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

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 <klocalizedstring.h>
25 
26 #include <QtCore/QPointer>
27 #include <QButtonGroup>
28 #include <QTreeWidget>
29 #include <QGroupBox>
30 #include <QLayout>
31 #include <QRadioButton>
32 
33 
34 using namespace KABC;
35 
36 class EmailSelectDialog::Private
37 {
38  public:
39  QButtonGroup *mButtonGroup;
40 };
41 
42 EmailSelectDialog::EmailSelectDialog( const QStringList &emails,
43  const QString &current,
44  QWidget *parent )
45  : KDialog( parent ), d( new Private )
46 {
47  setCaption( i18n( "Select Email Address" ) );
48  setButtons( Ok );
49  setDefaultButton( Ok );
50 
51  QFrame *topFrame = new QFrame( this );
52  setMainWidget( topFrame );
53 
54  QBoxLayout *topLayout = new QVBoxLayout( topFrame );
55  QGroupBox *box = new QGroupBox( i18n( "Email Addresses" ) );
56  d->mButtonGroup = new QButtonGroup( box );
57  d->mButtonGroup->setExclusive( true );
58  topLayout->addWidget( box );
59  QVBoxLayout *layout = new QVBoxLayout;
60 
61  QStringList::ConstIterator it;
62  QStringList::ConstIterator end( emails.end() );
63  for ( it = emails.begin(); it != end; ++it ) {
64  QRadioButton *button = new QRadioButton( *it, box );
65  d->mButtonGroup->addButton( button );
66  layout->addWidget( button );
67  if ( ( *it ) == current ) {
68  button->setChecked( true );
69  }
70  }
71  layout->addStretch( 1 );
72  box->setLayout( layout );
73 }
74 
75 EmailSelectDialog::~EmailSelectDialog()
76 {
77  delete d;
78 }
79 
80 QString EmailSelectDialog::selected()
81 {
82  QAbstractButton *button = d->mButtonGroup->checkedButton();
83  if ( button ) {
84  return button->text();
85  }
86  return QString();
87 }
88 
89 QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current,
90  QWidget *parent )
91 {
92  QPointer<EmailSelectDialog> dlg = new EmailSelectDialog( emails, current, parent );
93 
94  QString result;
95  if ( dlg->exec() && dlg ) {
96  result = dlg->selected();
97  }
98 
99  delete dlg;
100 
101  return result;
102 }
103 
104 class EditEntryItem : public QTreeWidgetItem
105 {
106  public:
107  EditEntryItem( QTreeWidget *parent, const Addressee &addressee,
108  const QString &email=QString() ) :
109  QTreeWidgetItem( parent ),
110  mAddressee( addressee ),
111  mEmail( email )
112  {
113  setText( 0, addressee.realName() );
114  if ( email.isEmpty() ) {
115  setText( 1, addressee.preferredEmail() );
116  setText( 2, i18nc( "this the preferred email address", "Yes" ) );
117  } else {
118  setText( 1, email );
119  setText( 2, i18nc( "this is not preferred email address", "No" ) );
120  }
121  }
122 
123  Addressee addressee() const
124  {
125  return mAddressee;
126  }
127 
128  QString email() const
129  {
130  return mEmail;
131  }
132 
133  private:
134  Addressee mAddressee;
135  QString mEmail;
136 };
KABC::Addressee::realName
QString realName() const
Return the name of the addressee.
Definition: addressee.cpp:1177
KABC::Addressee::preferredEmail
QString preferredEmail() const
Return preferred email address.
Definition: addressee.cpp:1259
KABC::Addressee
address book entry
Definition: addressee.h:74
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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