Skip to content
Snippets Groups Projects
Commit 8f41a05c authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

disambiguate cJobItems from jobItems

parent 979577a5
No related branches found
No related tags found
1 merge request!2338cleanup JobsSet
......@@ -68,6 +68,11 @@ QVector<JobItem*> JobsSet::jobItems() const
return QVector<JobItem*>(m_job_items.begin(), m_job_items.end());
}
QVector<const JobItem*> JobsSet::cJobItems() const
{
return QVector<const JobItem*>(m_job_items.begin(), m_job_items.end());
}
//! restore instrument and sample model from backup for given JobItem
void JobsSet::restore(JobItem* job_item, int index)
{
......@@ -173,7 +178,7 @@ void JobsSet::removeJob(JobItem* job_item)
QString JobsSet::generateJobName()
{
int maxJobIndex = 0;
for (const auto* job_item : jobItems()) {
for (const JobItem* job_item : cJobItems()) {
if (job_item->batchInfo()->jobName().startsWith("job"))
maxJobIndex = std::max(maxJobIndex, job_item->batchInfo()->jobName().mid(3).toInt());
}
......@@ -188,7 +193,7 @@ QString JobsSet::generateJobName()
bool JobsSet::hasUnfinishedJobs()
{
for (auto* job_item : jobItems())
for (const JobItem* job_item : cJobItems())
if (isFitting(job_item->batchInfo()->status()))
return true;
......@@ -265,7 +270,7 @@ void JobsSet::onProgressUpdate()
int global_progress(0);
int nRunningJobs(0);
for (auto* job_item : jobItems())
for (const JobItem* job_item : cJobItems())
if (isRunning(job_item->batchInfo()->status())) {
global_progress += job_item->batchInfo()->progress();
nRunningJobs++;
......
......@@ -45,6 +45,7 @@ public:
void addJobItem(JobItem* job_item);
QVector<JobItem*> jobItems() const;
QVector<const JobItem*> cJobItems() const;
void restore(JobItem* job_item, int index);
......
......@@ -47,11 +47,11 @@ int JobsQModel::rowCount(const QModelIndex&) const
QVariant JobsQModel::data(const QModelIndex& index, int role) const
{
QVector<JobItem*> jobs = m_jobs->jobItems();
QVector<const JobItem*> jobs = m_jobs->cJobItems();
if (!index.isValid() || index.row() >= jobs.size() || index.row() < 0)
return {};
JobItem* item = jobs[index.row()];
const JobItem* item = jobs[index.row()];
if (role == Qt::DisplayRole)
return item->batchInfo()->jobName();
......@@ -68,7 +68,7 @@ JobItem* JobsQModel::jobItemForIndex(const QModelIndex& index) const
QModelIndex JobsQModel::indexForJob(JobItem* job)
{
QVector<JobItem*> jobs = m_jobs->jobItems();
QVector<const JobItem*> jobs = m_jobs->cJobItems();
int idx = jobs.indexOf(job);
if (idx != -1)
return index(idx, 0);
......@@ -100,7 +100,7 @@ void JobsQModel::cancelJob(const QModelIndex& index)
void JobsQModel::emitJobsQModelChanged(JobItem* job)
{
QVector<JobItem*> jobs = m_jobs->jobItems();
QVector<const JobItem*> jobs = m_jobs->cJobItems();
int i = jobs.indexOf(job);
if (i != -1) {
QModelIndex idx = index(i, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment