Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/job_p.cpp
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | |||||
149 | } | 149 | } | ||
150 | 150 | | |||
151 | QString JobPrivate::text() const | 151 | QString JobPrivate::text() const | ||
152 | { | 152 | { | ||
153 | if (!m_errorText.isEmpty()) { | 153 | if (!m_errorText.isEmpty()) { | ||
154 | return m_errorText; | 154 | return m_errorText; | ||
155 | } | 155 | } | ||
156 | 156 | | |||
157 | if (!m_infoMessage.isEmpty()) { | ||||
158 | return m_infoMessage; | ||||
159 | } | ||||
160 | | ||||
157 | const QString currentFileName = descriptionUrl().fileName(); | 161 | const QString currentFileName = descriptionUrl().fileName(); | ||
158 | const QString destUrlString = prettyDestUrl(); | 162 | const QString destUrlString = prettyDestUrl(); | ||
159 | 163 | | |||
160 | if (m_totalFiles == 0) { | 164 | if (m_totalFiles == 0) { | ||
161 | if (!destUrlString.isEmpty()) { | 165 | if (!destUrlString.isEmpty()) { | ||
162 | if (m_processedFiles > 0) { | 166 | if (m_processedFiles > 0) { | ||
163 | return i18ncp("Copying n files to location", "%1 file to %2", "%1 files to %2", | 167 | return i18ncp("Copying n files to location", "%1 file to %2", "%1 files to %2", | ||
164 | m_processedFiles, destUrlString); | 168 | m_processedFiles, destUrlString); | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | |||||
280 | } | 284 | } | ||
281 | 285 | | |||
282 | void JobPrivate::setSpeed(quint64 bytesPerSecond) | 286 | void JobPrivate::setSpeed(quint64 bytesPerSecond) | ||
283 | { | 287 | { | ||
284 | updateField(bytesPerSecond, m_speed, &Job::speedChanged); | 288 | updateField(bytesPerSecond, m_speed, &Job::speedChanged); | ||
285 | updateHasDetails(); | 289 | updateHasDetails(); | ||
286 | } | 290 | } | ||
287 | 291 | | |||
292 | // NOTE infoMessage isn't supposed to be the "Copying..." heading but e.g. a "Connecting to server..." status message | ||||
293 | // JobViewV1/V2 got that wrong but JobView3 uses "title" and "infoMessage" correctly respectively. | ||||
288 | void JobPrivate::setInfoMessage(const QString &infoMessage) | 294 | void JobPrivate::setInfoMessage(const QString &infoMessage) | ||
289 | { | 295 | { | ||
290 | updateField(infoMessage, m_summary, &Job::summaryChanged); | 296 | updateField(infoMessage, m_summary, &Job::summaryChanged); | ||
291 | } | 297 | } | ||
292 | 298 | | |||
293 | bool JobPrivate::setDescriptionField(uint number, const QString &name, const QString &value) | 299 | bool JobPrivate::setDescriptionField(uint number, const QString &name, const QString &value) | ||
294 | { | 300 | { | ||
295 | bool dirty = false; | 301 | bool dirty = false; | ||
Show All 37 Lines | 335 | { | |||
333 | job->setError(errorCode); | 339 | job->setError(errorCode); | ||
334 | job->setErrorText(errorMessage); | 340 | job->setErrorText(errorMessage); | ||
335 | job->setState(Notifications::JobStateStopped); | 341 | job->setState(Notifications::JobStateStopped); | ||
336 | finish(); | 342 | finish(); | ||
337 | } | 343 | } | ||
338 | 344 | | |||
339 | void JobPrivate::update(const QVariantMap &properties) | 345 | void JobPrivate::update(const QVariantMap &properties) | ||
340 | { | 346 | { | ||
341 | // TODO | 347 | auto end = properties.end(); | ||
342 | sendErrorReply(QDBusError::NotSupported, QStringLiteral("JobViewV3 update is not yet implemented.")); | 348 | | ||
343 | Q_UNUSED(properties) | 349 | auto it = properties.find(QStringLiteral("title")); | ||
350 | if (it != end) { | ||||
davidedmundson: you can probably constEnd / constFind etc. | |||||
351 | updateField(it->toString(), m_summary, &Job::summaryChanged); | ||||
352 | } | ||||
353 | | ||||
354 | it = properties.find(QStringLiteral("infoMessage")); | ||||
355 | if (it != end) { | ||||
356 | // InfoMessage is exposed via text()/BodyRole, not via public API, hence no public signal | ||||
357 | const QString infoMessage = it->toString(); | ||||
358 | if (m_infoMessage != infoMessage) { | ||||
359 | m_infoMessage = it->toString(); | ||||
360 | emit infoMessageChanged(); | ||||
361 | } | ||||
362 | } | ||||
363 | | ||||
364 | it = properties.find(QStringLiteral("percent")); | ||||
365 | if (it != end) { | ||||
366 | setPercent(it->toUInt()); | ||||
367 | } | ||||
368 | | ||||
369 | it = properties.find(QStringLiteral("destUrl")); | ||||
370 | if (it != end) { | ||||
371 | const QUrl destUrl = QUrl(it->toUrl().adjusted(QUrl::StripTrailingSlash)); // urgh | ||||
372 | updateField(destUrl, m_destUrl, &Job::destUrlChanged); | ||||
373 | } | ||||
374 | | ||||
375 | it = properties.find(QStringLiteral("speed")); | ||||
376 | if (it != end) { | ||||
377 | setSpeed(it->value<qulonglong>()); | ||||
378 | } | ||||
379 | | ||||
380 | updateFieldFromProperties(properties, QStringLiteral("processedFiles"), m_processedFiles, &Job::processedFilesChanged); | ||||
381 | updateFieldFromProperties(properties, QStringLiteral("processedBytes"), m_processedBytes, &Job::processedBytesChanged); | ||||
382 | updateFieldFromProperties(properties, QStringLiteral("processedDirectories"), m_processedDirectories, &Job::processedDirectoriesChanged); | ||||
383 | | ||||
384 | updateFieldFromProperties(properties, QStringLiteral("totalFiles"), m_totalFiles, &Job::totalFilesChanged); | ||||
385 | updateFieldFromProperties(properties, QStringLiteral("totalBytes"), m_totalBytes, &Job::totalBytesChanged); | ||||
386 | updateFieldFromProperties(properties, QStringLiteral("totalDirectories"), m_totalDirectories, &Job::totalDirectoriesChanged); | ||||
387 | | ||||
388 | updateFieldFromProperties(properties, QStringLiteral("descriptionLabel1"), m_descriptionLabel1, &Job::descriptionLabel1Changed); | ||||
389 | updateFieldFromProperties(properties, QStringLiteral("descriptionValue1"), m_descriptionValue1, &Job::descriptionValue1Changed); | ||||
390 | updateFieldFromProperties(properties, QStringLiteral("descriptionLabel2"), m_descriptionLabel2, &Job::descriptionLabel2Changed); | ||||
391 | updateFieldFromProperties(properties, QStringLiteral("descriptionValue2"), m_descriptionValue2, &Job::descriptionValue2Changed); | ||||
392 | | ||||
393 | it = properties.find(QStringLiteral("suspended")); | ||||
394 | if (it != end) { | ||||
395 | setSuspended(it->toBool()); | ||||
396 | } | ||||
397 | | ||||
398 | updateHasDetails(); | ||||
344 | } | 399 | } |
you can probably constEnd / constFind etc.