]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #87 abort active operations on save/open
authorsbh <sergey.belash@opencascade.com>
Fri, 12 Sep 2014 07:09:27 +0000 (11:09 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 12 Sep 2014 07:09:27 +0000 (11:09 +0400)
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 8e8babd3b923b047629ac19c94f095f31e959137..84d5f184d547f27e93dd0e7a80a74376cb3eedd5 100644 (file)
@@ -534,6 +534,13 @@ void XGUI_Workshop::saveDocument(const QString& theName, std::list<std::string>&
   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..."));
index 946e75c9d9ccc44ccb609f1a338a10765e2aec31..f129faddff2d287e58e0a0ed2d6344d9b30b2fae 100644 (file)
@@ -175,6 +175,14 @@ Q_OBJECT
   */
   void saveDocument(const QString& theName, std::list<std::string>& 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<QAction*> getModuleCommands() const;
 
+  void displayAllResults();
   void displayDocumentResults(DocumentPtr theDoc);
   void displayGroupResults(DocumentPtr theDoc, std::string theGroup);