File indexing completed on 2024-11-24 04:39:27
0001 /* 0002 This file is part of Akonadi Contact. 0003 0004 SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "akonadi-contact-core_export.h" 0012 #include <QAbstractItemModel> 0013 #include <QSortFilterProxyModel> 0014 0015 #include <KContacts/ContactGroup> 0016 0017 #include <memory> 0018 0019 namespace Akonadi 0020 { 0021 class ContactGroupModelPrivate; 0022 0023 class AKONADI_CONTACT_CORE_EXPORT ContactGroupModel : public QAbstractItemModel 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 enum Role { IsReferenceRole = Qt::UserRole, AllEmailsRole }; 0029 0030 explicit ContactGroupModel(QObject *parent = nullptr); 0031 ~ContactGroupModel() override; 0032 0033 void loadContactGroup(const KContacts::ContactGroup &contactGroup); 0034 bool storeContactGroup(KContacts::ContactGroup &contactGroup) const; 0035 0036 QString lastErrorMessage() const; 0037 0038 QModelIndex index(int row, int col, const QModelIndex &parent = QModelIndex()) const override; 0039 QModelIndex parent(const QModelIndex &child) const override; 0040 QVariant data(const QModelIndex &index, int role) const override; 0041 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0042 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0043 Qt::ItemFlags flags(const QModelIndex &index) const override; 0044 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0045 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0046 0047 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; 0048 0049 private: 0050 friend class ContactGroupModelPrivate; 0051 std::unique_ptr<ContactGroupModelPrivate> const d; 0052 }; 0053 0054 class AKONADI_CONTACT_CORE_EXPORT GroupFilterModel : public QSortFilterProxyModel 0055 { 0056 public: 0057 explicit GroupFilterModel(QObject *parent = nullptr); 0058 0059 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 0060 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 0061 }; 0062 0063 }