Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/job_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 <QDBusVariant> | ||||
27 | #include <QDateTime> | ||||
28 | #include <QSharedPointer> | ||||
29 | #include <QString> | ||||
30 | #include <QUrl> | ||||
31 | | ||||
32 | #include "notifications.h" | ||||
33 | #include "job.h" | ||||
34 | | ||||
35 | class KFilePlacesModel; | ||||
36 | | ||||
37 | namespace NotificationManager | ||||
38 | { | ||||
39 | | ||||
40 | class JobDetails; | ||||
41 | | ||||
42 | class JobPrivate : public QObject, protected QDBusContext | ||||
43 | { | ||||
44 | Q_OBJECT | ||||
45 | | ||||
46 | public: | ||||
47 | JobPrivate(uint id, QObject *parent); | ||||
48 | ~JobPrivate() override; | ||||
49 | | ||||
50 | QDBusObjectPath objectPath() const; | ||||
51 | QUrl descriptionUrl() const; | ||||
52 | QString text() const; | ||||
53 | | ||||
54 | // DBus | ||||
55 | // JobViewV1 | ||||
56 | void terminate(const QString &errorMessage); | ||||
57 | void setSuspended(bool suspended); | ||||
58 | void setTotalAmount(quint64 amount, const QString &unit); | ||||
59 | void setProcessedAmount(quint64 amount, const QString &unit); | ||||
60 | void setPercent(uint percent); | ||||
61 | void setSpeed(quint64 bytesPerSecond); | ||||
62 | void setInfoMessage(const QString &infoMessage); | ||||
63 | bool setDescriptionField(uint number, const QString &name, const QString &value); | ||||
64 | void clearDescriptionField(uint number); | ||||
65 | void setDestUrl(const QDBusVariant &urlVariant); | ||||
66 | void setError(uint errorCode); | ||||
67 | | ||||
68 | // JobViewV2 | ||||
69 | void terminate(uint errorCode, const QString &errorMessage, const QVariantMap &hints); | ||||
70 | void update(const QVariantMap &properties); | ||||
71 | | ||||
72 | signals: | ||||
73 | void closed(); | ||||
74 | | ||||
75 | // DBus | ||||
76 | // V1 and V2 | ||||
77 | void suspendRequested(); | ||||
78 | void resumeRequested(); | ||||
79 | void cancelRequested(); | ||||
80 | // V2 | ||||
81 | void updateRequested(); | ||||
82 | | ||||
83 | private: | ||||
84 | friend class Job; | ||||
85 | | ||||
86 | template<typename T> bool updateField(const T &newValue, | ||||
87 | T &target, | ||||
88 | void (Job::*changeSignal)()) | ||||
89 | { | ||||
90 | if (target != newValue) { | ||||
91 | target = newValue; | ||||
92 | emit ((static_cast<Job *>(parent()))->*changeSignal)(); | ||||
93 | return true; | ||||
94 | } | ||||
95 | return false; | ||||
96 | } | ||||
97 | | ||||
98 | static QSharedPointer<KFilePlacesModel> createPlacesModel(); | ||||
99 | | ||||
100 | QString prettyDestUrl() const; | ||||
101 | void updateHasDetails(); | ||||
102 | | ||||
103 | void finish(); | ||||
104 | | ||||
105 | uint m_id = 0; | ||||
106 | QDBusObjectPath m_objectPath; | ||||
107 | | ||||
108 | QDateTime m_created; | ||||
109 | QDateTime m_updated; | ||||
110 | | ||||
111 | QString m_summary; | ||||
112 | | ||||
113 | QString m_desktopEntry; | ||||
114 | QString m_applicationName; | ||||
115 | QString m_applicationIconName; | ||||
116 | | ||||
117 | Notifications::JobState m_state = Notifications::JobStateRunning; | ||||
118 | int m_percentage = 0; | ||||
119 | int m_error = 0; | ||||
120 | QString m_errorText; | ||||
121 | bool m_suspendable = false; | ||||
122 | bool m_killable = false; | ||||
123 | | ||||
124 | QUrl m_destUrl; | ||||
125 | | ||||
126 | qulonglong m_speed = 0; | ||||
127 | | ||||
128 | qulonglong m_processedBytes = 0; | ||||
129 | qulonglong m_processedFiles = 0; | ||||
130 | qulonglong m_processedDirectories = 0; | ||||
131 | | ||||
132 | qulonglong m_totalBytes = 0; | ||||
133 | qulonglong m_totalFiles = 0; | ||||
134 | qulonglong m_totalDirectories = 0; | ||||
135 | | ||||
136 | QString m_descriptionLabel1; | ||||
137 | QString m_descriptionValue1; | ||||
138 | | ||||
139 | QString m_descriptionLabel2; | ||||
140 | QString m_descriptionValue2; | ||||
141 | | ||||
142 | bool m_hasDetails = false; | ||||
143 | | ||||
144 | bool m_expired = false; | ||||
145 | bool m_dismissed = false; | ||||
146 | | ||||
147 | mutable QSharedPointer<KFilePlacesModel> m_placesModel; | ||||
148 | | ||||
149 | }; | ||||
150 | | ||||
151 | } // namespace NotificationManager |