1 /*
2 SPDX-FileCopyrightText: 2015 Kevin Funk <kfunk@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5 */
6
7 #include "jobstatus.h"
8
9 #include <kcoreaddons_version.h>
10 #include <KJob>
11 #include <KLocalizedString>
12
13 using namespace KDevelop;
14
15 class KDevelop::JobStatusPrivate
16 {
17 public:
18 QString m_statusName;
19 };
20
JobStatus(KJob * job,const QString & statusName,QObject * parent)21 JobStatus::JobStatus(KJob* job, const QString& statusName, QObject* parent)
22 : QObject(parent)
23 , d_ptr(new JobStatusPrivate{statusName})
24 {
__anonc405c9180102(KJob*, const QString& plain, const QString&) 25 connect(job, &KJob::infoMessage, this, [this](KJob*, const QString& plain, const QString&) {
26 emit showMessage(this, plain);
27 });
__anonc405c9180202() 28 connect(job, &KJob::finished, this, [this, job]() {
29 if (job->error() == KJob::KilledJobError) {
30 emit showErrorMessage(i18n("Task aborted"));
31 }
32 emit hideProgress(this);
33 deleteLater();
34 });
35 #if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 80, 0)
36 connect(job, QOverload<KJob*, unsigned long>::of(&KJob::percent), this, &JobStatus::slotPercent);
37 #else
38 connect(job, &KJob::percentChanged, this, &JobStatus::slotPercent);
39 #endif
40 }
41
~JobStatus()42 JobStatus::~JobStatus()
43 {
44 }
45
statusName() const46 QString JobStatus::statusName() const
47 {
48 Q_D(const JobStatus);
49
50 return d->m_statusName;
51 }
52
slotPercent(KJob * job,unsigned long percent)53 void JobStatus::slotPercent(KJob* job, unsigned long percent)
54 {
55 Q_UNUSED(job)
56 emit showProgress(this, 0, 100, percent);
57 }
58
59 #include "moc_jobstatus.cpp"
60