Merge remote-tracking branch 'origin/master' into frameworks

Conflicts:
	doc/CMakeLists.txt
wilder-work
Montel Laurent 12 years ago
commit e2d5e7ff74
  1. 53
      identity/identityaddvcarddialog.cpp
  2. 6
      identity/identityaddvcarddialog.h
  3. 9
      identity/identitydialog.cpp
  4. 4
      tests/CMakeLists.txt
  5. 79
      tests/identityaddvcarddialogtest.cpp
  6. 36
      tests/identityaddvcarddialogtest.h

@ -22,6 +22,7 @@
#include <KComboBox>
#include <KLocalizedString>
#include <KSeparator>
#include <KUrlRequester>
#include <QButtonGroup>
#include <QVBoxLayout>
@ -30,7 +31,7 @@
IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent)
:KDialog(parent)
: KDialog(parent)
{
setCaption( i18n( "Create own vCard" ) );
setButtons( Ok|Cancel );
@ -43,6 +44,7 @@ IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *
setMainWidget( mainWidget );
mButtonGroup = new QButtonGroup( this );
mButtonGroup->setObjectName(QLatin1String("buttongroup"));
// row 1: radio button
QRadioButton *radio = new QRadioButton( i18n("&With empty fields"), this );
@ -51,19 +53,47 @@ IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *
mButtonGroup->addButton( radio, (int)Empty );
// row 2: radio button
radio = new QRadioButton( i18n("&Duplicate existing vCard"), this );
vlay->addWidget( radio );
mButtonGroup->addButton( radio, (int)ExistingEntry );
QRadioButton *fromExistingVCard = new QRadioButton( i18n("&From existing vCard"), this );
vlay->addWidget( fromExistingVCard );
mButtonGroup->addButton( fromExistingVCard, (int)FromExistingVCard );
// row 3: combobox with existing identities and label
// row 3: KUrlRequester
QHBoxLayout* hlay = new QHBoxLayout(); // inherits spacing
vlay->addLayout( hlay );
mVCardPath = new KUrlRequester;
mVCardPath->setObjectName(QLatin1String("kurlrequester_vcardpath"));
mVCardPath->setMode(KFile::LocalOnly|KFile::File);
QLabel *label = new QLabel( i18n("&VCard path:"), this );
label->setBuddy( mVCardPath );
label->setEnabled( false );
mVCardPath->setEnabled( false );
hlay->addWidget( label );
hlay->addWidget( mVCardPath );
connect( fromExistingVCard, SIGNAL(toggled(bool)),
label, SLOT(setEnabled(bool)) );
connect( fromExistingVCard, SIGNAL(toggled(bool)),
mVCardPath, SLOT(setEnabled(bool)) );
// row 4: radio button
QRadioButton *duplicateExistingVCard = new QRadioButton( i18n("&Duplicate existing vCard"), this );
vlay->addWidget( duplicateExistingVCard );
mButtonGroup->addButton( duplicateExistingVCard, (int)ExistingEntry );
// row 5: combobox with existing identities and label
hlay = new QHBoxLayout(); // inherits spacing
vlay->addLayout( hlay );
mComboBox = new KComboBox( this );
mComboBox->setObjectName(QLatin1String("identity_combobox"));
mComboBox->setEditable( false );
mComboBox->addItems( manager->shadowIdentities() );
mComboBox->addItems( manager ? manager->shadowIdentities() : QStringList() );
mComboBox->setEnabled( false );
QLabel *label = new QLabel( i18n("&Existing identities:"), this );
label = new QLabel( i18n("&Existing identities:"), this );
label->setBuddy( mComboBox );
label->setEnabled( false );
hlay->addWidget( label );
@ -74,9 +104,9 @@ IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *
// enable/disable combobox and label depending on the third radio
// button's state:
connect( radio, SIGNAL(toggled(bool)),
connect( duplicateExistingVCard, SIGNAL(toggled(bool)),
label, SLOT(setEnabled(bool)) );
connect( radio, SIGNAL(toggled(bool)),
connect( duplicateExistingVCard, SIGNAL(toggled(bool)),
mComboBox, SLOT(setEnabled(bool)) );
resize(350, 130);
}
@ -96,3 +126,8 @@ QString IdentityAddVcardDialog::duplicateVcardFromIdentity() const
return mComboBox->currentText();
}
KUrl IdentityAddVcardDialog::existingVCard() const
{
return mVCardPath->url();
}

@ -20,6 +20,7 @@
#include <KDialog>
class QButtonGroup;
class KComboBox;
class KUrlRequester;
namespace KPIMIdentities {
class IdentityManager;
@ -31,7 +32,8 @@ class IdentityAddVcardDialog: public KDialog
public:
enum DuplicateMode {
Empty,
ExistingEntry
ExistingEntry,
FromExistingVCard
};
explicit IdentityAddVcardDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent = 0);
@ -39,10 +41,12 @@ public:
DuplicateMode duplicateMode() const;
QString duplicateVcardFromIdentity() const;
KUrl existingVCard() const;
private:
QButtonGroup *mButtonGroup;
KComboBox *mComboBox;
KUrlRequester *mVCardPath;
};
#endif // IDENTITYADDVCARDDIALOG_H

@ -999,6 +999,15 @@ void IdentityDialog::slotEditVcard()
editVcard(mVcardFilename);
break;
}
case IdentityAddVcardDialog::FromExistingVCard: {
const QString filename = dlg->existingVCard().path();
if(!filename.isEmpty()) {
mVcardFilename = filename;
}
qDebug()<<" filename "<<filename;
editVcard(mVcardFilename);
break;
}
}
}
delete dlg;

@ -19,3 +19,7 @@ add_test( displaymessageformatactionmenutest displaymessageformatactionmenutest
ecm_mark_as_test(kmail-displaymessageformatactionmenutest)
target_link_libraries( displaymessageformatactionmenutest Qt5::Test messageviewer)
set( kmail_identityaddvcarddialog_source identityaddvcarddialogtest.cpp ../identity/identityaddvcarddialog.cpp )
kde4_add_unit_test( identityaddvcarddialogtest ${kmail_identityaddvcarddialog_source})
target_link_libraries( identityaddvcarddialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} kpimidentities)

@ -0,0 +1,79 @@
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "identityaddvcarddialogtest.h"
#include "../identity/identityaddvcarddialog.h"
#include <KComboBox>
#include <KUrlRequester>
#include <QButtonGroup>
#include <qtest_kde.h>
identityaddvcarddialogtest::identityaddvcarddialogtest()
{
}
void identityaddvcarddialogtest::shouldHaveDefaultValue()
{
IdentityAddVcardDialog dlg(0,0);
KComboBox *identityComboBox = qFindChild<KComboBox *>(&dlg, QLatin1String("identity_combobox"));
QVERIFY(identityComboBox);
QCOMPARE(identityComboBox->isEnabled(), false);
KUrlRequester *urlRequester = qFindChild<KUrlRequester *>(&dlg, QLatin1String("kurlrequester_vcardpath"));
QVERIFY(urlRequester);
QCOMPARE(urlRequester->isEnabled(), false);
QButtonGroup *buttonGroup = qFindChild<QButtonGroup *>(&dlg, QLatin1String("buttongroup"));
QVERIFY(buttonGroup);
QCOMPARE(dlg.duplicateMode(), IdentityAddVcardDialog::Empty);
QVERIFY(buttonGroup->button(IdentityAddVcardDialog::Empty));
QVERIFY(buttonGroup->button(IdentityAddVcardDialog::ExistingEntry));
QVERIFY(buttonGroup->button(IdentityAddVcardDialog::FromExistingVCard));
}
void identityaddvcarddialogtest::shouldEnabledUrlRequesterWhenSelectFromExistingVCard()
{
IdentityAddVcardDialog dlg(0,0);
QButtonGroup *buttonGroup = qFindChild<QButtonGroup *>(&dlg, QLatin1String("buttongroup"));
buttonGroup->button(IdentityAddVcardDialog::FromExistingVCard)->toggle();
QCOMPARE(dlg.duplicateMode(), IdentityAddVcardDialog::FromExistingVCard);
KComboBox *identityComboBox = qFindChild<KComboBox *>(&dlg, QLatin1String("identity_combobox"));
QCOMPARE(identityComboBox->isEnabled(), false);
KUrlRequester *urlRequester = qFindChild<KUrlRequester *>(&dlg, QLatin1String("kurlrequester_vcardpath"));
QCOMPARE(urlRequester->isEnabled(), true);
}
void identityaddvcarddialogtest::shouldEnabledComboboxWhenSelectDuplicateVCard()
{
IdentityAddVcardDialog dlg(0,0);
QButtonGroup *buttonGroup = qFindChild<QButtonGroup *>(&dlg, QLatin1String("buttongroup"));
buttonGroup->button(IdentityAddVcardDialog::ExistingEntry)->toggle();
QCOMPARE(dlg.duplicateMode(), IdentityAddVcardDialog::ExistingEntry);
KComboBox *identityComboBox = qFindChild<KComboBox *>(&dlg, QLatin1String("identity_combobox"));
QCOMPARE(identityComboBox->isEnabled(), true);
KUrlRequester *urlRequester = qFindChild<KUrlRequester *>(&dlg, QLatin1String("kurlrequester_vcardpath"));
QCOMPARE(urlRequester->isEnabled(), false);
}
QTEST_KDEMAIN(identityaddvcarddialogtest, GUI)

@ -0,0 +1,36 @@
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IDENTITYADDVCARDDIALOGTEST_H
#define IDENTITYADDVCARDDIALOGTEST_H
#include <QObject>
class identityaddvcarddialogtest : public QObject
{
Q_OBJECT
public:
identityaddvcarddialogtest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldEnabledUrlRequesterWhenSelectFromExistingVCard();
void shouldEnabledComboboxWhenSelectDuplicateVCard();
};
#endif // IDENTITYADDVCARDDIALOGTEST_H
Loading…
Cancel
Save