DEBTRACE("Creating BL::GenericGui");
BL_ASSERT(wrapper);
_wrapper = wrapper;
- _row_selected = -1;
_job_name_selected = "";
_dock_parent = _wrapper->getDockParent();
/* Signals and Slots */
// Model -> JobTab
connect(_model, SIGNAL(itemChanged(QStandardItem*)), _job_tab, SLOT(itemChanged(QStandardItem*)));
+
// TableView -> X
connect(_jobs_table, SIGNAL(clicked(QModelIndex)), _job_tab, SLOT(job_selected(QModelIndex)));
connect(_jobs_table, SIGNAL(clicked(QModelIndex)), this, SLOT(job_selected(QModelIndex)));
connect(_jobs_table, SIGNAL(activated(QModelIndex)), this, SLOT(job_activated(QModelIndex)));
connect(_jobs_table, SIGNAL(activated(QModelIndex)), _job_tab, SLOT(job_activated(QModelIndex)));
- // Delete Job -> X
- connect(this, SIGNAL(job_deleted(QString)), _job_tab, SLOT(reset(QString)));
}
void
if (_dw_resource_catalog) {
_dw_resource_catalog->setVisible(isVisible);
_dw_resource_catalog->toggleViewAction()->setVisible(isVisible);
- }
+ }
}
void
BL::GenericGui::delete_job()
{
DEBTRACE("Delete Job Slot BL::GenericGui");
- int ret = QMessageBox::warning(NULL, "Delete a job", "Do you really want to delete this job ?",
- QMessageBox::Ok|QMessageBox::Cancel,
- QMessageBox::Ok);
+ int ret = QMessageBox::Cancel;
+
+ if (!_jobs_table->isMultipleSelected())
+ {
+ ret = QMessageBox::warning(NULL, "Delete a job", "Do you really want to delete job " + _job_name_selected + " ? ",
+ QMessageBox::Ok|QMessageBox::Cancel,
+ QMessageBox::Ok);
+ }
+ else
+ {
+ ret = QMessageBox::warning(NULL, "Delete jobs", "Do you really want to delete these jobs ?",
+ QMessageBox::Ok|QMessageBox::Cancel,
+ QMessageBox::Ok);
+ }
if (ret == QMessageBox::Ok)
{
delete_job_internal();
void
BL::GenericGui::delete_job_external(const QString & name)
{
+ DEBTRACE("Delete Job External");
_jobs_manager->delete_job(name);
- _model_manager->deleteJob(name);
- emit job_deleted(name);
- if (name == _job_name_selected)
+ if (!_jobs_table->selectCurrent())
{
- _row_selected = -1;
_job_name_selected = "";
updateButtonsStates();
}
void
BL::GenericGui::delete_job_internal()
{
- _jobs_manager->delete_job(_job_name_selected);
- _model_manager->deleteJob(_row_selected);
- emit job_deleted(_job_name_selected);
- _row_selected = -1;
- _job_name_selected = "";
- updateButtonsStates();
+ if (!_jobs_table->isMultipleSelected())
+ {
+ QModelIndexList selected_list = _jobs_table->getSelectedIndexes();
+ QString job_name_to_delete = _model->itemFromIndex(selected_list[0])->text();
+ DEBTRACE("Single Deleting job: " << job_name_to_delete.toStdString());
+ _jobs_manager->delete_job(job_name_to_delete);
+ if (!_jobs_table->selectCurrent())
+ {
+ _job_name_selected = "";
+ updateButtonsStates();
+ }
+ }
+ else
+ {
+ QModelIndexList selected_list = _jobs_table->getSelectedIndexes();
+ QString job_name = _model->itemFromIndex(selected_list[0])->text();
+ DEBTRACE("Multiple Deleting job: " << job_name.toStdString());
+ _jobs_manager->delete_job(job_name);
+ delete_job_internal(); // Recursive delete
+ }
}
void
BL::GenericGui::job_selected(const QModelIndex & index)
{
- DEBTRACE("BL::GenericGui::job_selected slot");
- QStandardItem * item = _model->itemFromIndex(index);
- QStandardItem * item_name = _model->item(item->row());
- _row_selected = item->row();
- _job_name_selected = item_name->text();
+ DEBTRACE("BL::GenericGui::job_selected");
+ if (index.row() >= 0)
+ {
+ QStandardItem * item = _model->itemFromIndex(index);
+ QStandardItem * item_name = _model->item(item->row());
+ _job_name_selected = item_name->text();
+ DEBTRACE("BL::GenericGui::job_selected name is " << _job_name_selected.toStdString());
+ }
+ else
+ {
+ _job_name_selected = "";
+ DEBTRACE("BL::GenericGui::job_selected - no jobs are selected");
+ }
updateButtonsStates();
}
job_selected(index);
}
-void
+void
BL::GenericGui::job_state_changed(const QString & name)
{
if (name == _job_name_selected)
updateButtonsStates();
}
+
void
BL::GenericGui::updateButtonsStates()
{
- DEBTRACE("BL::GenericGui::updateButtonsStates slot");
+ if (!_jobs_table->isMultipleSelected())
+ {
+ updateButtonsStatesSingleSelection();
+ }
+ else
+ {
+ _start_job_action->setEnabled(false);
+ _edit_clone_job_action->setEnabled(false);
+ _restart_job_action->setEnabled(false);
+ _buttons->disable_start_button();
+ _buttons->disable_edit_clone_button();
+ _buttons->disable_restart_button();
+
+ // You can always delete jobs
+ _delete_job_action->setEnabled(true);
+ _buttons->enable_delete_button();
+
+ _stop_job_action->setEnabled(false);
+ _buttons->disable_stop_button();
+
+ _get_results_job_action->setEnabled(false);
+ _buttons->disable_get_results_button();
+ }
+}
+
+void
+BL::GenericGui::updateButtonsStatesSingleSelection()
+{
+ DEBTRACE("BL::GenericGui::updateButtonsStatesSingleSelection slot");
// First case: no job selected
- if (_job_name_selected == "" and _row_selected == -1)
+ if (_job_name_selected == "")
{
_start_job_action->setEnabled(false);
_delete_job_action->setEnabled(false);
_stop_job_action->setEnabled(false);
_buttons->disable_stop_button();
}
- else if (_job_name_selected != "" and _row_selected != -1)
+ else if (_job_name_selected != "")
{
BL::Job * job = _jobs_manager->getJob(_job_name_selected.toStdString());
BL::Job::State job_state = job->getState();
void job_activated(const QModelIndex & index);
void job_state_changed(const QString & name);
void updateButtonsStates();
+ void updateButtonsStatesSingleSelection();
- signals:
- void job_deleted(QString job_name);
+ public:
+ BL::JobTab * _job_tab;
protected:
-
BL::MainWindows_Wrap * _wrapper;
BL::SALOMEServices * _salome_services;
QMainWindow * _tab_parent;
QDockWidget * _dw_summary;
QDockWidget * _dw_resource_catalog;
-
+
BL::Buttons * _buttons;
- BL::JobsTable * _jobs_table;
- BL::JobTab * _job_tab;
+ BL::JobsTable * _jobs_table;
BL::Summary * _summary;
QAction * _create_job_action;
QStandardItemModel * _model;
JM::ResourceCatalog * _resource_catalog;
- int _row_selected;
QString _job_name_selected;
};
}
void
BL::JobTab::reset(QString job_name)
{
- _job_name_label_value->setText("");
- _job_type_label_value->setText("");
- _job_state_label_value->setText("");
- _job_launcher_label_value->setText("");
- _job_resource_label_value->setText("");
- _job_nif_label_value->setText("");
- _job_nof_label_value->setText("");
- _job_bd_label_value->setText("");
- _job_rd_label_value->setText("");
- _job_mdt_label_value->setText("");
- _job_em_label_value->setText("");
- _job_nop_label_value->setText("");
- _job_jobfile_label_value->setText("");
- _job_envfile_label_value->setText("");
-
- _input_files_list->clear();
- _output_files_list->clear();
-
- _yacs_dump_state_value->setText("");
- _batch_queue_value->setText("");
- _ll_jobtype_value->setText("");
+ if (job_name == _job_name_label_value->text() || job_name == "")
+ {
+ _job_name_label_value->setText("");
+ _job_type_label_value->setText("");
+ _job_state_label_value->setText("");
+ _job_launcher_label_value->setText("");
+ _job_resource_label_value->setText("");
+ _job_nif_label_value->setText("");
+ _job_nof_label_value->setText("");
+ _job_bd_label_value->setText("");
+ _job_rd_label_value->setText("");
+ _job_mdt_label_value->setText("");
+ _job_em_label_value->setText("");
+ _job_nop_label_value->setText("");
+ _job_jobfile_label_value->setText("");
+ _job_envfile_label_value->setText("");
+
+ _input_files_list->clear();
+ _output_files_list->clear();
+
+ _yacs_dump_state_value->setText("");
+ _batch_queue_value->setText("");
+ _ll_jobtype_value->setText("");
+ }
}
DEBTRACE("Creating BL::JobsManager_QT");
_main_gui = main_gui;
setObserver(this);
- _model = NULL;
+ _model_manager = NULL;
// Widget Part
}
void
-BL::JobsManager_QT::set_model(QStandardItemModel * model)
+BL::JobsManager_QT::set_model_manager(BL::QModelManager * model_manager)
{
- _model = model;
+ _model_manager = model_manager;
}
void
BL::JobsManager_QT::delete_job(QString job_name)
{
BL::JobsManager::removeJob(job_name.toStdString());
+ _model_manager->delete_job(job_name);
+ _main_gui->_job_tab->reset(job_name);
}
void
#include "BL_Traces.hxx"
#include "BL_JobsManager.hxx"
#include "BL_CreateJobWizard.hxx"
+#include "BL_JobsManager.hxx"
+#include "BL_QModelManager.hxx"
#include <string>
void write_normal_text(const QString & text);
void write_error_text(const QString & text);
- void set_model(QStandardItemModel * model);
+ void set_model_manager(BL::QModelManager * model_manager);
protected:
void create_job_with_wizard(BL::CreateJobWizard & wizard);
QTimer * _timer;
QTextEdit * _log;
BL::GenericGui * _main_gui;
- QStandardItemModel * _model;
+ BL::QModelManager * _model_manager;
};
}
DEBTRACE("Destroying BL::JobsTable");
}
+bool
+BL::JobsTable::selectCurrent()
+{
+ QModelIndex idx = currentIndex();
+ if (idx.row() > -1)
+ if (!isMultipleSelected())
+ {
+ DEBTRACE("SELECT CURRENT ACTIVATION !!!");
+ setCurrentIndex(idx);
+ activated(idx);
+ return true;
+ }
+ return false;
+}
+
void
BL::JobsTable::currentChanged(const QModelIndex & current, const QModelIndex & previous)
{
- DEBTRACE("BL::JobsTable currentChanged");
- activated(current);
+ DEBTRACE("current changed");
+ DEBTRACE("current row: " << current.row());
+ if (current.row() > -1)
+ if (!isMultipleSelected())
+ {
+ DEBTRACE("CURRENT CHANGED ACTIVATION !!!");
+ setCurrentIndex(current);
+ activated(current);
+ }
+}
+
+bool
+BL::JobsTable::isMultipleSelected()
+{
+ QModelIndexList list_of_selected = selectedIndexes();
+ int length = list_of_selected.length();
+ length = length / model()->columnCount();
+ DEBTRACE("Number of selected rows: " << length);
+ if (length > 1)
+ return true;
+ else
+ return false;
+}
+
+QModelIndexList
+BL::JobsTable::getSelectedIndexes()
+{
+ return selectedIndexes();
}
JobsTable(QWidget *parent);
virtual ~JobsTable();
+ bool selectCurrent();
+ bool isMultipleSelected();
+ QModelIndexList getSelectedIndexes();
+
protected:
QWidget* _parent;
//
#include "BL_QModelManager.hxx"
+#include "BL_JobsManager_QT.hxx"
BL::QModelManager::QModelManager(QObject * parent, BL::JobsManager_QT * jobs_manager) : QObject(parent)
{
_jobs_manager = jobs_manager;
_model = new QStandardItemModel(this);
- jobs_manager->set_model(_model);
+ jobs_manager->set_model_manager(this);
QStringList headers;
headers << "Job Name" << "Type" << "State" << "Resource" << "Launcher Id";
_model->setHorizontalHeaderLabels(headers);
}
void
-BL::QModelManager::deleteJob(int row)
-{
- _model->removeRow(row);
-}
-
-void
-BL::QModelManager::deleteJob(const QString & name)
+BL::QModelManager::delete_job(const QString & name)
{
QList<QStandardItem *> list = _model->findItems(name);
if (list.size() != 1)
{
- DEBMSG("WARNING LIST IS NOT ONLY ONE !");
+ DEBMSG("LIST SIZE IS :" << list.size());
+ DEBMSG("FOR NAME :" << name.toStdString());
}
if (list.size() > 0)
_model->removeRow(list[0]->row());
#include <QtGui>
#include "BL_Job.hxx"
-#include "BL_JobsManager_QT.hxx"
namespace BL{
+ class JobsManager_QT;
class QModelManager: virtual public QObject
{
Q_OBJECT
QStandardItemModel * getModel();
- void deleteJob(int row);
- void deleteJob(const QString & name);
+ void delete_job(const QString & name);
public slots:
void new_job_added(const QString & name);