GUI: show number of running jobs in the status bar

This commit is contained in:
Moritz Bunkus 2015-08-14 19:46:18 +02:00
parent 95b88d6dee
commit ee8dae5da5
5 changed files with 13 additions and 18 deletions

View File

@ -55,7 +55,7 @@
</sizepolicy>
</property>
<property name="text">
<string notr="true">0 automatic, 0 manual</string>
<string notr="true">0 automatic, 0 manual, 0 running</string>
</property>
</widget>
</item>

View File

@ -445,21 +445,14 @@ void
Model::updateJobStats() {
QMutexLocker locked{&m_mutex};
auto numPendingAuto = 0;
auto numPendingManual = 0;
auto numOther = 0;
auto numJobs = std::map<Job::Status, int>{ { Job::PendingAuto, 0 }, { Job::PendingManual, 0 }, { Job::Running, 0 }, { Job::Disabled, 0 } };
for (auto const &job : m_jobsById)
if (mtx::included_in(job->status(), Job::PendingAuto, Job::Running))
++numPendingAuto;
for (auto const &job : m_jobsById) {
auto idx = mtx::included_in(job->status(), Job::PendingAuto, Job::PendingManual, Job::Running) ? job->status() : Job::Disabled;
++numJobs[idx];
}
else if (Job::PendingManual == job->status())
++numPendingManual;
else
++numOther;
emit jobStatsChanged(numPendingAuto, numPendingManual, numOther);
emit jobStatsChanged(numJobs[ Job::PendingAuto ], numJobs[ Job::PendingManual ], numJobs[ Job::Running ], numJobs[ Job::Disabled ]);
}
void

View File

@ -83,7 +83,7 @@ public:
signals:
void progressChanged(int progress, int totalProgress);
void jobStatsChanged(int numPendingAutomatic, int numPendingManual, int numOther);
void jobStatsChanged(int numPendingAutomatic, int numPendingManual, int numRunning, int numOther);
void numUnacknowledgedWarningsOrErrorsChanged(int numWarnings, int numErrors);
void queueStatusChanged(QueueStatus status);

View File

@ -48,9 +48,11 @@ StatusBarProgressWidget::setProgress(int progress,
void
StatusBarProgressWidget::setJobStats(int numPendingAuto,
int numPendingManual,
int numRunning,
int) {
m_numPendingAuto = numPendingAuto;
m_numPendingManual = numPendingManual;
m_numRunning = numRunning;
setLabelTexts();
}
@ -84,7 +86,7 @@ StatusBarProgressWidget::retranslateUi() {
void
StatusBarProgressWidget::setLabelTexts() {
ui->numJobsLabel->setText(QY("%1 automatic, %2 manual").arg(m_numPendingAuto).arg(m_numPendingManual));
ui->numJobsLabel->setText(QY("%1 automatic, %2 manual, %3 running").arg(m_numPendingAuto).arg(m_numPendingManual).arg(m_numRunning));
ui->warningsLabel->setText(QNY("%1 warning", "%1 warnings", m_numWarnings).arg(m_numWarnings));
ui->errorsLabel ->setText(QNY("%1 error", "%1 errors", m_numErrors) .arg(m_numErrors));
}

View File

@ -19,7 +19,7 @@ class StatusBarProgressWidget : public QWidget {
protected:
std::unique_ptr<Ui::StatusBarProgressWidget> ui;
int m_numPendingAuto{}, m_numPendingManual{}, m_numWarnings{}, m_numErrors{}, m_timerStep{};
int m_numPendingAuto{}, m_numPendingManual{}, m_numRunning{}, m_numWarnings{}, m_numErrors{}, m_timerStep{};
QTimer m_timer;
QList<QPixmap> m_pixmaps;
@ -31,7 +31,7 @@ public:
public slots:
void setProgress(int progress, int totalProgress);
void setJobStats(int numPendingAutomatic, int numPendingManual, int numOther);
void setJobStats(int numPendingAutomatic, int numPendingManual, int numRunning, int numOther);
void setNumUnacknowledgedWarningsOrErrors(int numWarnings, int numErrors);
void updateWarningsAndErrorsIcons();