Commit cfa4938b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to select vcard from existing vcard

parent adb38d7a
......@@ -17,6 +17,8 @@
#include "identityaddvcarddialog.h"
#include <kpimidentities/identitymanager.h>
#include <QVBoxLayout>
#include <QRadioButton>
#include <QLabel>
......@@ -25,7 +27,7 @@
#include <QButtonGroup>
IdentityAddVcardDialog::IdentityAddVcardDialog(QWidget *parent)
IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent)
:KDialog(parent)
{
setCaption( i18n( "Create own vcard" ) );
......@@ -56,7 +58,8 @@ IdentityAddVcardDialog::IdentityAddVcardDialog(QWidget *parent)
vlay->addLayout( hlay );
mComboBox = new KComboBox( this );
mComboBox->setEditable( false );
//mComboBox->addItems( manager->shadowIdentities() );
mComboBox->addItems( manager->shadowIdentities() );
mComboBox->setEnabled( false );
QLabel *label = new QLabel( i18n("&Existing identities:"), this );
label->setBuddy( mComboBox );
......
......@@ -21,12 +21,16 @@
class QButtonGroup;
class KComboBox;
namespace KPIMIdentities {
class IdentityManager;
}
class IdentityAddVcardDialog: public KDialog
{
Q_OBJECT
public:
enum DuplicateMode { Empty, ExistingEntry };
explicit IdentityAddVcardDialog(QWidget *parent = 0);
explicit IdentityAddVcardDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent = 0);
~IdentityAddVcardDialog();
DuplicateMode duplicateMode() const;
......
......@@ -31,6 +31,7 @@
#include "identitydialog.h"
#include "identityeditvcarddialog.h"
#include "identityaddvcarddialog.h"
// other KMail headers:
#ifndef KDEPIM_MOBILE_UI
......@@ -902,20 +903,37 @@ namespace KMail {
void IdentityDialog::slotEditVcard()
{
if(QFile(mVcardFilename).exists()) {
IdentityEditVcardDialog dlg(this);
dlg.loadVcard(mVcardFilename);
if(dlg.exec()) {
mVcardFilename = dlg.saveVcard();
updateVcardButton();
}
editVcard(mVcardFilename);
} else {
IdentityEditVcardDialog dlg(this);
dlg.loadVcard(mVcardFilename);
if(dlg.exec()) {
mVcardFilename = dlg.saveVcard();
updateVcardButton();
if ( !MailCommon::Kernel::self()->kernelIsRegistered() ) {
return;
}
KPIMIdentities::IdentityManager *manager = KernelIf->identityManager();
IdentityAddVcardDialog dlg(manager, this);
if(dlg.exec()) {
IdentityAddVcardDialog::DuplicateMode mode = dlg.duplicateMode();
switch(mode) {
case IdentityAddVcardDialog::Empty: {
editVcard(mVcardFilename);
}
break;
case IdentityAddVcardDialog::ExistingEntry:
//TODO copy existing vcard
editVcard(mVcardFilename);
break;
}
}
}
}
void IdentityDialog::editVcard(const QString& filename)
{
IdentityEditVcardDialog dlg(this);
dlg.loadVcard(filename);
if(dlg.exec()) {
mVcardFilename = dlg.saveVcard();
updateVcardButton();
}
}
......
......@@ -98,7 +98,7 @@ namespace KMail {
bool checkFolderExists( const QString & folder, const QString & msg );
bool validateAddresses( const QString & addresses );
void updateVcardButton();
void editVcard(const QString& filename);
protected:
// "general" tab:
KLineEdit *mNameEdit;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment