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

kmail

  • sources
  • kde-4.14
  • kdepim
  • kmail
  • identity
identityaddvcarddialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012-2015 Montel Laurent <montel@kde.org>
3 
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.
7 
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.
12 
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
16 */
17 
18 #include "identityaddvcarddialog.h"
19 
20 #include <KComboBox>
21 #include <KLocalizedString>
22 #include <KSeparator>
23 #include <KUrlRequester>
24 
25 #include <QButtonGroup>
26 #include <QVBoxLayout>
27 #include <QRadioButton>
28 #include <QLabel>
29 
30 
31 IdentityAddVcardDialog::IdentityAddVcardDialog(const QStringList &shadowIdentities, QWidget *parent)
32  : KDialog(parent)
33 {
34  setCaption( i18n( "Create own vCard" ) );
35  setButtons( Ok|Cancel );
36  setDefaultButton( Ok );
37  setModal( true );
38  QWidget *mainWidget = new QWidget( this );
39  QVBoxLayout *vlay = new QVBoxLayout( mainWidget );
40  vlay->setSpacing( KDialog::spacingHint() );
41  vlay->setMargin( KDialog::marginHint() );
42  setMainWidget( mainWidget );
43 
44  mButtonGroup = new QButtonGroup( this );
45  mButtonGroup->setObjectName(QLatin1String("buttongroup"));
46 
47  // row 1: radio button
48  QRadioButton *radio = new QRadioButton( i18n("&With empty fields"), this );
49  radio->setChecked( true );
50  vlay->addWidget( radio );
51  mButtonGroup->addButton( radio, (int)Empty );
52 
53  // row 2: radio button
54  QRadioButton *fromExistingVCard = new QRadioButton( i18n("&From existing vCard"), this );
55  vlay->addWidget( fromExistingVCard );
56  mButtonGroup->addButton( fromExistingVCard, (int)FromExistingVCard );
57 
58  // row 3: KUrlRequester
59  QHBoxLayout* hlay = new QHBoxLayout(); // inherits spacing
60  vlay->addLayout( hlay );
61 
62 
63  mVCardPath = new KUrlRequester;
64  mVCardPath->setObjectName(QLatin1String("kurlrequester_vcardpath"));
65  const QString filter = i18n( "*.vcf|vCard (*.vcf)\n*|all files (*)" );
66  mVCardPath->setFilter(filter);
67 
68  mVCardPath->setMode(KFile::LocalOnly|KFile::File);
69  QLabel *label = new QLabel( i18n("&VCard path:"), this );
70  label->setBuddy( mVCardPath );
71  label->setEnabled( false );
72  mVCardPath->setEnabled( false );
73  hlay->addWidget( label );
74  hlay->addWidget( mVCardPath );
75 
76  connect( fromExistingVCard, SIGNAL(toggled(bool)),
77  label, SLOT(setEnabled(bool)) );
78  connect( fromExistingVCard, SIGNAL(toggled(bool)),
79  mVCardPath, SLOT(setEnabled(bool)) );
80 
81 
82  // row 4: radio button
83  QRadioButton *duplicateExistingVCard = new QRadioButton( i18n("&Duplicate existing vCard"), this );
84  vlay->addWidget( duplicateExistingVCard );
85  mButtonGroup->addButton( duplicateExistingVCard, (int)ExistingEntry );
86 
87  // row 5: combobox with existing identities and label
88  hlay = new QHBoxLayout(); // inherits spacing
89  vlay->addLayout( hlay );
90  mComboBox = new KComboBox( this );
91  mComboBox->setObjectName(QLatin1String("identity_combobox"));
92  mComboBox->setEditable( false );
93 
94  mComboBox->addItems( shadowIdentities );
95  mComboBox->setEnabled( false );
96  label = new QLabel( i18n("&Existing identities:"), this );
97  label->setBuddy( mComboBox );
98  label->setEnabled( false );
99  hlay->addWidget( label );
100  hlay->addWidget( mComboBox, 1 );
101 
102  vlay->addWidget(new KSeparator);
103  vlay->addStretch( 1 ); // spacer
104 
105  // enable/disable combobox and label depending on the third radio
106  // button's state:
107  connect( duplicateExistingVCard, SIGNAL(toggled(bool)),
108  label, SLOT(setEnabled(bool)) );
109  connect( duplicateExistingVCard, SIGNAL(toggled(bool)),
110  mComboBox, SLOT(setEnabled(bool)) );
111  resize(350, 130);
112 }
113 
114 IdentityAddVcardDialog::~IdentityAddVcardDialog()
115 {
116 }
117 
118 IdentityAddVcardDialog::DuplicateMode IdentityAddVcardDialog::duplicateMode() const
119 {
120  const int id = mButtonGroup->checkedId();
121  return static_cast<DuplicateMode>( id );
122 }
123 
124 QString IdentityAddVcardDialog::duplicateVcardFromIdentity() const
125 {
126  return mComboBox->currentText();
127 }
128 
129 KUrl IdentityAddVcardDialog::existingVCard() const
130 {
131  return mVCardPath->url();
132 }
133 
QWidget
identityaddvcarddialog.h
IdentityAddVcardDialog::~IdentityAddVcardDialog
~IdentityAddVcardDialog()
Definition: identityaddvcarddialog.cpp:114
IdentityAddVcardDialog::existingVCard
KUrl existingVCard() const
Definition: identityaddvcarddialog.cpp:129
QButtonGroup::addButton
void addButton(QAbstractButton *button)
QHBoxLayout
IdentityAddVcardDialog::DuplicateMode
DuplicateMode
Definition: identityaddvcarddialog.h:29
KDialog
IdentityAddVcardDialog::FromExistingVCard
Definition: identityaddvcarddialog.h:32
IdentityAddVcardDialog::IdentityAddVcardDialog
IdentityAddVcardDialog(const QStringList &shadowIdentities, QWidget *parent=0)
Definition: identityaddvcarddialog.cpp:31
QButtonGroup
IdentityAddVcardDialog::duplicateVcardFromIdentity
QString duplicateVcardFromIdentity() const
Definition: identityaddvcarddialog.cpp:124
QLabel::setBuddy
void setBuddy(QWidget *buddy)
QWidget::setEnabled
void setEnabled(bool)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
IdentityAddVcardDialog::duplicateMode
DuplicateMode duplicateMode() const
Definition: identityaddvcarddialog.cpp:118
QObject::setObjectName
void setObjectName(const QString &name)
QVBoxLayout
IdentityAddVcardDialog::Empty
Definition: identityaddvcarddialog.h:30
QString
QLayout::setMargin
void setMargin(int margin)
QStringList
QAbstractButton::setChecked
void setChecked(bool)
QButtonGroup::checkedId
int checkedId() const
QLatin1String
QBoxLayout::addStretch
void addStretch(int stretch)
QRadioButton
KComboBox
IdentityAddVcardDialog::ExistingEntry
Definition: identityaddvcarddialog.h:31
QLabel
QBoxLayout::setSpacing
void setSpacing(int spacing)
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

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