• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

kabc

  • kabc
emailselectdialog.cpp
1 /*
2  This file is part of the kabc library.
3  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "emailselectdialog.h"
22 #include "addresseedialog.h"
23 
24 #include <klocale.h>
25 
26 #include <QtCore/QPointer>
27 #include <QButtonGroup>
28 #include <QGroupBox>
29 #include <QLayout>
30 #include <QRadioButton>
31 
32 
33 using namespace KABC;
34 
35 class EmailSelectDialog::Private
36 {
37  public:
38  QButtonGroup *mButtonGroup;
39 };
40 
41 EmailSelectDialog::EmailSelectDialog( const QStringList &emails,
42  const QString &current,
43  QWidget *parent )
44  : KDialog( parent ), d( new Private )
45 {
46  setCaption( i18n( "Select Email Address" ) );
47  setButtons( Ok );
48  setDefaultButton( Ok );
49 
50  QFrame *topFrame = new QFrame( this );
51  setMainWidget( topFrame );
52 
53  QBoxLayout *topLayout = new QVBoxLayout( topFrame );
54  QGroupBox *box = new QGroupBox( i18n( "Email Addresses" ) );
55  d->mButtonGroup = new QButtonGroup( box );
56  d->mButtonGroup->setExclusive( true );
57  topLayout->addWidget( box );
58  QVBoxLayout *layout = new QVBoxLayout;
59 
60  QStringList::ConstIterator it;
61  QStringList::ConstIterator end( emails.end() );
62  for ( it = emails.begin(); it != end; ++it ) {
63  QRadioButton *button = new QRadioButton( *it, box );
64  d->mButtonGroup->addButton( button );
65  layout->addWidget( button );
66  if ( ( *it ) == current ) {
67  button->setChecked( true );
68  }
69  }
70  layout->addStretch( 1 );
71  box->setLayout( layout );
72 }
73 
74 EmailSelectDialog::~EmailSelectDialog()
75 {
76  delete d;
77 }
78 
79 QString EmailSelectDialog::selected()
80 {
81  QAbstractButton *button = d->mButtonGroup->checkedButton();
82  if ( button ) {
83  return button->text();
84  }
85  return QString();
86 }
87 
88 QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current,
89  QWidget *parent )
90 {
91  QPointer<EmailSelectDialog> dlg = new EmailSelectDialog( emails, current, parent );
92 
93  QString result;
94  if ( dlg->exec() && dlg ) {
95  result = dlg->selected();
96  }
97 
98  delete dlg;
99 
100  return result;
101 }
102 
103 class EditEntryItem : public QTreeWidgetItem
104 {
105  public:
106  EditEntryItem( QTreeWidget *parent, const Addressee &addressee,
107  const QString &email=QString() ) :
108  QTreeWidgetItem( parent ),
109  mAddressee( addressee ),
110  mEmail( email )
111  {
112  setText( 0, addressee.realName() );
113  if ( email.isEmpty() ) {
114  setText( 1, addressee.preferredEmail() );
115  setText( 2, i18nc( "this the preferred email address", "Yes" ) );
116  } else {
117  setText( 1, email );
118  setText( 2, i18nc( "this is not preferred email address", "No" ) );
119  }
120  }
121 
122  Addressee addressee() const
123  {
124  return mAddressee;
125  }
126 
127  QString email() const
128  {
129  return mEmail;
130  }
131 
132  private:
133  Addressee mAddressee;
134  QString mEmail;
135 };
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:29:40 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

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

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal