• 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
  • widgets
mergecontactselectinformationscrollarea.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 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 "mergecontactselectinformationscrollarea.h"
19 #include "mergecontactselectinformationwidget.h"
20 #include "merge/job/mergecontactsjob.h"
21 #include "merge/widgets/mergecontactinfowidget.h"
22 #include <QVBoxLayout>
23 #include <QScrollArea>
24 #include <QStackedWidget>
25 #include <QPushButton>
26 #include <KMessageBox>
27 using namespace KABMergeContacts;
28 
29 MergeContactSelectInformationScrollArea::MergeContactSelectInformationScrollArea(QWidget *parent)
30  : QWidget(parent)
31 {
32  QVBoxLayout *vbox = new QVBoxLayout;
33  setLayout(vbox);
34  mStackWidget = new QStackedWidget;
35  mStackWidget->setObjectName(QLatin1String("stackwidget"));
36  vbox->addWidget(mStackWidget);
37 
38  QWidget *selectMergeWidget = new QWidget;
39  selectMergeWidget->setObjectName(QLatin1String("selectwidget"));
40  QVBoxLayout *layout = new QVBoxLayout;
41  selectMergeWidget->setLayout(layout);
42  QScrollArea *area = new QScrollArea;
43  area->setWidgetResizable(true);
44  area->setObjectName(QLatin1String("scrollarea"));
45  layout->addWidget(area);
46  mSelectInformationWidget = new MergeContactSelectInformationWidget;
47  mSelectInformationWidget->setObjectName(QLatin1String("selectinformationwidget"));
48  area->setWidget(mSelectInformationWidget);
49 
50  QHBoxLayout *hbox = new QHBoxLayout;
51  hbox->addStretch();
52  //KF5 add i18n
53  QPushButton *mergeButton = new QPushButton(QLatin1String("Merge"));
54  mergeButton->setObjectName(QLatin1String("merge"));
55  hbox->addWidget(mergeButton);
56  layout->addLayout(hbox);
57  connect(mergeButton, SIGNAL(clicked()), this, SLOT(slotMergeContacts()));
58 
59  mStackWidget->addWidget(selectMergeWidget);
60 
61  mMergedContactWidget = new MergeContactInfoWidget;
62  mMergedContactWidget->setObjectName(QLatin1String("mergedcontactwidget"));
63  mStackWidget->addWidget(mMergedContactWidget);
64  mStackWidget->setCurrentWidget(selectMergeWidget);
65 }
66 
67 MergeContactSelectInformationScrollArea::~MergeContactSelectInformationScrollArea()
68 {
69 
70 }
71 
72 void MergeContactSelectInformationScrollArea::setContacts(MergeContacts::ConflictInformations conflictTypes, const Akonadi::Item::List &listItem, const Akonadi::Collection &col)
73 {
74  mCollection = col;
75  mListItem = listItem;
76  if (conflictTypes == MergeContacts::None) {
77  MergeContacts contact(mListItem);
78  KABC::Addressee addr = contact.mergedContact();
79  mergeContact(addr);
80  } else {
81  mSelectInformationWidget->setContacts(conflictTypes, listItem);
82  }
83 }
84 
85 void MergeContactSelectInformationScrollArea::slotMergeContacts()
86 {
87  if (!mCollection.isValid()) {
88  qDebug()<<" Invalid colletion";
89  return;
90  }
91  if (mListItem.isEmpty()) {
92  qDebug()<<" item list is empty";
93  return;
94  }
95  const bool result = mSelectInformationWidget->verifySelectedInfo();
96  if (!result) {
97  //KF5 add i18n
98  if (KMessageBox::No == KMessageBox::warningYesNo(this, QLatin1String("Some information was not selected. You can lose theses information. Do you want to continue merging?"), QLatin1String("Missing Selected Information")))
99  return;
100  }
101  MergeContacts contact(mListItem);
102  KABC::Addressee addr = contact.mergedContact(true);
103  mSelectInformationWidget->createContact(addr);
104  mergeContact(addr);
105 }
106 
107 void MergeContactSelectInformationScrollArea::mergeContact(const KABC::Addressee &addr)
108 {
109  if (!addr.isEmpty()) {
110  KABMergeContacts::MergeContactsJob *job = new KABMergeContacts::MergeContactsJob(this);
111  job->setNewContact(addr);
112  job->setDestination(mCollection);
113  job->setListItem(mListItem);
114  connect(job, SIGNAL(finished(Akonadi::Item)), this, SLOT(slotMergeDone(Akonadi::Item)));
115  job->start();
116  } else {
117  qDebug()<<" Address is empty";
118  }
119 }
120 
121 void MergeContactSelectInformationScrollArea::slotMergeDone(const Akonadi::Item &item)
122 {
123  mMergedContactWidget->setContact(item);
124  mStackWidget->setCurrentWidget(mMergedContactWidget);
125 }
QWidget::layout
QLayout * layout() const
KABMergeContacts::MergeContactsJob::setNewContact
void setNewContact(const KABC::Addressee &addr)
Definition: mergecontactsjob.cpp:82
KABMergeContacts::MergeContactSelectInformationScrollArea::setContacts
void setContacts(MergeContacts::ConflictInformations conflictTypes, const Akonadi::Item::List &listItem, const Akonadi::Collection &col)
Definition: mergecontactselectinformationscrollarea.cpp:72
QWidget
QScrollArea::setWidget
void setWidget(QWidget *widget)
KABMergeContacts::MergeContactSelectInformationScrollArea::~MergeContactSelectInformationScrollArea
~MergeContactSelectInformationScrollArea()
Definition: mergecontactselectinformationscrollarea.cpp:67
QHBoxLayout
KABMergeContacts::MergeContacts::None
Definition: mergecontacts.h:33
KABMergeContacts::MergeContactSelectInformationWidget
Definition: mergecontactselectinformationwidget.h:27
KABMergeContacts::MergeContacts
Definition: mergecontacts.h:26
KABMergeContacts::MergeContactsJob
Definition: mergecontactsjob.h:26
KABMergeContacts::MergeContactSelectInformationWidget::setContacts
void setContacts(MergeContacts::ConflictInformations conflictTypes, const Akonadi::Item::List &listItem)
Definition: mergecontactselectinformationwidget.cpp:39
KABMergeContacts::MergeContacts::mergedContact
KABC::Addressee mergedContact(bool excludeConflictPart=false)
Definition: mergecontacts.cpp:37
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QStackedWidget::setCurrentWidget
void setCurrentWidget(QWidget *widget)
QWidget::setLayout
void setLayout(QLayout *layout)
KABMergeContacts::MergeContactInfoWidget::setContact
void setContact(const Akonadi::Item &item)
Definition: mergecontactinfowidget.cpp:59
mergecontactsjob.h
QObject::setObjectName
void setObjectName(const QString &name)
KABMergeContacts::MergeContactSelectInformationWidget::createContact
void createContact(KABC::Addressee &addr)
Definition: mergecontactselectinformationwidget.cpp:129
QVBoxLayout
KABMergeContacts::MergeContactsJob::start
void start()
Definition: mergecontactsjob.cpp:56
QStackedWidget
KABMergeContacts::MergeContactInfoWidget
Definition: mergecontactinfowidget.h:31
KABMergeContacts::MergeContactSelectInformationScrollArea::MergeContactSelectInformationScrollArea
MergeContactSelectInformationScrollArea(QWidget *parent=0)
Definition: mergecontactselectinformationscrollarea.cpp:29
QScrollArea::setWidgetResizable
void setWidgetResizable(bool resizable)
KABMergeContacts::MergeContactsJob::setListItem
void setListItem(const Akonadi::Item::List &lstItem)
Definition: mergecontactsjob.cpp:87
QLatin1String
QBoxLayout::addStretch
void addStretch(int stretch)
QWidget::QWidget
QWidget(QWidget *parent, QFlags< Qt::WindowType > f)
mergecontactselectinformationwidget.h
KABMergeContacts::MergeContactSelectInformationWidget::verifySelectedInfo
bool verifySelectedInfo() const
Definition: mergecontactselectinformationwidget.cpp:117
QPushButton
QScrollArea
mergecontactselectinformationscrollarea.h
QStackedWidget::addWidget
int addWidget(QWidget *widget)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KABMergeContacts::MergeContactsJob::setDestination
void setDestination(const Akonadi::Collection &collection)
Definition: mergecontactsjob.cpp:92
mergecontactinfowidget.h
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: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