Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/jobsmodel_p.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2019 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | * later version accepted by the membership of KDE e.V. (or its | ||||
9 | * successor approved by the membership of KDE e.V.), which shall | ||||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | * | ||||
12 | * This library is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | * Lesser General Public License for more details. | ||||
16 | * | ||||
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/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #pragma once | ||||
22 | | ||||
23 | #include <QObject> | ||||
24 | #include <QDBusContext> | ||||
25 | #include <QDBusObjectPath> | ||||
26 | #include <QSet> | ||||
27 | #include <QVector> | ||||
28 | | ||||
29 | #include "notifications.h" | ||||
30 | | ||||
31 | class QDBusServiceWatcher; | ||||
32 | class QTimer; | ||||
33 | | ||||
34 | namespace NotificationManager | ||||
35 | { | ||||
36 | | ||||
37 | class Job; | ||||
38 | | ||||
39 | class Q_DECL_HIDDEN JobsModelPrivate : public QObject, protected QDBusContext | ||||
40 | { | ||||
41 | Q_OBJECT | ||||
42 | | ||||
43 | public: | ||||
44 | JobsModelPrivate(QObject *parent); | ||||
45 | ~JobsModelPrivate() override; | ||||
46 | | ||||
47 | // DBus | ||||
48 | // kuiserver | ||||
49 | void registerService(const QString &service, const QString &objectPath); | ||||
50 | void emitJobUrlsChanged(); | ||||
51 | bool requiresJobTracker() const; | ||||
52 | QStringList registeredJobContacts() const; | ||||
53 | // V1 | ||||
54 | QDBusObjectPath requestView(const QString &appName, const QString &appIconName, int capabilities); | ||||
55 | // V2 | ||||
56 | QDBusObjectPath requestView(const QString &desktopEntry, | ||||
57 | const QString &appName, | ||||
58 | const QString &appIconName, | ||||
59 | int capabilities, | ||||
60 | const QVariantMap &hints); | ||||
61 | | ||||
62 | Q_SIGNALS: | ||||
63 | void jobViewAboutToBeAdded(int row, Job *job); | ||||
64 | void jobViewAdded(int row, Job *job); | ||||
65 | | ||||
66 | void jobViewAboutToBeRemoved(int row);//, Job *job); | ||||
67 | void jobViewRemoved(int row); | ||||
68 | | ||||
69 | void jobViewChanged(int row, Job *job, const QVector<int> &roles); | ||||
70 | | ||||
71 | // DBus | ||||
72 | // kuiserver | ||||
73 | void jobUrlsChanged(const QStringList &urls); | ||||
74 | | ||||
75 | public: // stuff used by public class | ||||
76 | bool init(); | ||||
77 | | ||||
78 | void remove(Job *job); | ||||
79 | void removeAt(int row); | ||||
80 | | ||||
81 | bool m_valid = false; | ||||
82 | QVector<Job *> m_jobViews; | ||||
83 | | ||||
84 | private: | ||||
85 | void onServiceUnregistered(const QString &serviceName); | ||||
86 | | ||||
87 | void updateApplicationPercentage(const QString &desktopEntry); | ||||
88 | | ||||
89 | QStringList jobUrls() const; | ||||
90 | void scheduleUpdate(Job *job, Notifications::Roles role); | ||||
91 | | ||||
92 | QDBusServiceWatcher *m_serviceWatcher = nullptr; | ||||
93 | // Job -> serviceName | ||||
94 | QHash<Job *, QString> m_jobServices; | ||||
95 | int m_highestJobId = 1; | ||||
96 | | ||||
97 | QTimer *m_compressUpdatesTimer = nullptr; | ||||
98 | QHash<Job *, QVector<int>> m_pendingDirtyRoles; | ||||
99 | | ||||
100 | QTimer *m_pendingJobViewsTimer = nullptr; | ||||
101 | QVector<Job *> m_pendingJobViews; | ||||
102 | | ||||
103 | }; | ||||
104 | | ||||
105 | } // namespace NotificationManager |