• Skip to content
  • Skip to link menu
KDE 4.2 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   QVBoxLayout *layout = new QVBoxLayout;
00059 
00060   QStringList::ConstIterator it;
00061   for ( it = emails.begin(); it != emails.end(); ++it ) {
00062     QRadioButton *button = new QRadioButton( *it, box );
00063     d->mButtonGroup->addButton( button );
00064     layout->addWidget( button );
00065     if ( (*it) == current ) {
00066       button->setChecked( true );
00067     }
00068   }
00069   layout->addStretch( 1 );
00070   box->setLayout( layout );
00071 }
00072 
00073 EmailSelectDialog::~EmailSelectDialog()
00074 {
00075   delete d;
00076 }
00077 
00078 QString EmailSelectDialog::selected()
00079 {
00080   QAbstractButton *button = d->mButtonGroup->checkedButton();
00081   if ( button ) {
00082     return button->text();
00083   }
00084   return QString();
00085 }
00086 
00087 QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current,
00088                                      QWidget *parent )
00089 {
00090   EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent );
00091   dlg->exec();
00092 
00093   QString result = dlg->selected();
00094 
00095   delete dlg;
00096 
00097   return result;
00098 }
00099 
00100 class EditEntryItem : public QTreeWidgetItem
00101 {
00102   public:
00103     EditEntryItem( QTreeWidget *parent, const Addressee &addressee,
00104                const QString &email=QString() ) :
00105       QTreeWidgetItem( parent ),
00106       mAddressee( addressee ),
00107       mEmail( email )
00108     {
00109       setText( 0, addressee.realName() );
00110       if ( email.isEmpty() ) {
00111         setText( 1, addressee.preferredEmail() );
00112         setText( 2, i18nc( "this the preferred email address", "Yes" ) );
00113       } else {
00114         setText( 1, email );
00115         setText( 2, i18nc( "this is not preferred email address", "No" ) );
00116       }
00117     }
00118 
00119     Addressee addressee() const
00120     {
00121       return mAddressee;
00122     }
00123 
00124     QString email() const
00125     {
00126       return mEmail;
00127     }
00128 
00129   private:
00130     Addressee mAddressee;
00131     QString mEmail;
00132 };

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