From: vsr Date: Thu, 10 Jun 2010 11:05:39 +0000 (+0000) Subject: Merge from V5_1_main 10/06/2010 X-Git-Tag: TRIPOLI_302 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d73d7c9bb6634219bace51c72140924903f84618;p=modules%2Fjobmanager.git Merge from V5_1_main 10/06/2010 --- diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index 97da5a6..a5a5b34 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -19,6 +19,10 @@ #include "BL_CreateJobWizard.hxx" #include "BL_JobsManager_QT.hxx" +#include +#include +#include +#include BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services) { @@ -676,6 +680,17 @@ BL::FilesPage::FilesPage(BL::CreateJobWizard * parent) QPushButton * button_result = new QPushButton("Local Result directory"); connect(button_result, SIGNAL(clicked()), this, SLOT(choose_local_directory())); _result_directory = new QLineEdit(this); + + // Default result directory is home directory (if we found it) + // First try -> HOME + if (getenv("HOME")) + _result_directory->setText(getenv("HOME")); + else { + // Second try -> getpwuid + struct passwd * pass_struct = getpwuid(getuid()); + if (pass_struct) + _result_directory->setText(pass_struct->pw_dir); + } registerField("result_directory", _result_directory); QGridLayout * output_box = new QGridLayout; diff --git a/src/genericgui/BL_GenericGui.cxx b/src/genericgui/BL_GenericGui.cxx index fde75e3..7050d71 100644 --- a/src/genericgui/BL_GenericGui.cxx +++ b/src/genericgui/BL_GenericGui.cxx @@ -28,21 +28,70 @@ BL::GenericGui::GenericGui(BL::MainWindows_Wrap * wrapper) : QObject(wrapper->ge _job_name_selected = ""; _dock_parent = _wrapper->getDockParent(); - _tab_parent = _wrapper->getTabParent(); _salome_services = new BL::SALOMEServices(); if (_salome_services->initNS() == false) DEBMSG("WARNING !!!!! SALOME IS NOT REACHABLE !!!!"); +} + +BL::GenericGui::~GenericGui() +{ + DEBTRACE("Destroying BL::GenericGui"); + delete _salome_services; +} + +void +BL::GenericGui::createDockWidgets() +{ + DEBTRACE("createDockWidgets BL::GenericGui"); _jobs_manager = new BL::JobsManager_QT(_dock_parent, this, _salome_services); _model_manager = new BL::QModelManager(this, _jobs_manager); - _model = _model_manager->getModel(); - // ---- Adding different GUI parts + /* Summary */ + _dw_summary = new QDockWidget(_dock_parent); + _dw_summary->setWindowTitle("Summary"); + _summary = new BL::Summary(_dw_summary, _jobs_manager); + _summary->setModel(_model); + QScrollArea * scroll_widget_summary = new QScrollArea(_dw_summary); + scroll_widget_summary->setWidget(_summary); + scroll_widget_summary->setWidgetResizable(true); + _dw_summary->setWidget(scroll_widget_summary); + /* ResourceCatalog */ + _dw_resource_catalog = new QDockWidget(_dock_parent); + _dw_resource_catalog->setWindowTitle("Resource Catalog"); + _resource_catalog = new JM::ResourceCatalog(_dw_resource_catalog, _salome_services); + QScrollArea * scroll_widget_resource = new QScrollArea(_dw_resource_catalog); + scroll_widget_resource->setWidget(_resource_catalog); + scroll_widget_resource->setWidgetResizable(true); + _dw_resource_catalog->setWidget(scroll_widget_resource); - /* Tab Central Widget */ + /* Main Dock Window */ + _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _jobs_manager); + _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_summary); + _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_resource_catalog); + _dock_parent->splitDockWidget(_jobs_manager, _dw_summary, Qt::Vertical); + _dock_parent->tabifyDockWidget(_dw_summary, _dw_resource_catalog); + + /* Signals and Slots */ + // JobsManager -> Model + connect(_jobs_manager, SIGNAL(new_job_added(QString)), _model_manager, SLOT(new_job_added(QString))); + connect(_jobs_manager, SIGNAL(job_state_changed(QString)), _model_manager, SLOT(job_state_changed(QString))); + connect(_jobs_manager, SIGNAL(job_state_changed(QString)), this, SLOT(job_state_changed(QString))); + // Model -> summary + connect(_model, SIGNAL(rowsInserted(QModelIndex, int, int)), _summary, SLOT(rowsInserted(QModelIndex, int, int))); + connect(_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), _summary, SLOT(rowsRemoved(QModelIndex, int, int))); + connect(_model, SIGNAL(itemChanged(QStandardItem*)), _summary, SLOT(itemChanged(QStandardItem*))); +} + +void +BL::GenericGui::createCentralWidget() +{ + DEBTRACE("createCentralWidget BL::GenericGui"); + _tab_parent = _wrapper->getTabParent(); + /* Tab Central Widget */ /* Buttons */ _buttons = new BL::Buttons(_tab_parent); _buttons->setCreateButtonSlot(this, SLOT(create_job())); @@ -78,60 +127,17 @@ BL::GenericGui::GenericGui(BL::MainWindows_Wrap * wrapper) : QObject(wrapper->ge scroll_central_widget->setWidgetResizable(true); _tab_parent->setCentralWidget(scroll_central_widget); - /* Summary */ - _dw_summary = new QDockWidget(_dock_parent); - _dw_summary->setWindowTitle("Summary"); - _summary = new BL::Summary(_dw_summary, _jobs_manager); - _summary->setModel(_model); - QScrollArea * scroll_widget_summary = new QScrollArea(_dw_summary); - scroll_widget_summary->setWidget(_summary); - scroll_widget_summary->setWidgetResizable(true); - _dw_summary->setWidget(scroll_widget_summary); - - /* ResourceCatalog */ - _dw_resource_catalog = new QDockWidget(_dock_parent); - _dw_resource_catalog->setWindowTitle("Resource Catalog"); - _resource_catalog = new JM::ResourceCatalog(_dw_resource_catalog, _salome_services); - QScrollArea * scroll_widget_resource = new QScrollArea(_dw_resource_catalog); - scroll_widget_resource->setWidget(_resource_catalog); - scroll_widget_resource->setWidgetResizable(true); - _dw_resource_catalog->setWidget(scroll_widget_resource); - - /* Main Dock Window */ - _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _jobs_manager); - _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_summary); - _dock_parent->addDockWidget(Qt::RightDockWidgetArea, _dw_resource_catalog); - _dock_parent->splitDockWidget(_jobs_manager, _dw_summary, Qt::Vertical); - _dock_parent->tabifyDockWidget(_dw_summary, _dw_resource_catalog); - /* Signals and Slots */ - - // JobsManager -> Model - connect(_jobs_manager, SIGNAL(new_job_added(QString)), _model_manager, SLOT(new_job_added(QString))); - connect(_jobs_manager, SIGNAL(job_state_changed(QString)), _model_manager, SLOT(job_state_changed(QString))); - connect(_jobs_manager, SIGNAL(job_state_changed(QString)), this, SLOT(job_state_changed(QString))); - - // Model -> X - connect(_model, SIGNAL(rowsInserted(QModelIndex, int, int)), _summary, SLOT(rowsInserted(QModelIndex, int, int))); - connect(_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), _summary, SLOT(rowsRemoved(QModelIndex, int, int))); - connect(_model, SIGNAL(itemChanged(QStandardItem*)), _summary, SLOT(itemChanged(QStandardItem*))); + // 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(clicked(QModelIndex)), _model_manager, SLOT(job_selected(QModelIndex))); - // Delete Job -> X connect(this, SIGNAL(job_deleted(QString)), _job_tab, SLOT(reset(QString))); } -BL::GenericGui::~GenericGui() -{ - DEBTRACE("Destroying BL::GenericGui"); - delete _salome_services; -} - void BL::GenericGui::deleteDockWidget() { diff --git a/src/genericgui/BL_GenericGui.hxx b/src/genericgui/BL_GenericGui.hxx index 822538d..f6492bb 100644 --- a/src/genericgui/BL_GenericGui.hxx +++ b/src/genericgui/BL_GenericGui.hxx @@ -46,6 +46,9 @@ namespace BL GenericGui(BL::MainWindows_Wrap * wrapper); virtual ~GenericGui(); + void createDockWidgets(); + void createCentralWidget(); + void showDockWidgets(bool isVisible); void createActions(); void createMenus(); diff --git a/src/salomegui/BL_SalomeGui.cxx b/src/salomegui/BL_SalomeGui.cxx index 7528758..4d23041 100644 --- a/src/salomegui/BL_SalomeGui.cxx +++ b/src/salomegui/BL_SalomeGui.cxx @@ -62,15 +62,29 @@ BL::SalomeGui::activateModule(SUIT_Study* theStudy) if (!_gengui) { BL::MainWindows_SALOME::initialize(getApp()); + BL::MainWindows_SALOME::createView(); _gengui = new BL::GenericGui(this); + + _gengui->createDockWidgets(); + _gengui->createCentralWidget(); _gengui->createActions(); _gengui->createMenus(); _gengui->updateButtonsStates(); } + else + { + // Test main view + if (!BL::MainWindows_SALOME::restoreViewFocus()) + { + // We need to recreate QT objects and the view + BL::MainWindows_SALOME::createView(); + _gengui->createCentralWidget(); + } + } - bool bOk = SalomeApp_Module::activateModule(theStudy); setMenuShown(true); _gengui->showDockWidgets(true); + bool bOk = SalomeApp_Module::activateModule(theStudy); return bOk; } diff --git a/src/wrappers/BL_MainWindows_SALOME.cxx b/src/wrappers/BL_MainWindows_SALOME.cxx index 29c73cb..ccedfe5 100644 --- a/src/wrappers/BL_MainWindows_SALOME.cxx +++ b/src/wrappers/BL_MainWindows_SALOME.cxx @@ -24,6 +24,7 @@ BL::MainWindows_SALOME::MainWindows_SALOME(const QString & module_name) : { DEBTRACE("Creating BL::MainWindows_SALOME"); _actionId = 190; + _currentViewId = -1; } void @@ -31,14 +32,45 @@ BL::MainWindows_SALOME::initialize(SalomeApp_Application * appli) { DEBTRACE("Initialize BL::MainWindows_SALOME"); BL_ASSERT(appli); - _appli = appli; +} + + +void +BL::MainWindows_SALOME::createView() +{ + DEBTRACE("BL::MainWindows_SALOME CreateView"); _svm = new SUIT_ViewManager(_appli->activeStudy(), _appli->desktop(), new SUIT_ViewModel()); _appli->addViewManager(_svm); _viewWin = _svm->createViewWindow(); - + _currentViewId = _viewWin->getId(); if (_viewWin && _appli->desktop()) _viewWin->resize((int)(_appli->desktop()->width() * 0.6), (int)(_appli->desktop()->height() * 0.6 )); + DEBTRACE("End of BL::MainWindows_SALOME CreateView"); +} + +bool +BL::MainWindows_SALOME::restoreViewFocus() +{ + bool result = false; + SUIT_ViewWindow* resWnd = 0; + + // Search window + QList wndlist = _appli->desktop()->windows(); + SUIT_ViewWindow* wnd; + for (int i = 0; i < wndlist.size(); ++i) + { + wnd = wndlist.at(i); + if (_currentViewId == wnd->getId()) {resWnd = wnd;} + if (resWnd) {break;} + } + + if (resWnd) + { + wnd->setFocus(); + result = true; + } + return result; } QString diff --git a/src/wrappers/BL_MainWindows_SALOME.hxx b/src/wrappers/BL_MainWindows_SALOME.hxx index 3be325f..627c20d 100644 --- a/src/wrappers/BL_MainWindows_SALOME.hxx +++ b/src/wrappers/BL_MainWindows_SALOME.hxx @@ -64,12 +64,15 @@ namespace BL // Usefull methods virtual void initialize(SalomeApp_Application * appli); + bool restoreViewFocus(); + void createView(); protected: SalomeApp_Application * _appli; SalomeApp_Module * _module; SUIT_ViewManager * _svm; SUIT_ViewWindow * _viewWin; + int _currentViewId; int _actionId; int getActionId() { return _actionId++; }