2
Copyright (c) 2012 Montel Laurent <montel@kde.org>
4
This program is free software; you can redistribute it and/or modify it
5
under the terms of the GNU General Public License, version 2, as
6
published by the Free Software Foundation.
8
This program is distributed in the hope that it will be useful, but
9
WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
General Public License for more details.
13
You should have received a copy of the GNU General Public License along
14
with this program; if not, write to the Free Software Foundation, Inc.,
15
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
#include "identityaddvcarddialog.h"
20
#include <kpimidentities/identitymanager.h>
22
#include <QVBoxLayout>
23
#include <QRadioButton>
27
#include <QButtonGroup>
30
IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent)
33
setCaption( i18n( "Create own vcard" ) );
34
setButtons( Ok|Cancel );
35
setDefaultButton( Ok );
37
QWidget *mainWidget = new QWidget( this );
38
QVBoxLayout *vlay = new QVBoxLayout( mainWidget );
39
vlay->setSpacing( KDialog::spacingHint() );
40
vlay->setMargin( KDialog::marginHint() );
41
setMainWidget( mainWidget );
43
mButtonGroup = new QButtonGroup( this );
45
// row 1: radio button
46
QRadioButton *radio = new QRadioButton( i18n("&With empty fields"), this );
47
radio->setChecked( true );
48
vlay->addWidget( radio );
49
mButtonGroup->addButton( radio, (int)Empty );
51
// row 2: radio button
52
radio = new QRadioButton( i18n("&Duplicate existing vcard"), this );
53
vlay->addWidget( radio );
54
mButtonGroup->addButton( radio, (int)ExistingEntry );
56
// row 3: combobox with existing identities and label
57
QHBoxLayout* hlay = new QHBoxLayout(); // inherits spacing
58
vlay->addLayout( hlay );
59
mComboBox = new KComboBox( this );
60
mComboBox->setEditable( false );
62
mComboBox->addItems( manager->shadowIdentities() );
63
mComboBox->setEnabled( false );
64
QLabel *label = new QLabel( i18n("&Existing identities:"), this );
65
label->setBuddy( mComboBox );
66
label->setEnabled( false );
67
hlay->addWidget( label );
68
hlay->addWidget( mComboBox, 1 );
70
vlay->addStretch( 1 ); // spacer
72
// enable/disable combobox and label depending on the third radio
74
connect( radio, SIGNAL(toggled(bool)),
75
label, SLOT(setEnabled(bool)) );
76
connect( radio, SIGNAL(toggled(bool)),
77
mComboBox, SLOT(setEnabled(bool)) );
81
IdentityAddVcardDialog::~IdentityAddVcardDialog()
85
IdentityAddVcardDialog::DuplicateMode IdentityAddVcardDialog::duplicateMode() const
87
const int id = mButtonGroup->checkedId();
88
return static_cast<DuplicateMode>( id );
91
QString IdentityAddVcardDialog::duplicateVcardFromIdentity() const
93
return mComboBox->currentText();
96
#include "identityaddvcarddialog.moc"