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

kaddressbook

  • sources
  • kde-4.14
  • kdepim
  • kaddressbook
  • merge
  • manualmerge
mergecontactsdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-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 "mergecontactsdialog.h"
19 #include "utils.h"
20 #include "merge/manualmerge/mergecontactwidget.h"
21 #include "merge/widgets/mergecontactinfowidget.h"
22 #include "merge/job/mergecontactsjob.h"
23 #include "merge/widgets/mergecontacterrorlabel.h"
24 #include "merge/widgets/mergecontactselectinformationscrollarea.h"
25 #include <kaddressbook/merge/widgets/mergecontactselectinformationscrollarea.h>
26 
27 #include <Akonadi/Item>
28 
29 #include <KConfigGroup>
30 #include <KSharedConfig>
31 #include <KLocalizedString>
32 #include <KMessageBox>
33 
34 #include <QItemSelectionModel>
35 #include <QLabel>
36 #include <QSplitter>
37 #include <QHBoxLayout>
38 #include <QPointer>
39 #include <QStackedWidget>
40 
41 using namespace KABMergeContacts;
42 MergeContactsDialog::MergeContactsDialog(QWidget *parent)
43  : KDialog(parent)
44 {
45  setCaption( i18n( "Select Contacts to merge" ) );
46  setButtons( Close );
47  readConfig();
48 
49  mStackedWidget = new QStackedWidget(this);
50  mStackedWidget->setObjectName(QLatin1String("stackedwidget"));
51  setMainWidget(mStackedWidget);
52 
53  mNoEnoughContactSelected = new KABMergeContacts::MergeContactErrorLabel(KABMergeContacts::MergeContactErrorLabel::NotEnoughContactsSelected);
54  mNoEnoughContactSelected->setObjectName(QLatin1String("notenoughcontactselected"));
55  mStackedWidget->addWidget(mNoEnoughContactSelected);
56 
57  mNoContactSelected = new KABMergeContacts::MergeContactErrorLabel(MergeContactErrorLabel::NoContactSelected, this);
58  mNoContactSelected->setObjectName(QLatin1String("nocontactselected"));
59  mStackedWidget->addWidget(mNoContactSelected);
60 
61  mManualMergeResultWidget = new KABMergeContacts::MergeContactWidget(this);
62  mManualMergeResultWidget->setObjectName(QLatin1String("manualmergeresultwidget"));
63  mStackedWidget->addWidget(mManualMergeResultWidget);
64  connect(mManualMergeResultWidget, SIGNAL(customizeMergeContact(Akonadi::Item::List,MergeContacts::ConflictInformations,Akonadi::Collection)),
65  this, SLOT(slotCustomizeMergeContact(Akonadi::Item::List,MergeContacts::ConflictInformations,Akonadi::Collection)));
66  connect(mManualMergeResultWidget, SIGNAL(contactMerged(Akonadi::Item)),
67  this, SLOT(slotContactMerged(Akonadi::Item)));
68 
69  mSelectInformation = new KABMergeContacts::MergeContactSelectInformationScrollArea(this);
70  mSelectInformation->setObjectName(QLatin1String("selectioninformation"));
71  mStackedWidget->addWidget(mSelectInformation);
72 
73 
74  mMergeContactInfo = new KABMergeContacts::MergeContactInfoWidget;
75  mMergeContactInfo->setObjectName(QLatin1String("mergecontactinfowidget"));
76  mStackedWidget->addWidget(mMergeContactInfo);
77 
78 
79  mStackedWidget->setCurrentWidget(mNoContactSelected);
80 }
81 
82 MergeContactsDialog::~MergeContactsDialog()
83 {
84  writeConfig();
85 }
86 
87 void MergeContactsDialog::setContacts(const Akonadi::Item::List &list)
88 {
89  if (list.isEmpty()) {
90  mStackedWidget->setCurrentWidget(mNoContactSelected);
91  } else if (list.count() < 2){
92  mStackedWidget->setCurrentWidget(mNoEnoughContactSelected);
93  } else {
94  mManualMergeResultWidget->setContacts(list);
95  mStackedWidget->setCurrentWidget(mManualMergeResultWidget);
96  }
97 }
98 
99 void MergeContactsDialog::slotCustomizeMergeContact(const Akonadi::Item::List &lst, MergeContacts::ConflictInformations conflictType, const Akonadi::Collection &col)
100 {
101  mSelectInformation->setContacts(conflictType, lst, col);
102  mStackedWidget->setCurrentWidget(mSelectInformation);
103 }
104 
105 void MergeContactsDialog::readConfig()
106 {
107  KConfigGroup grp( KGlobal::config(), "MergeContactsDialog" );
108  const QSize size = grp.readEntry( "Size", QSize(300, 200) );
109  if ( size.isValid() ) {
110  resize( size );
111  }
112 }
113 
114 void MergeContactsDialog::writeConfig()
115 {
116  KConfigGroup grp( KGlobal::config(), "MergeContactsDialog");
117  grp.writeEntry( "Size", size() );
118  grp.sync();
119 }
120 
121 
122 void MergeContactsDialog::slotContactMerged(const Akonadi::Item &item)
123 {
124  mMergeContactInfo->setContact(item);
125  mStackedWidget->setCurrentWidget(mMergeContactInfo);
126 }
KABMergeContacts::MergeContactSelectInformationScrollArea::setContacts
void setContacts(MergeContacts::ConflictInformations conflictTypes, const Akonadi::Item::List &listItem, const Akonadi::Collection &col)
Definition: mergecontactselectinformationscrollarea.cpp:72
QWidget
QSize::isValid
bool isValid() const
KABMergeContacts::MergeContactWidget
Definition: mergecontactwidget.h:36
KABMergeContacts::MergeContactErrorLabel::NoContactSelected
Definition: mergecontacterrorlabel.h:31
mergecontactwidget.h
KABMergeContacts::MergeContactErrorLabel::NotEnoughContactsSelected
Definition: mergecontacterrorlabel.h:29
KDialog
KABMergeContacts::MergeContactWidget::setContacts
void setContacts(const Akonadi::Item::List &items)
Definition: mergecontactwidget.cpp:116
mergecontactsdialog.h
utils.h
QStackedWidget::setCurrentWidget
void setCurrentWidget(QWidget *widget)
KABMergeContacts::MergeContactInfoWidget::setContact
void setContact(const Akonadi::Item &item)
Definition: mergecontactinfowidget.cpp:59
KABMergeContacts::MergeContactsDialog::~MergeContactsDialog
~MergeContactsDialog()
Definition: mergecontactsdialog.cpp:82
KABMergeContacts::MergeContactsDialog::MergeContactsDialog
MergeContactsDialog(QWidget *parent=0)
Definition: mergecontactsdialog.cpp:42
mergecontactsjob.h
QObject::setObjectName
void setObjectName(const QString &name)
mergecontacterrorlabel.h
QStackedWidget
KABMergeContacts::MergeContactInfoWidget
Definition: mergecontactinfowidget.h:31
QSize
KABMergeContacts::MergeContactErrorLabel
Definition: mergecontacterrorlabel.h:24
KABMergeContacts::MergeContactsDialog::setContacts
void setContacts(const Akonadi::Item::List &list)
Definition: mergecontactsdialog.cpp:87
QLatin1String
KABMergeContacts::MergeContactSelectInformationScrollArea
Definition: mergecontactselectinformationscrollarea.h:28
mergecontactselectinformationscrollarea.h
QStackedWidget::addWidget
int addWidget(QWidget *widget)
mergecontactinfowidget.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kaddressbook

Skip menu "kaddressbook"
  • 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