From: sbh Date: Fri, 12 Sep 2014 07:09:27 +0000 (+0400) Subject: Issue #87 abort active operations on save/open X-Git-Tag: V_0.4.4~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d04fbe39b7c974d10bee926e63ba0f09c234834;p=modules%2Fshaper.git Issue #87 abort active operations on save/open --- diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 8e8babd3b..84d5f184d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -534,6 +534,13 @@ void XGUI_Workshop::saveDocument(const QString& theName, std::list& QApplication::restoreOverrideCursor(); } +bool XGUI_Workshop::isActiveOperationAborted() +{ + if(!myOperationMgr->hasOperation()) + return true; + return myOperationMgr->abortOperation(); +} + //****************************************************** void XGUI_Workshop::onExit() { @@ -577,7 +584,7 @@ void XGUI_Workshop::onNew() //****************************************************** void XGUI_Workshop::onOpen() { - if(!myOperationMgr->abortOperation()) + if(!isActiveOperationAborted()) return; //save current file before close if modified SessionPtr aSession = ModelAPI_Session::get(); @@ -611,14 +618,13 @@ void XGUI_Workshop::onOpen() myObjectBrowser->rebuildDataTree(); displayAllResults(); updateCommandStatus(); - myMainWindow->setCurrentDir(myCurrentDir); QApplication::restoreOverrideCursor(); } //****************************************************** bool XGUI_Workshop::onSave() { - if(!myOperationMgr->abortOperation()) + if(!isActiveOperationAborted()) return false; if (myCurrentDir.isEmpty()) { return onSaveAs(); @@ -633,7 +639,7 @@ bool XGUI_Workshop::onSave() //****************************************************** bool XGUI_Workshop::onSaveAs() { - if(!myOperationMgr->abortOperation()) + if(!isActiveOperationAborted()) return false; QFileDialog dialog(mainWindow()); dialog.setWindowTitle(tr("Select directory to save files...")); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 946e75c9d..f129faddf 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -175,6 +175,14 @@ Q_OBJECT */ void saveDocument(const QString& theName, std::list& theFileNames); + /* + * If there is an active (uncommited) operation shows a prompt to abort it + * and performs abortion if user agreed. Returns true if + * - operation aborted successfully + * - there is no active operation + */ + bool isActiveOperationAborted(); + signals: void salomeViewerSelection(); void errorOccurred(const QString&); @@ -202,9 +210,6 @@ signals: void activateLastPart(); - /// Display all results of the current document - void displayAllResults(); - protected: //Event-loop processing methods: void addFeature(const Config_FeatureMessage*); @@ -219,6 +224,7 @@ signals: QList getModuleCommands() const; + void displayAllResults(); void displayDocumentResults(DocumentPtr theDoc); void displayGroupResults(DocumentPtr theDoc, std::string theGroup);