File indexing completed on 2024-05-12 05:12:47
0001 /* 0002 SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractItemModel> 0010 0011 #include <Akonadi/ChangeNotification> 0012 #include <Akonadi/Monitor> 0013 0014 namespace Akonadi 0015 { 0016 namespace Protocol 0017 { 0018 class ChangeNotification; 0019 } 0020 } 0021 0022 class NotificationModel : public QAbstractItemModel 0023 { 0024 Q_OBJECT 0025 public: 0026 enum Role { NotificationRole = Qt::UserRole }; 0027 enum Columns { 0028 DateColumn, 0029 TypeColumn, 0030 OperationColumn, 0031 IdsColumn, 0032 SessionColumn, 0033 ListenersColumn, 0034 0035 _ColumnCount 0036 }; 0037 0038 explicit NotificationModel(QObject *parent); 0039 ~NotificationModel() override; 0040 0041 int columnCount(const QModelIndex &parent = QModelIndex()) const override; 0042 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0043 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 0044 QModelIndex parent(const QModelIndex &child) const override; 0045 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0046 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 0047 0048 Akonadi::Protocol::ChangeNotificationPtr notification(const QModelIndex &index) const; 0049 0050 [[nodiscard]] bool isEnabled() const 0051 { 0052 return m_monitor; 0053 } 0054 0055 public Q_SLOTS: 0056 void clear(); 0057 void setEnabled(bool enable); 0058 0059 private Q_SLOTS: 0060 void slotNotify(const Akonadi::ChangeNotification &msg); 0061 0062 private: 0063 QList<Akonadi::ChangeNotification> m_data; 0064 0065 Akonadi::Monitor *m_monitor = nullptr; 0066 };