From df0637d37db940711a8404e6940eaab340359a07 Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 4 Feb 2009 21:29:44 +0000 Subject: [PATCH] PR: add a mecanism to control the view closing --- src/QxScene/QxScene_ViewManager.cxx | 25 ++++++++++++++++++++++++- src/QxScene/QxScene_ViewManager.h | 2 +- src/QxScene/QxScene_ViewModel.cxx | 9 +++------ src/QxScene/QxScene_ViewWindow.cxx | 14 +++++++++++++- src/QxScene/QxScene_ViewWindow.h | 4 ++++ 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/QxScene/QxScene_ViewManager.cxx b/src/QxScene/QxScene_ViewManager.cxx index 73a0b5427..d6846a4d9 100644 --- a/src/QxScene/QxScene_ViewManager.cxx +++ b/src/QxScene/QxScene_ViewManager.cxx @@ -20,8 +20,9 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "QxScene_ViewManager.h" +#include "QxScene_ViewWindow.h" -#define _DEVDEBUG_ +//#define _DEVDEBUG_ #include "DebTrace.hxx" /*! @@ -64,3 +65,25 @@ void QxScene_ViewManager::createView() DEBTRACE("QxScene_ViewManager::createView"); createViewWindow(); } + +/*! + * Method redefined here to allow some housekeeping before closing + * the view (delete a loded schema and everything related). + * If this is not possible, the view is not closed + */ +void QxScene_ViewManager::closeView(SUIT_ViewWindow* theView) +{ + DEBTRACE("QxScene_ViewManager::closeView"); + QxScene_ViewWindow *qxview = dynamic_cast(theView); + bool OKToClose = true; + if (!qxview) + OKToClose = true; + else + OKToClose = qxview->closeRequested(); + if (OKToClose) + { + DEBTRACE("SUIT View to close"); + SUIT_ViewManager::closeView(theView); + DEBTRACE("SUIT View closed"); + } +} diff --git a/src/QxScene/QxScene_ViewManager.h b/src/QxScene/QxScene_ViewManager.h index cf19675c7..924084c74 100644 --- a/src/QxScene/QxScene_ViewManager.h +++ b/src/QxScene/QxScene_ViewManager.h @@ -39,7 +39,7 @@ public: protected: bool insertView(SUIT_ViewWindow* theView); - + virtual void closeView(SUIT_ViewWindow* theView); public slots: void createView(); diff --git a/src/QxScene/QxScene_ViewModel.cxx b/src/QxScene/QxScene_ViewModel.cxx index 421c61dec..5d2e6755d 100644 --- a/src/QxScene/QxScene_ViewModel.cxx +++ b/src/QxScene/QxScene_ViewModel.cxx @@ -32,7 +32,7 @@ #include #include -#define _DEVDEBUG_ +//#define _DEVDEBUG_ #include "DebTrace.hxx" /*! @@ -68,10 +68,6 @@ void QxScene_Viewer::initView( QxScene_ViewWindow* view ) if ( view ) { view->initLayout(); - - /* - // test add items into the current canvas view - */ } } @@ -113,7 +109,8 @@ void QxScene_Viewer::onChangeBgColor() /*! SLOT: called when popup item "Show toolbar" is activated, shows toolbar of active view window */ -void QxScene_Viewer::onShowToolbar() { +void QxScene_Viewer::onShowToolbar() +{ QxScene_ViewWindow* aView = (QxScene_ViewWindow*)(myViewManager->getActiveView()); if ( aView ) aView->getToolBar()->show(); diff --git a/src/QxScene/QxScene_ViewWindow.cxx b/src/QxScene/QxScene_ViewWindow.cxx index f3091dec5..169694bb2 100644 --- a/src/QxScene/QxScene_ViewWindow.cxx +++ b/src/QxScene/QxScene_ViewWindow.cxx @@ -36,7 +36,7 @@ #include #include -#define _DEVDEBUG_ +//#define _DEVDEBUG_ #include "DebTrace.hxx" using namespace std; @@ -269,3 +269,15 @@ SUIT_ResourceMgr* QxScene_ViewWindow::resMgr() const return SUIT_Session::session()->resourceMgr(); } +/*! + * emits a signal to ask to close the schema associated to the window. + * A boolean in return indicates if it is OK to close. + */ +bool QxScene_ViewWindow::closeRequested() +{ + DEBTRACE("QxScene_ViewWindow::closeRequested"); + bool isClosed = false; + emit tryClose(isClosed, this); + DEBTRACE("isClosed=" << isClosed); + return isClosed; +} diff --git a/src/QxScene/QxScene_ViewWindow.h b/src/QxScene/QxScene_ViewWindow.h index c8bcc722b..dd1f8aa4e 100644 --- a/src/QxScene/QxScene_ViewWindow.h +++ b/src/QxScene/QxScene_ViewWindow.h @@ -70,6 +70,10 @@ class QXSCENE_EXPORT QxScene_ViewWindow : public SUIT_ViewWindow { QGraphicsScene* getScene() { return _scene; } void setSceneView(QGraphicsView* sceneView){ _sceneView = sceneView; } QGraphicsView* getSceneView() { return _sceneView; } + virtual bool closeRequested(); + + signals: + void tryClose(bool &isClosed, QxScene_ViewWindow* window); public slots: void onViewFitAll(); -- 2.39.2