Switch JobStatus enum to scoped enum.
This commit is contained in:
parent
0263e45251
commit
527734e9e8
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
Job::Job() :
|
Job::Job() :
|
||||||
m_Report(nullptr),
|
m_Report(nullptr),
|
||||||
m_Status(Pending)
|
m_Status(Status::Pending)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ Report* Job::jobStarted(Report& parent)
|
||||||
|
|
||||||
void Job::jobFinished(Report& report, bool b)
|
void Job::jobFinished(Report& report, bool b)
|
||||||
{
|
{
|
||||||
setStatus(b ? Success : Error);
|
setStatus(b ? Status::Success : Status::Error);
|
||||||
emit progress(numSteps());
|
emit progress(numSteps());
|
||||||
emit finished();
|
emit finished();
|
||||||
|
|
||||||
|
@ -137,12 +137,7 @@ QString Job::statusIcon() const
|
||||||
QStringLiteral("dialog-error")
|
QStringLiteral("dialog-error")
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ASSERT(status() >= 0 && static_cast<quint32>(status()) < sizeof(icons) / sizeof(icons[0]));
|
return icons[static_cast<int>(status())];
|
||||||
|
|
||||||
if (status() < 0 || static_cast<quint32>(status()) >= sizeof(icons) / sizeof(icons[0]))
|
|
||||||
return QString();
|
|
||||||
|
|
||||||
return icons[status()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the Job's current status text */
|
/** @return the Job's current status text */
|
||||||
|
@ -154,10 +149,5 @@ QString Job::statusText() const
|
||||||
xi18nc("@info:progress job", "Error")
|
xi18nc("@info:progress job", "Error")
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ASSERT(status() >= 0 && static_cast<quint32>(status()) < sizeof(s) / sizeof(s[0]));
|
return s[static_cast<int>(status())];
|
||||||
|
|
||||||
if (status() < 0 || static_cast<quint32>(status()) >= sizeof(s) / sizeof(s[0]))
|
|
||||||
return QString();
|
|
||||||
|
|
||||||
return s[status()];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if !defined(KPMCORE_JOB_H)
|
#ifndef KPMCORE_JOB_H
|
||||||
|
|
||||||
#define KPMCORE_JOB_H
|
#define KPMCORE_JOB_H
|
||||||
|
|
||||||
#include "fs/filesystem.h"
|
#include "fs/filesystem.h"
|
||||||
|
@ -49,10 +48,10 @@ class LIBKPMCORE_EXPORT Job : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Status of this Job */
|
/** Status of this Job */
|
||||||
enum JobStatus {
|
enum class Status : int {
|
||||||
Pending = 0, /**< Pending, not yet run */
|
Pending, /**< Pending, not yet run */
|
||||||
Success, /**< Successfully run */
|
Success, /**< Successfully run */
|
||||||
Error /**< Running generated an error */
|
Error /**< Running generated an error */
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -76,7 +75,7 @@ public:
|
||||||
virtual QString statusIcon() const;
|
virtual QString statusIcon() const;
|
||||||
virtual QString statusText() const;
|
virtual QString statusText() const;
|
||||||
|
|
||||||
JobStatus status() const {
|
Status status() const {
|
||||||
return m_Status; /**< @return the Job's current status */
|
return m_Status; /**< @return the Job's current status */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +89,13 @@ protected:
|
||||||
Report* jobStarted(Report& parent);
|
Report* jobStarted(Report& parent);
|
||||||
void jobFinished(Report& report, bool b);
|
void jobFinished(Report& report, bool b);
|
||||||
|
|
||||||
void setStatus(JobStatus s) {
|
void setStatus(Status s) {
|
||||||
m_Status = s;
|
m_Status = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Report *m_Report;
|
Report *m_Report;
|
||||||
JobStatus m_Status;
|
Status m_Status;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue