summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-10 09:19:54 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-10 09:19:54 (GMT)
commit7887f9b3047498f9248eb79e27f8a40c4a132ff3 (patch)
tree887734f1dfee2c288772d1eb29ef0da9b7348965
parentc652b89cebb6139dcf107e9dae2b1ddc65cac799 (diff)
Add dialogbox
-rw-r--r--CMakeLists.txt2
-rw-r--r--kaddressbookimportexport/src/CMakeLists.txt4
-rw-r--r--kaddressbookimportexport/src/kaddressbookcontactselectiondialog.cpp93
-rw-r--r--kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h82
-rw-r--r--kaddressbookimportexport/src/kaddressbookcontactselectionwidget.cpp332
-rw-r--r--kaddressbookimportexport/src/kaddressbookcontactselectionwidget.h100
6 files changed, 612 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 54e839f..7013a58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
-set(PIM_VERSION "5.3.47")
+set(PIM_VERSION "5.3.48")
set(KDEPIM_APPS_LIB_VERSION ${PIM_VERSION})
set(QT_REQUIRED_VERSION "5.6.0")
diff --git a/kaddressbookimportexport/src/CMakeLists.txt b/kaddressbookimportexport/src/CMakeLists.txt
index dd6b39e..6e32fd0 100644
--- a/kaddressbookimportexport/src/CMakeLists.txt
+++ b/kaddressbookimportexport/src/CMakeLists.txt
@@ -7,6 +7,8 @@ set(kaddressbook_importexport_LIB_SRCS
kaddressbookimportexportplugininterface.cpp
kaddressbookimportexportpluginmanager.cpp
kaddressbookimportexportcontactlist.cpp
+ kaddressbookcontactselectionwidget.cpp
+ kaddressbookcontactselectiondialog.cpp
)
ecm_qt_declare_logging_category(kaddressbook_importexport_LIB_SRCS HEADER libkaddressbookexportimport_debug.h IDENTIFIER LIBKADDRESSBOOKIMPORTEXPORT_LOG CATEGORY_NAME org.kde.pim.kaddressbookimportexport)
@@ -26,6 +28,7 @@ target_link_libraries(KF5KaddressbookImportExport
KF5::Contacts
KF5::Service
KF5::PimCommon
+ KF5::I18n
)
set_target_properties(KF5KaddressbookImportExport PROPERTIES
@@ -47,6 +50,7 @@ ecm_generate_headers(KaddressbookImportExport_CamelCase_HEADERS
KAddressBookImportExportPlugin
KAddressBookImportExportPluginManager
KAddressBookImportExportContactList
+ KAddressBookContactSelectionDialog
REQUIRED_HEADERS KaddressbookImportExport_HEADERS
PREFIX KAddressBookImportExport
)
diff --git a/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.cpp b/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.cpp
new file mode 100644
index 0000000..6881d33
--- /dev/null
+++ b/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.cpp
@@ -0,0 +1,93 @@
+/*
+ Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+ Copyright (c) 2015-2016 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This library 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 Library General Public
+ License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#include "kaddressbookcontactselectiondialog.h"
+#include "kaddressbookcontactselectionwidget.h"
+
+#include <QVBoxLayout>
+#include <KLocalizedString>
+#include <QDialogButtonBox>
+#include <QPushButton>
+using namespace KAddressBookImportExport;
+
+KAddressBookContactSelectionDialog::KAddressBookContactSelectionDialog(QItemSelectionModel *selectionModel, bool allowToSelectTypeToExport,
+ QWidget *parent)
+ : QDialog(parent)//,
+ //mVCardExport(Q_NULLPTR)
+{
+
+ setWindowTitle(i18n("Select Contacts"));
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+
+ mSelectionWidget = new KAddressBookContactSelectionWidget(selectionModel, this);
+ if (allowToSelectTypeToExport) {
+ mainLayout->addWidget(mSelectionWidget);
+#if 0
+ mVCardExport = new VCardExportSelectionWidget(this);
+ mainLayout->addWidget(mVCardExport);
+#endif
+ } else {
+ mainLayout->addWidget(mSelectionWidget);
+ }
+
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
+ QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
+ okButton->setDefault(true);
+ okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &KAddressBookContactSelectionDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &KAddressBookContactSelectionDialog::reject);
+ mainLayout->addWidget(buttonBox);
+}
+
+void KAddressBookContactSelectionDialog::setMessageText(const QString &message)
+{
+ mSelectionWidget->setMessageText(message);
+}
+
+void KAddressBookContactSelectionDialog::setDefaultAddressBook(const Akonadi::Collection &addressBook)
+{
+ mSelectionWidget->setDefaultAddressBook(addressBook);
+}
+
+Akonadi::Item::List KAddressBookContactSelectionDialog::selectedItems() const
+{
+ return mSelectionWidget->selectedItems();
+}
+
+KAddressBookImportExport::KAddressBookImportExportContactList KAddressBookContactSelectionDialog::selectedContacts() const
+{
+ return mSelectionWidget->selectedContacts();
+}
+#if 0
+VCardExportSelectionWidget::ExportFields KAddressBookContactSelectionDialog::exportType() const
+{
+ if (mVCardExport) {
+ return mVCardExport->exportType();
+ } else {
+ return VCardExportSelectionWidget::None;
+ }
+}
+#endif
+
+void KAddressBookContactSelectionDialog::setAddGroupContact(bool addGroupContact)
+{
+ mSelectionWidget->setAddGroupContact(addGroupContact);
+}
+
diff --git a/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h b/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h
new file mode 100644
index 0000000..bb2e4b8
--- /dev/null
+++ b/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h
@@ -0,0 +1,82 @@
+/*
+ Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+ Copyright (c) 2015 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This library 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 Library General Public
+ License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#ifndef CONTACTEXPORTSELECTIONDIALOG_H
+#define CONTACTEXPORTSELECTIONDIALOG_H
+
+#include "kaddressbookimportexportplugin.h"
+#include <KContacts/Addressee>
+#include <QDialog>
+#include <KAddressBookImportExport/KAddressBookImportExportContactList>
+//#include <xxport/vcard/vcardexportselectionwidget.h>
+#include <AkonadiCore/Item>
+class QItemSelectionModel;
+class KAddressBookContactSelectionWidget;
+namespace Akonadi
+{
+class Collection;
+}
+
+/**
+ * @short A dialog to select a group of contacts.
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ */
+namespace KAddressBookImportExport
+{
+class KAddressBookContactSelectionWidget;
+class KADDRESSBOOK_IMPORTEXPORT_EXPORT KAddressBookContactSelectionDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ /**
+ * Creates a new contact selection dialog.
+ *
+ * @param selectionModel The model that contains the currently selected contacts.
+ * @param parent The parent widget.
+ */
+ explicit KAddressBookContactSelectionDialog(QItemSelectionModel *selectionModel, bool allowToSelectTypeToExport, QWidget *parent = Q_NULLPTR);
+
+ /**
+ * Sets the @p message text.
+ */
+ void setMessageText(const QString &message);
+
+ /**
+ * Sets the default addressbook.
+ */
+ void setDefaultAddressBook(const Akonadi::Collection &addressBook);
+
+ /**
+ * Returns the list of selected contacts.
+ */
+ KAddressBookImportExport::KAddressBookImportExportContactList selectedContacts() const;
+
+ //VCardExportSelectionWidget::ExportFields exportType() const;
+ void setAddGroupContact(bool addGroupContact);
+
+ Akonadi::Item::List selectedItems() const;
+private:
+ KAddressBookContactSelectionWidget *mSelectionWidget;
+ //VCardExportSelectionWidget *mVCardExport;
+};
+}
+#endif
diff --git a/kaddressbookimportexport/src/kaddressbookcontactselectionwidget.cpp b/kaddressbookimportexport/src/kaddressbookcontactselectionwidget.cpp
new file mode 100644
index 0000000..a91a770
--- /dev/null
+++ b/kaddressbookimportexport/src/kaddressbookcontactselectionwidget.cpp
@@ -0,0 +1,332 @@
+/*
+ Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+ Copyright (c) 2016 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This library 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 Library General Public
+ License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#include "kaddressbookcontactselectionwidget.h"
+
+#include <AkonadiWidgets/CollectionComboBox>
+#include <AkonadiCore/EntityTreeModel>
+#include <AkonadiCore/ItemFetchJob>
+#include <AkonadiCore/ItemFetchScope>
+#include <AkonadiCore/RecursiveItemFetchJob>
+
+#include <KLocalizedString>
+
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QItemSelectionModel>
+#include <QLabel>
+#include <QRadioButton>
+#include <QVBoxLayout>
+
+using namespace KAddressBookImportExport;
+KAddressBookContactSelectionWidget::KAddressBookContactSelectionWidget(QItemSelectionModel *selectionModel,
+ QWidget *parent)
+ : QWidget(parent), mSelectionModel(selectionModel), mAddContactGroup(false)
+{
+ initGui();
+
+ mSelectedContactsButton->setEnabled(mSelectionModel->hasSelection());
+ mAddressBookSelection->setEnabled(false);
+ mAddressBookSelectionRecursive->setEnabled(false);
+
+ connect(mAddressBookContactsButton, &QRadioButton::toggled, mAddressBookSelection, &Akonadi::CollectionComboBox::setEnabled);
+ connect(mAddressBookContactsButton, &QRadioButton::toggled, mAddressBookSelectionRecursive, &QCheckBox::setEnabled);
+
+ // apply default configuration
+ if (mSelectionModel->hasSelection()) {
+ mSelectedContactsButton->setChecked(true);
+ } else {
+ mAllContactsButton->setChecked(true);
+ }
+}
+
+void KAddressBookContactSelectionWidget::setMessageText(const QString &message)
+{
+ if (!message.isEmpty()) {
+ mMessageLabel->setText(message);
+ mMessageLabel->show();
+ }
+}
+
+void KAddressBookContactSelectionWidget::setDefaultAddressBook(const Akonadi::Collection &addressBook)
+{
+ mAddressBookSelection->setDefaultCollection(addressBook);
+}
+
+Akonadi::Item::List KAddressBookContactSelectionWidget::selectedItems() const
+{
+ if (mAllContactsButton->isChecked()) {
+ return collectAllItems();
+ } else if (mSelectedContactsButton->isChecked()) {
+ return collectSelectedItems();
+ } else if (mAddressBookContactsButton->isChecked()) {
+ return collectAddressBookItems();
+ }
+
+ return Akonadi::Item::List();
+}
+
+KAddressBookImportExport::KAddressBookImportExportContactList KAddressBookContactSelectionWidget::selectedContacts() const
+{
+ if (mAllContactsButton->isChecked()) {
+ return collectAllContacts();
+ } else if (mSelectedContactsButton->isChecked()) {
+ return collectSelectedContacts();
+ } else if (mAddressBookContactsButton->isChecked()) {
+ return collectAddressBookContacts();
+ }
+
+ return KAddressBookImportExport::KAddressBookImportExportContactList();
+}
+
+void KAddressBookContactSelectionWidget::setAddGroupContact(bool addGroupContact)
+{
+ mAddContactGroup = addGroupContact;
+}
+
+void KAddressBookContactSelectionWidget::initGui()
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setMargin(0);
+
+ mMessageLabel = new QLabel;
+ layout->addWidget(mMessageLabel);
+ mMessageLabel->hide();
+
+ QButtonGroup *group = new QButtonGroup(this);
+
+ QGroupBox *groupBox = new QGroupBox;
+
+ QGridLayout *boxLayout = new QGridLayout;
+ groupBox->setLayout(boxLayout);
+
+ mAllContactsButton = new QRadioButton(i18nc("@option:radio", "All contacts"));
+ mAllContactsButton->setToolTip(
+ i18nc("@info:tooltip", "All contacts from all your address books"));
+ mAllContactsButton->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Choose this option you want to select all your contacts from "
+ "all your address books."));
+
+ mSelectedContactsButton = new QRadioButton(i18nc("@option:radio", "Selected contacts"));
+ mSelectedContactsButton->setToolTip(
+ i18nc("@info:tooltip", "Only the contacts currently selected"));
+ mSelectedContactsButton->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Choose this option if you want only the contacts you have already "
+ "selected in the graphical interface."));
+
+ mAddressBookContactsButton = new QRadioButton(i18nc("@option:radio", "All contacts from:"));
+ mAddressBookContactsButton->setToolTip(
+ i18nc("@info:tooltip", "All contacts from a chosen address book"));
+ mAddressBookContactsButton->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Choose this option if you want to select all the contacts from only one "
+ "of your address books. Once this option is clicked you will be provided "
+ "a drop down box listing all those address books and permitted to select "
+ "the one you want."));
+
+ mAddressBookSelection = new Akonadi::CollectionComboBox;
+ mAddressBookSelection->setMimeTypeFilter(QStringList() << KContacts::Addressee::mimeType());
+ mAddressBookSelection->setAccessRightsFilter(Akonadi::Collection::ReadOnly);
+ mAddressBookSelection->setExcludeVirtualCollections(true);
+ mAddressBookSelectionRecursive = new QCheckBox(i18nc("@option:check", "Include Subfolders"));
+ mAddressBookSelectionRecursive->setToolTip(
+ i18nc("@info:tooltip", "Select all subfolders including the top-level folder"));
+ mAddressBookSelectionRecursive->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Check this box if you want to select all contacts from this folder, "
+ "including all subfolders. If you only want the contacts from the "
+ "top-level folder then leave this box unchecked."));
+
+ group->addButton(mAllContactsButton);
+ group->addButton(mSelectedContactsButton);
+ group->addButton(mAddressBookContactsButton);
+
+ boxLayout->addWidget(mAllContactsButton, 0, 0, 1, 2);
+ boxLayout->addWidget(mSelectedContactsButton, 1, 0, 1, 2);
+ boxLayout->addWidget(mAddressBookContactsButton, 2, 0, Qt::AlignTop);
+
+ QVBoxLayout *addressBookLayout = new QVBoxLayout;
+ addressBookLayout->setMargin(0);
+ addressBookLayout->addWidget(mAddressBookSelection);
+ addressBookLayout->addWidget(mAddressBookSelectionRecursive);
+
+ boxLayout->addLayout(addressBookLayout, 2, 1);
+
+ layout->addWidget(groupBox);
+ layout->addStretch(1);
+}
+
+Akonadi::Item::List KAddressBookContactSelectionWidget::collectAllItems() const
+{
+ Akonadi::RecursiveItemFetchJob *job =
+ new Akonadi::RecursiveItemFetchJob(Akonadi::Collection::root(),
+ QStringList() << KContacts::Addressee::mimeType());
+ job->fetchScope().fetchFullPayload();
+
+ if (!job->exec()) {
+ return Akonadi::Item::List();
+ }
+
+ return job->items();
+}
+
+KAddressBookImportExport::KAddressBookImportExportContactList KAddressBookContactSelectionWidget::collectAllContacts() const
+{
+ KAddressBookImportExport::KAddressBookImportExportContactList contacts;
+ Akonadi::RecursiveItemFetchJob *job =
+ new Akonadi::RecursiveItemFetchJob(Akonadi::Collection::root(),
+ QStringList() << KContacts::Addressee::mimeType());
+ job->fetchScope().fetchFullPayload();
+
+ if (!job->exec()) {
+ return contacts;
+ }
+
+ foreach (const Akonadi::Item &item, job->items()) {
+ if (item.isValid()) {
+ if (item.hasPayload<KContacts::Addressee>()) {
+ contacts.append(item.payload<KContacts::Addressee>());
+ }
+ }
+ }
+
+ return contacts;
+}
+
+Akonadi::Item::List KAddressBookContactSelectionWidget::collectSelectedItems() const
+{
+ Akonadi::Item::List items;
+
+ const QModelIndexList indexes = mSelectionModel->selectedRows(0);
+ for (int i = 0; i < indexes.count(); ++i) {
+ const QModelIndex index = indexes.at(i);
+ if (index.isValid()) {
+ const Akonadi::Item item =
+ index.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
+ if (item.isValid()) {
+ items.append(item);
+ }
+ }
+ }
+
+ return items;
+}
+
+KAddressBookImportExport::KAddressBookImportExportContactList KAddressBookContactSelectionWidget::collectSelectedContacts() const
+{
+ KAddressBookImportExport::KAddressBookImportExportContactList contacts;
+
+ const QModelIndexList indexes = mSelectionModel->selectedRows(0);
+ for (int i = 0; i < indexes.count(); ++i) {
+ const QModelIndex index = indexes.at(i);
+ if (index.isValid()) {
+ const Akonadi::Item item =
+ index.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
+ if (item.isValid()) {
+ if (item.hasPayload<KContacts::Addressee>()) {
+ contacts.append(item.payload<KContacts::Addressee>());
+ }
+ }
+ }
+ }
+
+ return contacts;
+}
+
+Akonadi::Item::List KAddressBookContactSelectionWidget::collectAddressBookItems() const
+{
+ Akonadi::Item::List items;
+
+ const Akonadi::Collection collection = mAddressBookSelection->currentCollection();
+ if (!collection.isValid()) {
+ return items;
+ }
+
+ if (mAddressBookSelectionRecursive->isChecked()) {
+ Akonadi::RecursiveItemFetchJob *job =
+ new Akonadi::RecursiveItemFetchJob(collection,
+ QStringList() << KContacts::Addressee::mimeType());
+ job->fetchScope().fetchFullPayload();
+
+ if (!job->exec()) {
+ return items;
+ }
+
+ items = job->items();
+ } else {
+ Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(collection);
+ job->fetchScope().fetchFullPayload();
+
+ if (!job->exec()) {
+ return items;
+ }
+ items = job->items();
+ }
+
+ return items;
+
+}
+
+KAddressBookImportExport::KAddressBookImportExportContactList KAddressBookContactSelectionWidget::collectAddressBookContacts() const
+{
+ KAddressBookImportExport::KAddressBookImportExportContactList contacts;
+
+ const Akonadi::Collection collection = mAddressBookSelection->currentCollection();
+ if (!collection.isValid()) {
+ return contacts;
+ }
+
+ if (mAddressBookSelectionRecursive->isChecked()) {
+ Akonadi::RecursiveItemFetchJob *job =
+ new Akonadi::RecursiveItemFetchJob(collection,
+ QStringList() << KContacts::Addressee::mimeType());
+ job->fetchScope().fetchFullPayload();
+
+ if (!job->exec()) {
+ return contacts;
+ }
+
+ foreach (const Akonadi::Item &item, job->items()) {
+ if (item.hasPayload<KContacts::Addressee>()) {
+ contacts.append(item.payload<KContacts::Addressee>());
+ }
+ }
+ } else {
+ Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(collection);
+ job->fetchScope().fetchFullPayload();
+
+ if (!job->exec()) {
+ return contacts;
+ }
+
+ foreach (const Akonadi::Item &item, job->items()) {
+ if (item.hasPayload<KContacts::Addressee>()) {
+ contacts.append(item.payload<KContacts::Addressee>());
+ }
+ }
+ }
+
+ return contacts;
+}
+
diff --git a/kaddressbookimportexport/src/kaddressbookcontactselectionwidget.h b/kaddressbookimportexport/src/kaddressbookcontactselectionwidget.h
new file mode 100644
index 0000000..c0f28c6
--- /dev/null
+++ b/kaddressbookimportexport/src/kaddressbookcontactselectionwidget.h
@@ -0,0 +1,100 @@
+/*
+ Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+ Copyright (c) 2016 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This library 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 Library General Public
+ License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#ifndef KAddressBookCONTACTSELECTIONWIDGET_H
+#define KAddressBookCONTACTSELECTIONWIDGET_H
+
+#include <KContacts/Addressee>
+#include <AkonadiCore/Item>
+#include "KAddressBookImportExport/KAddressBookImportExportContactList"
+
+#include <QWidget>
+
+class QCheckBox;
+class QItemSelectionModel;
+class QLabel;
+class QRadioButton;
+
+namespace Akonadi
+{
+class Collection;
+class CollectionComboBox;
+}
+
+/**
+ * @short A widget to select a group of contacts.
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ */
+namespace KAddressBookImportExport
+{
+class KAddressBookContactSelectionWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ /**
+ * Creates a new contact selection widget.
+ *
+ * @param selectionModel The model that contains the currently selected contacts.
+ * @param parent The parent widget.
+ */
+ explicit KAddressBookContactSelectionWidget(QItemSelectionModel *selectionModel, QWidget *parent = Q_NULLPTR);
+
+ /**
+ * Sets the @p message text.
+ */
+ void setMessageText(const QString &message);
+
+ /**
+ * Sets the default addressbook.
+ */
+ void setDefaultAddressBook(const Akonadi::Collection &addressBook);
+
+ /**
+ * Returns the list of selected contacts.
+ */
+ KAddressBookImportExport::KAddressBookImportExportContactList selectedContacts() const;
+
+ void setAddGroupContact(bool addGroupContact);
+ Akonadi::Item::List selectedItems() const;
+private:
+ void initGui();
+
+ KAddressBookImportExport::KAddressBookImportExportContactList collectAllContacts() const;
+ KAddressBookImportExport::KAddressBookImportExportContactList collectSelectedContacts() const;
+ KAddressBookImportExport::KAddressBookImportExportContactList collectAddressBookContacts() const;
+
+ Akonadi::Item::List collectAllItems() const;
+ Akonadi::Item::List collectSelectedItems() const;
+ Akonadi::Item::List collectAddressBookItems() const;
+
+ QItemSelectionModel *mSelectionModel;
+
+ QLabel *mMessageLabel;
+ QRadioButton *mAllContactsButton;
+ QRadioButton *mSelectedContactsButton;
+ QRadioButton *mAddressBookContactsButton;
+ Akonadi::CollectionComboBox *mAddressBookSelection;
+ QCheckBox *mAddressBookSelectionRecursive;
+ bool mAddContactGroup;
+};
+}
+#endif