From 6af2fa1ec27fd01b8f0c208ed32ece7f736ccfc9 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 1 Sep 2015 09:37:00 +0300 Subject: [PATCH] the new virtual function to allow the module to abort the active operations on load/save --- src/CAM/CAM_Application.cxx | 11 +++++++++++ src/CAM/CAM_Application.h | 2 ++ src/CAM/CAM_Module.cxx | 6 ++++++ src/CAM/CAM_Module.h | 2 ++ src/STD/STD_Application.cxx | 16 ++++++++++++++++ src/STD/STD_Application.h | 2 ++ 6 files changed, 39 insertions(+) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index e45d4a8cd..1f4754b32 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -863,3 +863,14 @@ CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() } return info; } + +bool CAM_Application::abortAllOperations() +{ + bool isNextOperationAllowed = true; + for( QList::const_iterator it = myModules.begin(); it != myModules.end(); ++it ) + { + if( !(*it)->abortAllOperations() ) + isNextOperationAllowed = false; + } + return isNextOperationAllowed; +} diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index d25f4d4c2..5944e55d3 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -93,6 +93,8 @@ protected: static QString moduleLibrary( const QString&, const bool = true ); + virtual bool abortAllOperations(); + private: void readModuleList(); diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 5d7d569de..d3a0ddaf1 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -1134,3 +1134,9 @@ void CAM_Module::connectToStudy( CAM_Study* camStudy ) \fn void CAM_Module::updateCommandsStatus(); \brief Update menu/toolbar actions. */ + + +bool CAM_Module::abortAllOperations() +{ + return true; +} diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index 74a2b6e75..952f18571 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -145,6 +145,8 @@ protected: // after activate/deactivate modules QMap, QKeySequence> myActionShortcutMap; //!< copy actions shortcut map + virtual bool abortAllOperations(); + private: CAM_Application* myApp; //!< parent application object QString myName; //!< module title (user name) diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index dee6fd199..96f13ac18 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -324,6 +324,10 @@ void STD_Application::onOpenDoc() /*! \retval true, if document was opened successful, else false.*/ bool STD_Application::onOpenDoc( const QString& aName ) { + bool isNextOperationAllowed = abortAllOperations(); + if( !isNextOperationAllowed ) + return false; + QApplication::setOverrideCursor( Qt::WaitCursor ); bool res = openAction( openChoice( aName ), aName ); @@ -558,6 +562,10 @@ void STD_Application::onSaveDoc() if ( !activeStudy() ) return; + bool isNextOperationAllowed = abortAllOperations(); + if( !isNextOperationAllowed ) + return; + bool isOk = false; if ( activeStudy()->isSaved() ) { @@ -593,6 +601,10 @@ bool STD_Application::onSaveAsDoc() if ( !study ) return false; + bool isNextOperationAllowed = abortAllOperations(); + if( !isNextOperationAllowed ) + return false; + bool isOk = false; while ( !isOk ) { @@ -1007,3 +1019,7 @@ int STD_Application::viewManagerId( const SUIT_ViewManager* theManager) const return myViewMgrs.indexOf(const_cast(theManager)); } +bool STD_Application::abortAllOperations() +{ + return true; +} diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index ed3f6fed5..2b1f4653c 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -170,6 +170,8 @@ protected: virtual bool closeDoc( bool ask = true ); virtual bool closeActiveDoc( bool permanently = true ); + virtual bool abortAllOperations(); + private: ViewManagerList myViewMgrs; SUIT_ViewManager* myActiveViewMgr; -- 2.39.2