1 /*
2     SPDX-FileCopyrightText: 2018-2019 Kai Uwe Broulik <kde@privat.broulik.de>
3 
4     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #pragma once
8 
9 #include "notification.h"
10 #include "server.h"
11 
12 #include <QDateTime>
13 #include <QTimer>
14 
15 class QTimer;
16 
17 namespace NotificationManager
18 {
19 class Q_DECL_HIDDEN AbstractNotificationsModel::Private
20 {
21 public:
22     explicit Private(AbstractNotificationsModel *q);
23     ~Private();
24 
25     void onNotificationAdded(const Notification &notification);
26     void onNotificationReplaced(uint replacedId, const Notification &notification);
27     void onNotificationRemoved(uint notificationId, Server::CloseReason reason);
28 
29     void setupNotificationTimeout(const Notification &notification);
30 
31     void removeRows(const QVector<int> &rows);
32 
33     AbstractNotificationsModel *q;
34 
35     QVector<Notification> notifications;
36     // Fallback timeout to ensure all notifications expire eventually
37     // otherwise when it isn't shown to the user and doesn't expire
38     // an app might wait indefinitely for the notification to do so
39     QHash<uint /*notificationId*/, QTimer *> notificationTimeouts;
40 
41     QVector<uint /*notificationId*/> pendingRemovals;
42     QTimer pendingRemovalTimer;
43 
44     QDateTime lastRead;
45 };
46 
47 }
48