From: asl Date: Tue, 1 Sep 2015 06:37:00 +0000 (+0300) Subject: Add virtual function to allow the module to abort active operations on document loadi... X-Git-Tag: V7_7_0a1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b2087aa3c306bc98fbd5ef6344a8ab3367ae498;p=modules%2Fgui.git Add virtual function to allow the module to abort active operations on document loading/saving --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index e45d4a8cd..ed7260417 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -863,3 +863,20 @@ CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() } return info; } + +/*! + \brief Abort active operations if there are any + + Iterates through all modules and asks each of them if there are pending operations that cannot be aborted. + + \return \c false if some operation cannot be aborted +*/ +bool CAM_Application::abortAllOperations() +{ + bool aborted = true; + for ( QList::const_iterator it = myModules.begin(); it != myModules.end() && aborted; ++it ) + { + aborted = (*it)->abortAllOperations(); + } + return aborted; +} 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 557371ac0..47b3a0459 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -324,6 +324,9 @@ void STD_Application::onOpenDoc() /*! \retval true, if document was opened successful, else false.*/ bool STD_Application::onOpenDoc( const QString& aName ) { + if ( !abortAllOperations() ) + return false; + QApplication::setOverrideCursor( Qt::WaitCursor ); bool res = openAction( openChoice( aName ), aName ); @@ -564,6 +567,9 @@ void STD_Application::onSaveDoc() if ( !activeStudy() ) return; + if ( !abortAllOperations() ) + return; + bool isOk = false; if ( activeStudy()->isSaved() ) { @@ -599,6 +605,9 @@ bool STD_Application::onSaveAsDoc() if ( !study ) return false; + if ( !abortAllOperations() ) + return false; + bool isOk = false; while ( !isOk ) { @@ -1013,3 +1022,11 @@ int STD_Application::viewManagerId( const SUIT_ViewManager* theManager) const return myViewMgrs.indexOf(const_cast(theManager)); } +/*! + \brief Abort active operations if there are any + \return \c false if some operation cannot be aborted +*/ +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;