1 /*
2   SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
3   SPDX-FileCopyrightText: 2015-2021 Laurent Montel <montel@kde.org>
4 
5   SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #pragma once
9 
10 #include "contactlist.h"
11 #include "exportselectionwidget.h"
12 #include "kaddressbook_importexport_export.h"
13 
14 #include <Akonadi/Item>
15 #include <KContacts/Addressee>
16 #include <QDialog>
17 
18 class QItemSelectionModel;
19 namespace Akonadi
20 {
21 class Collection;
22 }
23 
24 namespace KAddressBookImportExport
25 {
26 class ContactSelectionWidget;
27 
28 /**
29  * @short A dialog to select a group of contacts.
30  *
31  * @author Tobias Koenig <tokoe@kde.org>
32  */
33 class KADDRESSBOOK_IMPORTEXPORT_EXPORT ContactSelectionDialog : public QDialog
34 {
35     Q_OBJECT
36 
37 public:
38     /**
39      * Creates a new contact selection dialog.
40      *
41      * @param selectionModel The model that contains the currently selected contacts.
42      * @param parent The parent widget.
43      */
44     explicit ContactSelectionDialog(QItemSelectionModel *selectionModel, bool allowToSelectTypeToExport, QWidget *parent = nullptr);
45 
46     /**
47      * Sets the @p message text.
48      */
49     void setMessageText(const QString &message);
50 
51     /**
52      * Sets the default addressbook.
53      */
54     void setDefaultAddressBook(const Akonadi::Collection &addressBook);
55 
56     /**
57      * Returns the list of selected contacts.
58      */
59     Q_REQUIRED_RESULT ContactList selectedContacts() const;
60 
61     Q_REQUIRED_RESULT ExportSelectionWidget::ExportFields exportType() const;
62     void setAddGroupContact(bool addGroupContact);
63 
64     Q_REQUIRED_RESULT Akonadi::Item::List selectedItems() const;
65 
66 private:
67     ContactSelectionWidget *mSelectionWidget = nullptr;
68     ExportSelectionWidget *mVCardExport = nullptr;
69 };
70 }
71