Plasma-workspace

job.cpp
1/*
2 SPDX-FileCopyrightText: 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#include "job.h"
8#include "job_p.h"
9
10#include <QDebug>
11
12using namespace NotificationManager;
13
14Job::Job(uint id, QObject *parent)
15 : QObject(parent)
16 , d(new JobPrivate(id, this))
17{
18 d->m_created = QDateTime::currentDateTimeUtc();
19
20 // These properties are used in generating the pretty job text
21 connect(d, &JobPrivate::infoMessageChanged, this, &Job::textChanged);
22 connect(this, &Job::processedFilesChanged, this, &Job::textChanged);
23 connect(this, &Job::processedItemsChanged, this, &Job::textChanged);
24 connect(this, &Job::totalFilesChanged, this, &Job::textChanged);
25 connect(this, &Job::totalItemsChanged, this, &Job::textChanged);
26 connect(this, &Job::descriptionValue1Changed, this, &Job::textChanged);
27 connect(this, &Job::descriptionValue2Changed, this, &Job::textChanged);
28 connect(this, &Job::destUrlChanged, this, &Job::textChanged);
29 connect(this, &Job::errorTextChanged, this, &Job::textChanged);
30}
31
32Job::~Job() = default;
33
34uint Job::id() const
35{
36 return d->m_id;
37}
38
39QDateTime Job::created() const
40{
41 return d->m_created;
42}
43
44QDateTime Job::updated() const
45{
46 return d->m_updated;
47}
48
49void Job::resetUpdated()
50{
51 d->m_updated = QDateTime::currentDateTimeUtc();
52 Q_EMIT updatedChanged();
53}
54
56{
57 return d->m_summary;
58}
59
60QString Job::text() const
61{
62 return d->text();
63}
64
66{
67 return d->m_desktopEntry;
68}
69
70void Job::setDesktopEntry(const QString &desktopEntry)
71{
72 Q_ASSERT(d->m_desktopEntry.isNull());
73 d->m_desktopEntry = desktopEntry;
74}
75
77{
78 return d->m_applicationName;
79}
80
81void Job::setApplicationName(const QString &applicationName)
82{
83 Q_ASSERT(d->m_applicationName.isNull());
84 d->m_applicationName = applicationName;
85}
86
88{
89 return d->m_applicationIconName;
90}
91
92void Job::setApplicationIconName(const QString &applicationIconName)
93{
94 Q_ASSERT(d->m_applicationIconName.isNull());
95 d->m_applicationIconName = applicationIconName;
96}
97
99{
100 return d->m_state;
101}
102
103void Job::setState(Notifications::JobState state)
104{
105 if (d->m_state != state) {
106 d->m_state = state;
107 Q_EMIT stateChanged(state);
108 }
109}
110
111int Job::percentage() const
112{
113 return d->m_percentage;
114}
115
116int Job::error() const
117{
118 return d->m_error;
119}
120
121void Job::setError(int error)
122{
123 if (d->m_error != error) {
124 d->m_error = error;
125 Q_EMIT errorChanged(error);
126 }
127}
128
129QString Job::errorText() const
130{
131 return d->m_errorText;
132}
133
134void Job::setErrorText(const QString &errorText)
135{
136 if (d->m_errorText != errorText) {
137 d->m_errorText = errorText;
138 Q_EMIT errorTextChanged(errorText);
139 }
140}
141
142bool Job::suspendable() const
143{
144 return d->m_suspendable;
145}
146
147void Job::setSuspendable(bool suspendable)
148{
149 // Cannot change after job started
150 d->m_suspendable = suspendable;
151}
152
153bool Job::killable() const
154{
155 return d->m_killable;
156}
157
158void Job::setKillable(bool killable)
159{
160 // Cannot change after job started
161 d->m_killable = killable;
162}
163
164bool Job::transient() const
165{
166 return d->m_transient;
167}
168
169void Job::setTransient(bool transient)
170{
171 d->m_transient = transient;
172}
173
174QUrl Job::destUrl() const
175{
176 return d->m_destUrl;
177}
178
179qulonglong Job::speed() const
180{
181 return d->m_speed;
182}
183
184qulonglong Job::processedBytes() const
185{
186 return d->m_processedBytes;
187}
188
189qulonglong Job::processedFiles() const
190{
191 return d->m_processedFiles;
192}
193
194qulonglong Job::processedDirectories() const
195{
196 return d->m_processedDirectories;
197}
198
199qulonglong Job::processedItems() const
200{
201 return d->m_processedItems;
202}
203
204qulonglong Job::totalBytes() const
205{
206 return d->m_totalBytes;
207}
208
209qulonglong Job::totalFiles() const
210{
211 return d->m_totalFiles;
212}
213
214qulonglong Job::totalDirectories() const
215{
216 return d->m_totalDirectories;
217}
218
219qulonglong Job::totalItems() const
220{
221 return d->m_totalItems;
222}
223
224QString Job::descriptionLabel1() const
225{
226 return d->m_descriptionLabel1;
227}
228
229QString Job::descriptionValue1() const
230{
231 return d->m_descriptionValue1;
232}
233
234QString Job::descriptionLabel2() const
235{
236 return d->m_descriptionLabel2;
237}
238
239QString Job::descriptionValue2() const
240{
241 return d->m_descriptionValue2;
242}
243
244bool Job::hasDetails() const
245{
246 return d->m_hasDetails;
247}
248
250{
251 return d->descriptionUrl();
252}
253
254bool Job::expired() const
255{
256 return d->m_expired;
257}
258
259void Job::setExpired(bool expired)
260{
261 if (d->m_expired != expired) {
262 d->m_expired = expired;
263 Q_EMIT expiredChanged();
264 }
265}
266
267bool Job::dismissed() const
268{
269 return d->m_dismissed;
270}
271
272void Job::setDismissed(bool dismissed)
273{
274 if (d->m_dismissed != dismissed) {
275 d->m_dismissed = dismissed;
276 Q_EMIT dismissedChanged();
277 }
278}
279
280void Job::suspend()
281{
282 Q_EMIT d->suspendRequested();
283}
284
285void Job::resume()
286{
287 Q_EMIT d->resumeRequested();
288}
289
290void Job::kill()
291{
292 d->kill();
293}
bool hasDetails
Whether there are any details available for this job.
Definition job.h:121
qulonglong speed
Current transfer rate in Byte/s.
Definition job.h:94
QString text
User-friendly compact description text of the job, for example "42 of 1337 files to "~/some/folder",...
Definition job.h:46
bool suspendable
Whether the job can be suspended.
Definition job.h:78
QUrl descriptionUrl
This tries to generate a valid URL for a file that's being processed by converting descriptionValue2 ...
Definition job.h:127
int error
The error code of the job failure.
Definition job.h:71
QString desktopEntry
The desktop entry of the application owning the job, e.g.
Definition job.h:51
QString applicationIconName
The icon name of the application owning the job, e.g.
Definition job.h:59
QML_ELEMENTQString summary
The job infoMessage, e.g.
Definition job.h:40
QUrl destUrl
The destination URL of a job.
Definition job.h:89
bool killable
Whether the job can be aborted.
Definition job.h:84
Notifications::JobState state
The state the job is currently in.
Definition job.h:63
QString applicationName
The user-visible name of the application owning the job, e.g.
Definition job.h:55
int percentage
The total percentage (0-100) of job completion.
Definition job.h:67
JobState
The state an application job is in.
void transient(const QString &message, const QString &title)
QDateTime currentDateTimeUtc()
Q_EMITQ_EMIT
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:42 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.