Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/abstractnotificationsmodel.h
- This file was copied from libnotificationmanager/notificationsmodel.h.
Show All 12 Lines | |||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | 15 | * Lesser General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | 17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #pragma once | 21 | #ifndef ABSTRACTNOTIFICATIONSMODEL_H | ||
22 | #define ABSTRACTNOTIFICATIONSMODEL_H | ||||
22 | 23 | | |||
23 | #include <QAbstractListModel> | 24 | #include <QAbstractListModel> | ||
24 | #include <QScopedPointer> | 25 | #include <QScopedPointer> | ||
25 | #include <QSharedPointer> | 26 | #include <QSharedPointer> | ||
27 | #include <QDateTime> | ||||
26 | 28 | | |||
27 | #include "notifications.h" | 29 | #include "notifications.h" | ||
30 | #include "notification.h" | ||||
31 | #include "server.h" | ||||
28 | 32 | | |||
29 | namespace NotificationManager | 33 | namespace NotificationManager | ||
30 | { | 34 | { | ||
31 | 35 | | |||
32 | class NotificationsModel : public QAbstractListModel | 36 | class Q_DECL_EXPORT AbstractNotificationsModel : public QAbstractListModel | ||
33 | { | 37 | { | ||
34 | Q_OBJECT | 38 | Q_OBJECT | ||
35 | 39 | | |||
36 | public: | 40 | public: | ||
37 | ~NotificationsModel() override; | 41 | ~AbstractNotificationsModel() override; | ||
broulik: `protected` constructor? | |||||
38 | | ||||
39 | using Ptr = QSharedPointer<NotificationsModel>; | | |||
40 | static Ptr createNotificationsModel(); | | |||
41 | 42 | | |||
42 | QDateTime lastRead() const; | 43 | QDateTime lastRead() const; | ||
43 | void setLastRead(const QDateTime &lastRead); | 44 | void setLastRead(const QDateTime &lastRead); | ||
44 | 45 | | |||
45 | QVariant data(const QModelIndex &index, int role) const override; | 46 | QVariant data(const QModelIndex &index, int role) const override; | ||
46 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; | 47 | bool setData(const QModelIndex &index, const QVariant &value, int role) override; | ||
47 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | 48 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
48 | QHash<int, QByteArray> roleNames() const override; | 49 | QHash<int, QByteArray> roleNames() const override; | ||
49 | 50 | | |||
50 | void expire(uint notificationId); | 51 | virtual void expire(uint notificationId) = 0; | ||
51 | void close(uint notificationId); | 52 | virtual void close(uint notificationId) = 0; | ||
52 | void configure(uint notificationId); | 53 | | ||
53 | void configure(const QString &desktopEntry, const QString ¬ifyRcName, const QString &eventId); | 54 | // Currently configure actions are not exposed in AbstractNotificationsModel to keep it very minimal | ||
54 | void invokeDefaultAction(uint notificationId); | 55 | // if usecase for this comes up in future, we can revisit it. | ||
55 | void invokeAction(uint notificationId, const QString &actionName); | 56 | | ||
56 | void reply(uint notificationId, const QString &text); | 57 | virtual void invokeDefaultAction(uint notificationId) = 0; | ||
58 | virtual void invokeAction(uint notificationId, const QString &actionName) = 0; | ||||
59 | virtual void reply(uint notificationId, const QString &text) = 0; | ||||
57 | 60 | | |||
58 | void startTimeout(uint notificationId); | 61 | void startTimeout(uint notificationId); | ||
59 | void stopTimeout(uint notificationId); | 62 | void stopTimeout(uint notificationId); | ||
60 | 63 | | |||
61 | void clear(Notifications::ClearFlags flags); | 64 | void clear(Notifications::ClearFlags flags); | ||
62 | 65 | | |||
63 | signals: | 66 | signals: | ||
64 | void lastReadChanged(); | 67 | void lastReadChanged(); | ||
65 | 68 | | |||
69 | protected: | ||||
70 | AbstractNotificationsModel(); | ||||
71 | void onNotificationAdded(const Notification ¬ification); | ||||
72 | void onNotificationReplaced(uint replacedId, const Notification ¬ification); | ||||
73 | void onNotificationRemoved(uint notificationId, Server::CloseReason reason); | ||||
74 | | ||||
75 | void setupNotificationTimeout(const Notification ¬ification); | ||||
76 | const QVector<Notification>& notifications(); | ||||
77 | int rowOfNotification(uint id) const; | ||||
78 | | ||||
79 | | ||||
66 | private: | 80 | private: | ||
67 | class Private; | 81 | class Private; | ||
68 | QScopedPointer<Private> d; | 82 | QScopedPointer<Private> d; | ||
69 | 83 | | |||
70 | NotificationsModel(); | 84 | Q_DISABLE_COPY(AbstractNotificationsModel) | ||
71 | Q_DISABLE_COPY(NotificationsModel) | | |||
72 | 85 | | |||
73 | }; | 86 | }; | ||
74 | 87 | | |||
75 | } // namespace NotificationManager | 88 | } // namespace NotificationManager | ||
89 | | ||||
90 | #endif //ABSTRACTNOTIFICATIONSMODEL_H |
protected constructor?