From: Renaud Barate Date: Mon, 26 Jan 2015 13:04:11 +0000 (+0100) Subject: Fix bug preventing to change the type of a cloned job X-Git-Tag: V7_6_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=070c18dea25170f7a4090acf39a2b147787076a9;p=modules%2Fjobmanager.git Fix bug preventing to change the type of a cloned job --- diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 9d9ea3c..ce6add0 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -47,6 +47,7 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO _salome_services = salome_services; job_name = ""; + job_type = YACS; yacs_file = ""; command = ""; python_salome_file = ""; @@ -125,7 +126,7 @@ BL::CreateJobWizard::clone(const std::string & name) if (job->getType() == BL::Job::YACS_SCHEMA) { setField("yacs_file", QString(job->getJobFile().c_str())); - _job_name_page->_yacs_schema_button->click(); + setField("job_type_yacs", true); setField("env_yacs_file", QString(job->getEnvFile().c_str())); if (job->getDumpYACSState() != -1) { @@ -137,13 +138,13 @@ BL::CreateJobWizard::clone(const std::string & name) else if (job->getType() == BL::Job::COMMAND) { setField("command", QString(job->getJobFile().c_str())); - _job_name_page->_command_button->click(); + setField("job_type_command", true); setField("env_command_file", QString(job->getEnvFile().c_str())); } else if (job->getType() == BL::Job::PYTHON_SALOME) { setField("PythonSalome", QString(job->getJobFile().c_str())); - _job_name_page->_python_salome_button->click(); + setField("job_type_python_salome", true); setField("env_PythonSalome_file", QString(job->getEnvFile().c_str())); } @@ -247,6 +248,12 @@ BL::CreateJobWizard::end(int result) // Job Name Panel QString f_job_name = field("job_name").toString(); job_name = f_job_name.trimmed().toUtf8().constData(); + if (field("job_type_yacs").toBool()) + job_type = YACS; + else if (field("job_type_command").toBool()) + job_type = COMMAND; + else + job_type = PYTHON_SALOME; // YACS Schema Panel QString f_yacs_file = field("yacs_file").toString(); @@ -262,11 +269,11 @@ BL::CreateJobWizard::end(int result) python_salome_file = f_python_salome_file.trimmed().toUtf8().constData(); QString f_env_file; - if (yacs_file != "") + if (job_type == YACS) f_env_file = field("env_yacs_file").toString(); - else if (command != "") + else if (job_type == COMMAND) f_env_file = field("env_command_file").toString(); - else if (python_salome_file != "") + else if (job_type == PYTHON_SALOME) f_env_file = field("env_PythonSalome_file").toString(); env_file = f_env_file.trimmed().toUtf8().constData(); @@ -394,16 +401,19 @@ BL::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager QLabel * label_type = new QLabel("Choose type of batch job:"); QGroupBox *groupBox = new QGroupBox("Type of job"); - _yacs_schema_button = new QRadioButton(tr("YACS Schema")); + QRadioButton * _yacs_schema_button = new QRadioButton(tr("YACS Schema")); _yacs_schema_button->setChecked(true); - _command_button = new QRadioButton(tr("Command")); - _python_salome_button = new QRadioButton(tr("Python script in SALOME")); + QRadioButton * _command_button = new QRadioButton(tr("Command")); + QRadioButton * _python_salome_button = new QRadioButton(tr("Python script in SALOME")); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(_yacs_schema_button); vbox->addWidget(_command_button); vbox->addWidget(_python_salome_button); vbox->addStretch(1); groupBox->setLayout(vbox); + registerField("job_type_yacs", _yacs_schema_button); + registerField("job_type_command", _command_button); + registerField("job_type_python_salome", _python_salome_button); QGroupBox * explanationBox = new QGroupBox("Explanation"); QVBoxLayout *explanationvbox = new QVBoxLayout; @@ -425,9 +435,9 @@ BL::JobNamePage::JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager layout->addWidget(explanationBox, 4, 0, 1, -1); setLayout(main_layout); - connect(_yacs_schema_button, SIGNAL(clicked(bool)), this, SLOT(yacs_schema_button(bool))); - connect(_command_button, SIGNAL(clicked(bool)), this, SLOT(command_button(bool))); - connect(_python_salome_button, SIGNAL(clicked(bool)), this, SLOT(python_salome_button(bool))); + connect(_yacs_schema_button, SIGNAL(toggled(bool)), this, SLOT(yacs_schema_button(bool))); + connect(_command_button, SIGNAL(toggled(bool)), this, SLOT(command_button(bool))); + connect(_python_salome_button, SIGNAL(toggled(bool)), this, SLOT(python_salome_button(bool))); // Default button yacs_schema_button(true); @@ -501,11 +511,11 @@ BL::JobNamePage::validatePage() int BL::JobNamePage::nextId() const { - if (_yacs_schema_button->isChecked()) + if (field("job_type_yacs").toBool()) { return BL::CreateJobWizard::Page_YACSSchema; } - else if (_command_button->isChecked()) + else if (field("job_type_command").toBool()) { return BL::CreateJobWizard::Page_Command_Main_Definitions; } diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index 54f5e11..b9d3760 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -67,6 +67,7 @@ namespace BL{ public: // Results std::string job_name; + enum {YACS, COMMAND, PYTHON_SALOME} job_type; std::string yacs_file; std::string command; @@ -137,9 +138,6 @@ namespace BL{ QLabel * _explanation; public: - QRadioButton * _yacs_schema_button; - QRadioButton * _command_button; - QRadioButton * _python_salome_button; bool _check_name; }; diff --git a/src/genericgui/BL_JobsManager_QT.cxx b/src/genericgui/BL_JobsManager_QT.cxx index 3e57f6e..4b5f3f3 100644 --- a/src/genericgui/BL_JobsManager_QT.cxx +++ b/src/genericgui/BL_JobsManager_QT.cxx @@ -272,24 +272,26 @@ void BL::JobsManager_QT::create_job_with_wizard(BL::CreateJobWizard & wizard) { BL::Job * new_job = createJob(wizard.job_name); - if (wizard.yacs_file != "") + switch (wizard.job_type) { + case BL::CreateJobWizard::YACS: // YACS schema job new_job->setType(BL::Job::YACS_SCHEMA); new_job->setJobFile(wizard.yacs_file); new_job->setDumpYACSState(wizard.dump_yacs_state); - } - else if (wizard.command != "") - { + break; + case BL::CreateJobWizard::COMMAND: // Command Job new_job->setType(BL::Job::COMMAND); new_job->setJobFile(wizard.command); - } - else if (wizard.python_salome_file != "") - { - // Command Job + break; + case BL::CreateJobWizard::PYTHON_SALOME: + // Python Salome Job new_job->setType(BL::Job::PYTHON_SALOME); new_job->setJobFile(wizard.python_salome_file); + break; + default: + throw BL::Exception("Unknown job type"); } // For all jobs