File indexing completed on 2024-11-24 04:50:42
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.1-or-later 0003 0004 #pragma once 0005 0006 #include <QObject> 0007 0008 class KJob; 0009 class QAbstractListModel; 0010 class ContactGroupModel; 0011 0012 #include <Akonadi/Item> 0013 #include <Akonadi/ItemMonitor> 0014 #include <KContacts/ContactGroup> 0015 0016 class ContactGroupWrapper : public QObject, public Akonadi::ItemMonitor 0017 { 0018 Q_OBJECT 0019 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 0020 Q_PROPERTY(Akonadi::Item item READ item WRITE setItem NOTIFY akonadiItemChanged) 0021 Q_PROPERTY(QAbstractListModel *model READ model CONSTANT) 0022 0023 public: 0024 ContactGroupWrapper(QObject *parent = nullptr); 0025 QString name() const; 0026 void setName(const QString &name); 0027 Akonadi::Item item() const; 0028 void setItem(const Akonadi::Item &item); 0029 QAbstractListModel *model() const; 0030 0031 protected: 0032 virtual void itemChanged(const Akonadi::Item &item) override; 0033 0034 Q_SIGNALS: 0035 void nameChanged(); 0036 void akonadiItemChanged(); 0037 0038 private: 0039 void itemFetchDone(KJob *job); 0040 void loadContactGroup(const KContacts::ContactGroup &contactGroup); 0041 0042 QString m_name; 0043 ContactGroupModel *m_model; 0044 Akonadi::Item m_item; 0045 };