• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • 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 <QtGui/QButtonGroup>
00027 #include <QtGui/QGroupBox>
00028 #include <QtGui/QLayout>
00029 #include <QtGui/QRadioButton>
00030 
00031 #include "emailselectdialog.moc"
00032 
00033 using namespace KABC;
00034 
00035 class EmailSelectDialog::Private
00036 {
00037   public:
00038     QButtonGroup *mButtonGroup;
00039 };
00040 
00041 EmailSelectDialog::EmailSelectDialog( const QStringList &emails,
00042                                       const QString &current,
00043                                       QWidget *parent )
00044   : KDialog( parent ), d( new Private )
00045 {
00046   setCaption( i18n( "Select Email Address" ) );
00047   setButtons( Ok );
00048   setDefaultButton( Ok );
00049 
00050   QFrame *topFrame = new QFrame( this );
00051   setMainWidget( topFrame );
00052 
00053   QBoxLayout *topLayout = new QVBoxLayout( topFrame );
00054   QGroupBox *box = new QGroupBox( i18n( "Email Addresses" ) );
00055   d->mButtonGroup = new QButtonGroup( box );
00056   d->mButtonGroup->setExclusive( true );
00057   topLayout->addWidget( box );
00058 
00059   QStringList::ConstIterator it;
00060   for ( it = emails.begin(); it != emails.end(); ++it ) {
00061     QRadioButton *button = new QRadioButton( *it, box );
00062     d->mButtonGroup->addButton( button );
00063     if ( (*it) == current ) {
00064       button->setChecked( true );
00065     }
00066   }
00067 }
00068 
00069 EmailSelectDialog::~EmailSelectDialog()
00070 {
00071   delete d;
00072 }
00073 
00074 QString EmailSelectDialog::selected()
00075 {
00076   QAbstractButton *button = d->mButtonGroup->checkedButton();
00077   if ( button ) {
00078     return button->text();
00079   }
00080   return QString();
00081 }
00082 
00083 QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current,
00084                                      QWidget *parent )
00085 {
00086   EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent );
00087   dlg->exec();
00088 
00089   QString result = dlg->selected();
00090 
00091   delete dlg;
00092 
00093   return result;
00094 }
00095 
00096 class EditEntryItem : public QTreeWidgetItem
00097 {
00098   public:
00099     EditEntryItem( QTreeWidget *parent, const Addressee &addressee,
00100                const QString &email=QString() ) :
00101       QTreeWidgetItem( parent ),
00102       mAddressee( addressee ),
00103       mEmail( email )
00104     {
00105       setText( 0, addressee.realName() );
00106       if ( email.isEmpty() ) {
00107         setText( 1, addressee.preferredEmail() );
00108         setText( 2, i18n( "Yes" ) );
00109       } else {
00110         setText( 1, email );
00111         setText( 2, i18n( "No" ) );
00112       }
00113     }
00114 
00115     Addressee addressee() const
00116     {
00117       return mAddressee;
00118     }
00119 
00120     QString email() const
00121     {
00122       return mEmail;
00123     }
00124 
00125   private:
00126     Addressee mAddressee;
00127     QString mEmail;
00128 };

kabc

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.5
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