Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
NotificationModel.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServiceNotifications/phosphorservicenotifications_export.h>
7
10
11#include <QAbstractListModel>
12#include <QList>
13
15
22class PHOSPHORSERVICENOTIFICATIONS_EXPORT NotificationModel : public QAbstractListModel
23{
24 Q_OBJECT
25 Q_DISABLE_COPY_MOVE(NotificationModel)
26 Q_PROPERTY(
28 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
29
30public:
51 Q_ENUM(Roles)
52
53 explicit NotificationModel(QObject* parent = nullptr);
54 ~NotificationModel() override;
55
56 [[nodiscard]] NotificationServer* server() const;
58
59 [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override;
60 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
61 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
62
63Q_SIGNALS:
66
67private:
68 void connectNotification(Notification* notification);
69 void onNotificationAdded(Notification* notification);
70 void onNotificationClosed(uint id);
71 void onNotificationChanged(Notification* notification);
72
73 NotificationServer* m_server = nullptr;
74 // Row mirror of server-owned Notification pointers; the model does NOT own
75 // them. The server keeps each alive until its NotificationClosed fires, at
76 // which point the row is removed before the object is deleted.
77 QList<Notification*> m_rows;
78};
79
80} // namespace PhosphorServiceNotifications
Roles
Definition NotificationModel.h:31
@ TransientRole
Definition NotificationModel.h:45
@ ResidentRole
Definition NotificationModel.h:44
@ TimestampRole
Definition NotificationModel.h:49
@ IdRole
Definition NotificationModel.h:33
@ ImageRole
Definition NotificationModel.h:42
@ DesktopEntryRole
Definition NotificationModel.h:41
@ NotificationRole
Definition NotificationModel.h:32
@ BodyRole
Definition NotificationModel.h:37
@ ActionsRole
Definition NotificationModel.h:38
@ ValueRole
Definition NotificationModel.h:47
@ ExpireTimeoutRole
Definition NotificationModel.h:48
@ HasImageRole
Definition NotificationModel.h:43
@ SummaryRole
Definition NotificationModel.h:36
@ SuppressSoundRole
Definition NotificationModel.h:46
@ AppIconRole
Definition NotificationModel.h:35
@ CategoryRole
Definition NotificationModel.h:40
@ UrgencyRole
Definition NotificationModel.h:39
@ AppNameRole
Definition NotificationModel.h:34
QHash< int, QByteArray > roleNames() const override
int rowCount(const QModelIndex &parent={}) const override
QVariant data(const QModelIndex &index, int role) const override
void setServer(NotificationServer *server)
The session-bus server for org.freedesktop.Notifications (Desktop Notifications Spec 1....
Definition NotificationServer.h:42
One live notification, decoded from an org.freedesktop.Notifications Notify call.
Definition Notification.h:36
Definition Notification.h:15