21 #include "emailselectdialog.h"
22 #include "addresseedialog.h"
24 #include <klocalizedstring.h>
26 #include <QtCore/QPointer>
27 #include <QButtonGroup>
28 #include <QTreeWidget>
31 #include <QRadioButton>
36 class EmailSelectDialog::Private
39 QButtonGroup *mButtonGroup;
42 EmailSelectDialog::EmailSelectDialog(
const QStringList &emails,
43 const QString ¤t,
45 : KDialog( parent ), d( new Private )
47 setCaption( i18n(
"Select Email Address" ) );
49 setDefaultButton( Ok );
51 QFrame *topFrame =
new QFrame(
this );
52 setMainWidget( topFrame );
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;
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 );
71 layout->addStretch( 1 );
72 box->setLayout( layout );
75 EmailSelectDialog::~EmailSelectDialog()
80 QString EmailSelectDialog::selected()
82 QAbstractButton *button = d->mButtonGroup->checkedButton();
84 return button->text();
89 QString EmailSelectDialog::getEmail(
const QStringList &emails,
const QString ¤t,
92 QPointer<EmailSelectDialog> dlg =
new EmailSelectDialog( emails, current, parent );
95 if ( dlg->exec() && dlg ) {
96 result = dlg->selected();
104 class EditEntryItem :
public QTreeWidgetItem
107 EditEntryItem( QTreeWidget *parent,
const Addressee &addressee,
108 const QString &email=QString() ) :
109 QTreeWidgetItem( parent ),
110 mAddressee( addressee ),
114 if ( email.isEmpty() ) {
116 setText( 2, i18nc(
"this the preferred email address",
"Yes" ) );
119 setText( 2, i18nc(
"this is not preferred email address",
"No" ) );
128 QString email()
const
QString realName() const
Return the name of the addressee.
QString preferredEmail() const
Return preferred email address.