• Skip to content
  • Skip to link menu
KDE 4.8 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

kabc

emailselectdialog.cpp
00001 /*
00002   This file is part of the kabc library.
00003   Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public License
00016   along with this library; see the file COPYING.LIB.  If not, write to
00017   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018   Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "emailselectdialog.h"
00022 #include "addresseedialog.h"
00023 
00024 #include <klocale.h>
00025 
00026 #include <QtCore/QPointer>
00027 #include <QtGui/QButtonGroup>
00028 #include <QtGui/QGroupBox>
00029 #include <QtGui/QLayout>
00030 #include <QtGui/QRadioButton>
00031 
00032 #include "emailselectdialog.moc"
00033 
00034 using namespace KABC;
00035 
00036 class EmailSelectDialog::Private
00037 {
00038   public:
00039     QButtonGroup *mButtonGroup;
00040 };
00041 
00042 EmailSelectDialog::EmailSelectDialog( const QStringList &emails,
00043                                       const QString &current,
00044                                       QWidget *parent )
00045   : KDialog( parent ), d( new Private )
00046 {
00047   setCaption( i18n( "Select Email Address" ) );
00048   setButtons( Ok );
00049   setDefaultButton( Ok );
00050 
00051   QFrame *topFrame = new QFrame( this );
00052   setMainWidget( topFrame );
00053 
00054   QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00055   QGroupBox *box = new QGroupBox( i18n( "Email Addresses" ) );
00056   d->mButtonGroup = new QButtonGroup( box );
00057   d->mButtonGroup->setExclusive( true );
00058   topLayout->addWidget( box );
00059   QVBoxLayout *layout = new QVBoxLayout;
00060 
00061   QStringList::ConstIterator it;
00062   for ( it = emails.begin(); it != emails.end(); ++it ) {
00063     QRadioButton *button = new QRadioButton( *it, box );
00064     d->mButtonGroup->addButton( button );
00065     layout->addWidget( button );
00066     if ( (*it) == current ) {
00067       button->setChecked( true );
00068     }
00069   }
00070   layout->addStretch( 1 );
00071   box->setLayout( layout );
00072 }
00073 
00074 EmailSelectDialog::~EmailSelectDialog()
00075 {
00076   delete d;
00077 }
00078 
00079 QString EmailSelectDialog::selected()
00080 {
00081   QAbstractButton *button = d->mButtonGroup->checkedButton();
00082   if ( button ) {
00083     return button->text();
00084   }
00085   return QString();
00086 }
00087 
00088 QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current,
00089                                      QWidget *parent )
00090 {
00091   QPointer<EmailSelectDialog> dlg = new EmailSelectDialog( emails, current, parent );
00092 
00093   QString result;
00094   if ( dlg->exec() && dlg ) {
00095     result = dlg->selected();
00096   }
00097 
00098   delete dlg;
00099 
00100   return result;
00101 }
00102 
00103 class EditEntryItem : public QTreeWidgetItem
00104 {
00105   public:
00106     EditEntryItem( QTreeWidget *parent, const Addressee &addressee,
00107                const QString &email=QString() ) :
00108       QTreeWidgetItem( parent ),
00109       mAddressee( addressee ),
00110       mEmail( email )
00111     {
00112       setText( 0, addressee.realName() );
00113       if ( email.isEmpty() ) {
00114         setText( 1, addressee.preferredEmail() );
00115         setText( 2, i18nc( "this the preferred email address", "Yes" ) );
00116       } else {
00117         setText( 1, email );
00118         setText( 2, i18nc( "this is not preferred email address", "No" ) );
00119       }
00120     }
00121 
00122     Addressee addressee() const
00123     {
00124       return mAddressee;
00125     }
00126 
00127     QString email() const
00128     {
00129       return mEmail;
00130     }
00131 
00132   private:
00133     Addressee mAddressee;
00134     QString mEmail;
00135 };

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal