From 929705eabaf2333a1287a56129cb34a5e2f75e75 Mon Sep 17 00:00:00 2001 From: ribes Date: Fri, 21 May 2010 10:12:20 +0000 Subject: [PATCH] - Now you can close the view of JOBMANAGER --- src/genericgui/BL_GenericGui.cxx | 102 +++++++++++++------------ src/genericgui/BL_GenericGui.hxx | 3 + src/salomegui/BL_SalomeGui.cxx | 16 +++- src/wrappers/BL_MainWindows_SALOME.cxx | 36 ++++++++- src/wrappers/BL_MainWindows_SALOME.hxx | 3 + 5 files changed, 109 insertions(+), 51 deletions(-) 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++; } -- 2.39.2