File indexing completed on 2024-04-28 16:54:34
0001 /* 0002 SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QAbstractListModel> 0010 #include <QScopedPointer> 0011 #include <QSharedPointer> 0012 0013 #include "notificationmanager_export.h" 0014 #include "notifications.h" 0015 0016 namespace NotificationManager 0017 { 0018 class JobsModelPrivate; 0019 0020 /** 0021 * A model used for listing Job. 0022 */ 0023 class NOTIFICATIONMANAGER_EXPORT JobsModel : public QAbstractListModel 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 ~JobsModel() override; 0029 0030 using Ptr = QSharedPointer<JobsModel>; 0031 static Ptr createJobsModel(); 0032 0033 /** 0034 * Registers the JobView service on DBus. 0035 * 0036 * @return true if succeeded, false otherwise. 0037 */ 0038 bool init(); 0039 0040 /** 0041 * Whether the notification service could be registered 0042 */ 0043 bool isValid() const; 0044 0045 QVariant data(const QModelIndex &index, int role) const override; 0046 bool setData(const QModelIndex &index, const QVariant &value, int role) override; 0047 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0048 QHash<int, QByteArray> roleNames() const override; 0049 0050 /** 0051 * @brief Close a job 0052 * 0053 * This removes the job from the model. This will not cancel the job! 0054 * Use @c kill if you want to cancel a job. 0055 */ 0056 void close(const QModelIndex &idx); 0057 void expire(const QModelIndex &idx); 0058 0059 /** 0060 * @brief Suspend a job 0061 */ 0062 void suspend(const QModelIndex &idx); 0063 /** 0064 * @brief Resume a job 0065 */ 0066 void resume(const QModelIndex &idx); 0067 /** 0068 * @brief Kill a job 0069 * 0070 * This cancels the job. 0071 */ 0072 void kill(const QModelIndex &idx); 0073 0074 void clear(Notifications::ClearFlags flags); 0075 0076 Q_SIGNALS: 0077 void serviceOwnershipLost(); 0078 0079 private: 0080 JobsModel(); 0081 Q_DISABLE_COPY(JobsModel) 0082 0083 JobsModelPrivate *d; 0084 }; 0085 0086 } // namespace NotificationManager