diff --git a/GUI/coregui/Models/JobItem.cpp b/GUI/coregui/Models/JobItem.cpp index 0d5b70d55e29bbf7d44fb7b6f987ff4747fca2ed..59b21fc9da436162aff5c3acfbbef5ce01546a89 100644 --- a/GUI/coregui/Models/JobItem.cpp +++ b/GUI/coregui/Models/JobItem.cpp @@ -22,16 +22,17 @@ namespace { -const QString RUN_IMMEDIATELY = "Immediately"; -const QString RUN_IN_BACKGROUND = "In background"; -const QString RUN_SUBMIT_ONLY = "Submit only"; QMap<QString, QString> initializeRunPolicies() { QMap<QString, QString> result; - result[RUN_IMMEDIATELY] = QString("Start simulation immediately, switch to Jobs view automatically when completed"); - result[RUN_IN_BACKGROUND] = QString("Start simulation immediately, do not switch to Jobs view when completed"); - result[RUN_SUBMIT_ONLY] = QString("Only submit simulation for consequent execution, has to be started from Jobs view explicitely"); + result[Constants::JOB_RUN_IMMEDIATELY] = + QString("Start simulation immediately, switch to Jobs view automatically when completed"); + result[Constants::JOB_RUN_IN_BACKGROUND] = + QString("Start simulation immediately, do not switch to Jobs view when completed"); + result[Constants::JOB_RUN_SUBMIT_ONLY] = + QString("Only submit simulation for consequent execution," + " has to be started from Jobs view explicitely"); return result; } @@ -75,7 +76,9 @@ JobItem::JobItem(ParameterizedItem *parent) registerProperty(P_NTHREADS, -1, PropertyAttribute(PropertyAttribute::HIDDEN)); ComboProperty policy; - policy << RUN_IMMEDIATELY <<RUN_IN_BACKGROUND << RUN_SUBMIT_ONLY; + policy << Constants::JOB_RUN_IMMEDIATELY + << Constants::JOB_RUN_IN_BACKGROUND + << Constants::JOB_RUN_SUBMIT_ONLY; registerProperty(P_RUN_POLICY, policy.getVariant(), PropertyAttribute(PropertyAttribute::HIDDEN)); addToValidChildren(Constants::IntensityDataType); @@ -228,14 +231,21 @@ void JobItem::setNumberOfThreads(int number_of_threads) setRegisteredProperty(P_NTHREADS, number_of_threads); } +void JobItem::setRunPolicy(const QString &run_policy) +{ + ComboProperty combo_property = getRegisteredProperty(JobItem::P_RUN_POLICY).value<ComboProperty>(); + combo_property.setValue(run_policy); + setRegisteredProperty(JobItem::P_RUN_POLICY, combo_property.getVariant()); +} + bool JobItem::runImmediately() const { ComboProperty combo_property = getRegisteredProperty(P_RUN_POLICY).value<ComboProperty>(); - return combo_property.getValue() == RUN_IMMEDIATELY; + return combo_property.getValue() == Constants::JOB_RUN_IMMEDIATELY; } bool JobItem::runInBackground() const { ComboProperty combo_property = getRegisteredProperty(P_RUN_POLICY).value<ComboProperty>(); - return combo_property.getValue() == RUN_IN_BACKGROUND; + return combo_property.getValue() == Constants::JOB_RUN_IN_BACKGROUND; } diff --git a/GUI/coregui/Models/JobItem.h b/GUI/coregui/Models/JobItem.h index 55bc21f22a9f0f9ba1f7a74b3c2ee59ecad360d4..a55b449519f83cfda72f5ccd3ab4785790ec2424 100644 --- a/GUI/coregui/Models/JobItem.h +++ b/GUI/coregui/Models/JobItem.h @@ -72,6 +72,8 @@ public: int getNumberOfThreads() const; void setNumberOfThreads(int number_of_threads); + void setRunPolicy(const QString &run_policy); + static QMap<QString, QString> getRunPolicies() { return m_run_policies; } bool runImmediately() const; diff --git a/GUI/coregui/Models/JobModel.cpp b/GUI/coregui/Models/JobModel.cpp index 71bf3894112229f3d69a5624f221455058df934b..959c01fd61e61844bdad86e5b82020482af5c554 100644 --- a/GUI/coregui/Models/JobModel.cpp +++ b/GUI/coregui/Models/JobModel.cpp @@ -75,9 +75,10 @@ JobItem *JobModel::addJob(SampleModel *sampleModel, InstrumentModel *instrumentM jobItem->setIdentifier(generateJobIdentifier()); jobItem->setNumberOfThreads(numberOfThreads); - ComboProperty combo_property = jobItem->getRegisteredProperty(JobItem::P_RUN_POLICY).value<ComboProperty>(); - combo_property.setValue(run_policy); - jobItem->setRegisteredProperty(JobItem::P_RUN_POLICY, combo_property.getVariant()); +// ComboProperty combo_property = jobItem->getRegisteredProperty(JobItem::P_RUN_POLICY).value<ComboProperty>(); +// combo_property.setValue(run_policy); +// jobItem->setRegisteredProperty(JobItem::P_RUN_POLICY, combo_property.getVariant()); + jobItem->setRunPolicy(run_policy); if(jobItem->runImmediately() || jobItem->runInBackground()) m_queue_data->runJob(jobItem); @@ -91,7 +92,9 @@ JobItem *JobModel::addJob(SampleModel *sampleModel, InstrumentModel *instrumentM void JobModel::runJob(const QModelIndex &index) { qDebug() << "NJobModel::runJob(const QModelIndex &index)"; - m_queue_data->runJob(getJobItemForIndex(index)); + JobItem *jobItem = getJobItemForIndex(index); + jobItem->setRunPolicy(Constants::JOB_RUN_IMMEDIATELY); + m_queue_data->runJob(jobItem); } void JobModel::cancelJob(const QModelIndex &index) diff --git a/GUI/coregui/Models/item_constants.h b/GUI/coregui/Models/item_constants.h index 1d39918cd330d019f51f76f22c8f419caed1aac1..d5afadaca633243a800ac83f73bb9f2026e2a1ef 100644 --- a/GUI/coregui/Models/item_constants.h +++ b/GUI/coregui/Models/item_constants.h @@ -160,6 +160,10 @@ const ModelType GRADIENT_HUES = "Hues"; const ModelType AXIS_FIXED_BINNING = "Fixed"; const ModelType AXIS_CONSTK_BINNING = "Const KBin"; +const ModelType JOB_RUN_IMMEDIATELY = "Immediately"; +const ModelType JOB_RUN_IN_BACKGROUND = "In background"; +const ModelType JOB_RUN_SUBMIT_ONLY = "Submit only"; + }