File indexing completed on 2024-12-22 04:55:32
0001 /* 0002 SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org> 0003 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "contactlist.h" 0011 #include "kaddressbook_importexport_export.h" 0012 #include <Akonadi/Item> 0013 0014 #include <QWidget> 0015 0016 class QCheckBox; 0017 class QItemSelectionModel; 0018 class QLabel; 0019 class QRadioButton; 0020 0021 namespace Akonadi 0022 { 0023 class Collection; 0024 class CollectionComboBox; 0025 } 0026 0027 namespace KAddressBookImportExport 0028 { 0029 /** 0030 * @short A widget to select a group of contacts. 0031 * 0032 * @author Tobias Koenig <tokoe@kde.org> 0033 */ 0034 class KADDRESSBOOK_IMPORTEXPORT_EXPORT ContactSelectionWidget : public QWidget 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 /** 0040 * Creates a new contact selection widget. 0041 * 0042 * @param selectionModel The model that contains the currently selected contacts. 0043 * @param parent The parent widget. 0044 */ 0045 explicit ContactSelectionWidget(QItemSelectionModel *selectionModel, QWidget *parent = nullptr); 0046 0047 /** 0048 * Sets the @p message text. 0049 */ 0050 void setMessageText(const QString &message); 0051 0052 /** 0053 * Sets the default addressbook. 0054 */ 0055 void setDefaultAddressBook(const Akonadi::Collection &addressBook); 0056 0057 /** 0058 * Returns the list of selected contacts. 0059 */ 0060 [[nodiscard]] ContactList selectedContacts() const; 0061 0062 void setAddGroupContact(bool addGroupContact); 0063 [[nodiscard]] Akonadi::Item::List selectedItems() const; 0064 0065 private: 0066 KADDRESSBOOK_IMPORTEXPORT_NO_EXPORT void initGui(); 0067 0068 [[nodiscard]] KADDRESSBOOK_IMPORTEXPORT_NO_EXPORT ContactList collectAllContacts() const; 0069 [[nodiscard]] KADDRESSBOOK_IMPORTEXPORT_NO_EXPORT ContactList collectSelectedContacts() const; 0070 [[nodiscard]] KADDRESSBOOK_IMPORTEXPORT_NO_EXPORT ContactList collectAddressBookContacts() const; 0071 0072 [[nodiscard]] KADDRESSBOOK_IMPORTEXPORT_NO_EXPORT Akonadi::Item::List collectAllItems() const; 0073 [[nodiscard]] KADDRESSBOOK_IMPORTEXPORT_NO_EXPORT Akonadi::Item::List collectSelectedItems() const; 0074 [[nodiscard]] KADDRESSBOOK_IMPORTEXPORT_NO_EXPORT Akonadi::Item::List collectAddressBookItems() const; 0075 0076 QItemSelectionModel *const mSelectionModel; 0077 0078 QLabel *mMessageLabel = nullptr; 0079 QRadioButton *mAllContactsButton = nullptr; 0080 QRadioButton *mSelectedContactsButton = nullptr; 0081 QRadioButton *mAddressBookContactsButton = nullptr; 0082 Akonadi::CollectionComboBox *mAddressBookSelection = nullptr; 0083 QCheckBox *mAddressBookSelectionRecursive = nullptr; 0084 bool mAddContactGroup = false; 0085 }; 0086 }