From: barate Date: Tue, 17 Sep 2013 16:25:38 +0000 (+0000) Subject: Redesign two wizard pages as UI files with QT designer to facilitate further evolutions X-Git-Tag: V7_3_0a1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=57a61b16514ef4f5160bfa115a2dc3e2c3105ede;p=modules%2Fjobmanager.git Redesign two wizard pages as UI files with QT designer to facilitate further evolutions --- diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 646d253..2152d41 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -27,6 +27,9 @@ #include #include +#include +#include + #ifdef WNT #undef ERROR #endif @@ -72,12 +75,12 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO _job_name_page = new BL::JobNamePage(this, _jobs_manager); setPage(Page_JobName, _job_name_page); - setPage(Page_BatchParameters, new BL::BatchParametersPage(this, salome_services)); + setPage(Page_BatchParameters, new BL::BatchParametersPage(this)); // For COORM setPage(Page_COORM_BatchParameters, new BL::COORM_BatchParametersPage(this, salome_services)); - setPage(Page_Files, new BL::FilesPage(this)); + setPage(Page_Files, new BL::FilesPage(this, salome_services)); setPage(Page_Resource, new BL::ResourcePage(this, salome_services)); setPage(Page_Conclusion, new BL::ConclusionPage(this)); @@ -640,127 +643,30 @@ BL::CommandMainPage::nextId() const return BL::CreateJobWizard::Page_Resource; } -BL::BatchParametersPage::BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services) -: QWizardPage(parent) +BL::BatchParametersPage::BatchParametersPage(QWidget * parent) +: QWizardPage(parent), + ui(new Ui::ResourceRequirementsWizardPage) { - setTitle("Enter Batch Parameters"); - resource_choosed = ""; - - _salome_services = salome_services; - - QLabel *label = new QLabel("In this step you define the parameters of your job"); - label->setWordWrap(true); - QVBoxLayout * main_layout = new QVBoxLayout; - main_layout->addWidget(label); - - // batch_directory - QLabel * label_directory = new QLabel("Remote work directory: "); - QLineEdit * line_directory = new QLineEdit(this); - registerField("batch_directory", line_directory); - - // exected during time - QLabel * label_duration = new QLabel("Time limit: "); - QSpinBox * spin_duration_hour = new QSpinBox(this); - QLabel * label_duration_hour = new QLabel("Hours"); - spin_duration_hour->setMinimum(0); - spin_duration_hour->setMaximum(1000000); - registerField("duration_hour", spin_duration_hour); - QSpinBox * spin_duration_min = new QSpinBox(this); - QLabel * label_duration_min = new QLabel("Minutes"); - spin_duration_min->setMinimum(0); - spin_duration_min->setMaximum(59); - registerField("duration_min", spin_duration_min); - - // memory - QLabel * label_memory = new QLabel("Memory per node: "); - QSpinBox * spin_memory = new QSpinBox(this); - spin_memory->setMinimum(0); - spin_memory->setMaximum(1000000); - registerField("mem_value", spin_memory); - QComboBox * combo_memory = new QComboBox(this); - combo_memory->addItem("MB"); - combo_memory->addItem("GB"); - combo_memory->setCurrentIndex(1); - registerField("mem_type", combo_memory); - - // proc - QLabel * label_proc = new QLabel("Number of cores: "); - QSpinBox * spin_proc = new QSpinBox(this); - spin_proc->setMinimum(1); - spin_proc->setMaximum(1000000); - registerField("proc_value", spin_proc); - - // exclusive - QLabel * label_exclusive = new QLabel("Exclusive (do not share nodes with other jobs): "); - QCheckBox * check_exclusive = new QCheckBox(this); - check_exclusive->setChecked(true); - registerField("exclusive", check_exclusive); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(label_directory, 0, 0); - layout->addWidget(line_directory, 0, 1, 1, -1); - layout->addWidget(label_duration, 1, 0); - layout->addWidget(spin_duration_hour, 1, 1); - layout->addWidget(label_duration_hour, 1, 2); - layout->addWidget(spin_duration_min, 1, 3); - layout->addWidget(label_duration_min, 1, 4); - layout->addWidget(label_memory, 2, 0); - layout->addWidget(spin_memory, 2, 1); - layout->addWidget(combo_memory, 2, 2); - layout->addWidget(label_proc, 3, 0); - layout->addWidget(spin_proc, 3, 1); - layout->addWidget(label_exclusive, 4, 0); - layout->addWidget(check_exclusive, 4, 1); - - main_layout->insertLayout(-1, layout); - - setLayout(main_layout); + ui->setupUi(this); + + registerField("duration_hour", ui->spin_duration_hour); + registerField("duration_min", ui->spin_duration_min); + registerField("mem_value", ui->spin_memory); + registerField("mem_type", ui->combo_memory); + registerField("proc_value", ui->spin_proc); + registerField("exclusive", ui->check_exclusive); }; BL::BatchParametersPage::~BatchParametersPage() -{} - -void BL::BatchParametersPage::cleanupPage() {} - -void -BL::BatchParametersPage::initializePage() { - QString f_resource_choosed = field("resource_choosed").toString(); - if (f_resource_choosed != resource_choosed) - { - resource_choosed = f_resource_choosed; - // If choosed resource has a working_directory set - // Generates a default remote working directory - BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toStdString()); - QString res_work_dir = resource_descr.working_directory.c_str(); - if (res_work_dir != "") - { - time_t rawtime; - time(&rawtime); - std::string launch_date = ctime(&rawtime); - for (int i = 0; i < launch_date.size(); i++) - if (launch_date[i] == '/' || - launch_date[i] == '-' || - launch_date[i] == ':' || - launch_date[i] == ' ') - launch_date[i] = '_'; - launch_date.erase(--launch_date.end()); // Last caracter is a \n - QString date = launch_date.c_str(); - setField("batch_directory", res_work_dir + "/" + date); - } - } + delete ui; } +void BL::BatchParametersPage::cleanupPage() {} + bool BL::BatchParametersPage::validatePage() { - QString batch_directory = field("batch_directory").toString(); - if (batch_directory == "") - { - QMessageBox::warning(NULL, "Batch Directory Error", "Please enter a batch directory"); - return false; - } - int mem = field("mem_value").toInt(); if (mem == 0) { @@ -893,96 +799,93 @@ BL::COORM_BatchParametersPage::initializePage() } } -BL::FilesPage::FilesPage(BL::CreateJobWizard * parent) -: QWizardPage(parent) +BL::FilesPage::FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services) +: QWizardPage(parent), + ui(new Ui::FilesWizardPage) { - setTitle("Enter Input and Output Files"); + ui->setupUi(this); - QLabel * main_label = new QLabel("In this step you define input and output files of your job"); - main_label->setWordWrap(true); + resource_choosed = ""; + _salome_services = salome_services; + + connect(ui->add_input_files_button, SIGNAL(clicked()), this, SLOT(choose_input_files())); + connect(ui->remove_input_files_button, SIGNAL(clicked()), this, SLOT(remove_input_files())); + connect(ui->input_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(input_itemSelectionChanged())); + connect(ui->add_output_files_button, SIGNAL(clicked()), this, SLOT(add_output_file())); + connect(ui->remove_output_files_button, SIGNAL(clicked()), this, SLOT(remove_output_files())); + connect(ui->output_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(output_itemSelectionChanged())); + connect(ui->button_choose_result_dir, SIGNAL(clicked()), this, SLOT(choose_local_directory())); - // input_files - QGroupBox * input_group_box = new QGroupBox("Input Files"); - _input_files_button = new QPushButton("Add input files"); - _input_files_button->show(); - connect(_input_files_button, SIGNAL(clicked()), this, SLOT(choose_input_files())); - _remove_input_files_button = new QPushButton("Remove input files"); - _remove_input_files_button->show(); - _remove_input_files_button->setEnabled(false); - connect(_remove_input_files_button, SIGNAL(clicked()), this, SLOT(remove_input_files())); - _input_files_list = new QListWidget(); - _input_files_list->setSelectionMode(QAbstractItemView::MultiSelection); - connect(_input_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(input_itemSelectionChanged())); - - QGridLayout * input_box = new QGridLayout; - input_box->addWidget(_input_files_button, 0, 0); - input_box->addWidget(_remove_input_files_button, 0, 1); - input_box->addWidget(_input_files_list, 1, 0, 1, -1); - input_group_box->setLayout(input_box); - - // output_files - QGroupBox * output_group_box = new QGroupBox("Output Files"); - _output_files_button = new QPushButton("Add output file"); - _output_files_button->show(); - connect(_output_files_button, SIGNAL(clicked()), this, SLOT(add_output_file())); - _remove_output_files_button = new QPushButton("Remove output files"); - _remove_output_files_button->show(); - _remove_output_files_button->setEnabled(false); - connect(_remove_output_files_button, SIGNAL(clicked()), this, SLOT(remove_output_files())); - _output_files_list = new QListWidget(); - _output_files_list->setSelectionMode(QAbstractItemView::MultiSelection); - _output_files_list->setEditTriggers(QAbstractItemView::DoubleClicked); - connect(_output_files_list, SIGNAL(itemSelectionChanged()), this, SLOT(output_itemSelectionChanged())); - - // Results Directory - QPushButton * button_result = new QPushButton("Local Result directory"); - connect(button_result, SIGNAL(clicked()), this, SLOT(choose_local_directory())); - _result_directory = new QLineEdit(this); + registerField("batch_directory", ui->line_remote_working_dir); + registerField("result_directory", ui->line_result_dir); // Default result directory is home directory (if we found it) // First try -> HOME #ifdef WNT - _result_directory->setText(getenv("HOME")); + ui->line_result_dir->setText(getenv("HOME")); #else if (getenv("HOME")) - _result_directory->setText(getenv("HOME")); + ui->line_result_dir->setText(getenv("HOME")); else { // Second try -> getpwuid struct passwd * pass_struct = getpwuid(getuid()); if (pass_struct) - _result_directory->setText(pass_struct->pw_dir); + ui->line_result_dir->setText(pass_struct->pw_dir); } #endif - registerField("result_directory", _result_directory); - - QGridLayout * output_box = new QGridLayout; - output_box->addWidget(_output_files_button, 0, 0); - output_box->addWidget(_remove_output_files_button, 0, 1); - output_box->addWidget(_output_files_list, 1, 0, 1, -1); - output_box->addWidget(button_result, 2, 0); - output_box->addWidget(_result_directory, 2, 1, 1, -1); - output_group_box->setLayout(output_box); - - QVBoxLayout * main_layout = new QVBoxLayout; - main_layout->addWidget(main_label); - main_layout->addWidget(input_group_box); - main_layout->addWidget(output_group_box); - setLayout(main_layout); - parent->setFilesList(_input_files_list, _output_files_list); + parent->setFilesList(ui->input_files_list, ui->output_files_list); }; BL::FilesPage::~FilesPage() -{} +{ + delete ui; +} + +void +BL::FilesPage::initializePage() +{ + QString f_resource_choosed = field("resource_choosed").toString(); + if (f_resource_choosed != resource_choosed) + { + resource_choosed = f_resource_choosed; + // If choosed resource has a working_directory set + // Generates a default remote working directory + BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toStdString()); + QString res_work_dir = resource_descr.working_directory.c_str(); + if (res_work_dir != "") + { + time_t rawtime; + time(&rawtime); + std::string launch_date = ctime(&rawtime); + for (int i = 0; i < launch_date.size(); i++) + if (launch_date[i] == '/' || + launch_date[i] == '-' || + launch_date[i] == ':' || + launch_date[i] == ' ') + launch_date[i] = '_'; + launch_date.erase(--launch_date.end()); // Last caracter is a \n + QString date = launch_date.c_str(); + setField("batch_directory", res_work_dir + "/" + date); + } + } +} bool BL::FilesPage::validatePage() { + QString batch_directory = field("batch_directory").toString(); + if (batch_directory == "") + { + QMessageBox::warning(NULL, "Batch Directory Error", "Please enter a batch directory"); + return false; + } + QString result_directory = field("result_directory").toString(); - for (int i = 0; i < _output_files_list->count(); ++i) + for (int i = 0; i < ui->output_files_list->count(); ++i) { - QListWidgetItem * item = _output_files_list->item(i); + QListWidgetItem * item = ui->output_files_list->item(i); if (item->text() == "TO EDIT!") { QMessageBox::warning(NULL, "Ouput Files Error", "Some output files are not defined !"); @@ -990,7 +893,7 @@ BL::FilesPage::validatePage() } } - if (result_directory == "" && _output_files_list->count() != 0) + if (result_directory == "" && ui->output_files_list->count() != 0) { QMessageBox::warning(NULL, "Result Directory Error", "Please enter a result directory or remove output files"); return false; @@ -1007,8 +910,8 @@ BL::FilesPage::choose_input_files() tr("All Files (*)")); for (int i = 0; i < files.size(); ++i) { - if (_input_files_list->findItems(files.at(i), Qt::MatchFixedString).size() == 0) - _input_files_list->addItem(files.at(i)); + if (ui->input_files_list->findItems(files.at(i), Qt::MatchFixedString).size() == 0) + ui->input_files_list->addItem(files.at(i)); } } @@ -1021,27 +924,27 @@ BL::FilesPage::choose_local_directory() | QFileDialog::DontResolveSymlinks); if (dir != "") - _result_directory->setText(dir); + ui->line_result_dir->setText(dir); } void BL::FilesPage::remove_input_files() { - QList list = _input_files_list->selectedItems(); + QList list = ui->input_files_list->selectedItems(); for (int i = 0; i < list.size(); ++i) { - int row = _input_files_list->row( list.at(i) ); - delete _input_files_list->takeItem(row); + int row = ui->input_files_list->row( list.at(i) ); + delete ui->input_files_list->takeItem(row); } } void BL::FilesPage::input_itemSelectionChanged() { - if (_input_files_list->selectedItems().size() > 0) - _remove_input_files_button->setEnabled(true); + if (ui->input_files_list->selectedItems().size() > 0) + ui->remove_input_files_button->setEnabled(true); else - _remove_input_files_button->setEnabled(false); + ui->remove_input_files_button->setEnabled(false); } void @@ -1049,27 +952,27 @@ BL::FilesPage::add_output_file() { QListWidgetItem * new_item = new QListWidgetItem("TO EDIT!"); new_item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled); - _output_files_list->addItem(new_item); + ui->output_files_list->addItem(new_item); } void BL::FilesPage::remove_output_files() { - QList list = _output_files_list->selectedItems(); + QList list = ui->output_files_list->selectedItems(); for (int i = 0; i < list.size(); ++i) { - int row = _output_files_list->row( list.at(i) ); - delete _output_files_list->takeItem(row); + int row = ui->output_files_list->row( list.at(i) ); + delete ui->output_files_list->takeItem(row); } } void BL::FilesPage::output_itemSelectionChanged() { - if (_output_files_list->selectedItems().size() > 0) - _remove_output_files_button->setEnabled(true); + if (ui->output_files_list->selectedItems().size() > 0) + ui->remove_output_files_button->setEnabled(true); else - _remove_output_files_button->setEnabled(false); + ui->remove_output_files_button->setEnabled(false); } int diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index cbdcdbe..b1f5c67 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -29,6 +29,11 @@ #include #include +namespace Ui { + class ResourceRequirementsWizardPage; + class FilesWizardPage; +} + namespace BL{ class JobsManager_QT; @@ -149,17 +154,15 @@ namespace BL{ Q_OBJECT public: - BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services); + BatchParametersPage(QWidget * parent); virtual ~BatchParametersPage(); virtual bool validatePage(); virtual int nextId() const; virtual void cleanupPage(); - virtual void initializePage(); private: - BL::SALOMEServices * _salome_services; - QString resource_choosed; + Ui::ResourceRequirementsWizardPage * ui; }; // For COORM @@ -190,9 +193,10 @@ namespace BL{ Q_OBJECT public: - FilesPage(BL::CreateJobWizard * parent); + FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services); virtual ~FilesPage(); + virtual void initializePage(); virtual int nextId() const; virtual bool validatePage(); virtual void cleanupPage() {} @@ -208,14 +212,9 @@ namespace BL{ void output_itemSelectionChanged(); private: - QPushButton * _input_files_button; - QPushButton * _remove_input_files_button; - QListWidget * _input_files_list; - QLineEdit * _result_directory; - - QPushButton * _output_files_button; - QPushButton * _remove_output_files_button; - QListWidget * _output_files_list; + Ui::FilesWizardPage * ui; + BL::SALOMEServices * _salome_services; + QString resource_choosed; }; class ResourcePage: public QWizardPage diff --git a/src/genericgui/FilesWizardPage.ui b/src/genericgui/FilesWizardPage.ui new file mode 100644 index 0000000..fa76f59 --- /dev/null +++ b/src/genericgui/FilesWizardPage.ui @@ -0,0 +1,198 @@ + + + FilesWizardPage + + + + 0 + 0 + 602 + 480 + + + + WizardPage + + + Files and Directories + + + + + + Input Files + + + + + + QAbstractItemView::MultiSelection + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + false + + + - + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Output Files + + + + + + QAbstractItemView::MultiSelection + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + false + + + - + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Directories + + + + + + + + Remote Working Directory: + + + + + + + Local Result Directory: + + + + + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + diff --git a/src/genericgui/Makefile.am b/src/genericgui/Makefile.am index ba91fd2..666f79b 100644 --- a/src/genericgui/Makefile.am +++ b/src/genericgui/Makefile.am @@ -41,7 +41,15 @@ MOC_FILES = BL_GenericGui_moc.cxx BL_JobsTable_moc.cxx BL_Summary_moc.cxx JM_ResourceCatalog_moc.cxx \ JM_SalomeResource_moc.cxx JM_EditSalomeResource_moc.cxx -nodist_libBL_GenericGui_la_SOURCES = $(MOC_FILES) +UIC_FILES = ui_ResourceRequirementsWizardPage.hxx \ + ui_FilesWizardPage.hxx + +nodist_libBL_GenericGui_la_SOURCES = $(MOC_FILES) $(UIC_FILES) + +BUILT_SOURCES = $(MOC_FILES) $(UIC_FILES) + +# extra distributed files +EXTRA_DIST = $(UIC_FILES:ui_%.hxx=%.ui) libBL_GenericGui_la_CXXFLAGS = $(qt4_cppflags) \ -I$(top_srcdir)/src/bases \ @@ -65,8 +73,12 @@ SUFFIXES = .hxx _moc.cxx .qrc _qrc.cxx .qrc_qrc.cxx : $(QT_RCC) -name $(*F) $< -o $@ +# qt forms files generation (uic) +ui_%.hxx: %.ui + $(QT_UIC) -o $@ $< + clean-local-qt : - rm -f *_moc.cxx *_qrc.cxx ui_*.h + rm -f *_moc.cxx *_qrc.cxx ui_*.hxx clean-local: clean-local-qt diff --git a/src/genericgui/ResourceRequirementsWizardPage.ui b/src/genericgui/ResourceRequirementsWizardPage.ui new file mode 100644 index 0000000..bca7c53 --- /dev/null +++ b/src/genericgui/ResourceRequirementsWizardPage.ui @@ -0,0 +1,315 @@ + + + ResourceRequirementsWizardPage + + + + 0 + 0 + 512 + 325 + + + + WizardPage + + + Resource Requirements and Limits + + + + + + Computing Resources + + + + + + + + Number of cores: + + + + + + + 1 + + + 1000000000 + + + + + + + + + Exclusive (do not share nodes with other jobs) + + + true + + + + + + + + + + Time + + + + + + + + Time limit: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + false + + + Default + + + timeButtonGroup + + + + + + + + + + + + true + + + timeButtonGroup + + + + + + + 0 + + + 1000000000 + + + 0 + + + + + + + Hour(s) + + + + + + + 0 + + + 59 + + + 10 + + + + + + + Minute(s) + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Memory + + + + + + + + Memory limit / required: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + false + + + Default + + + memoryButtonGroup + + + + + + + + + + + + true + + + memoryButtonGroup + + + + + + + 1 + + + 1000000000 + + + 1 + + + + + + + 1 + + + + MB + + + + + GB + + + + + + + + false + + + + per node + + + + + per core + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + +