Salome HOME
Revert "Merge branch 'Pre_2.8.0_development'"
[modules/shaper.git] / src / XGUI / XGUI_OperationMgr.cpp
index 02186143c9def04d27e45cbfa4b8ccddc40e49b3..a0a879c7aaa353aa6c05b6b2f8b705322175c9be 100644 (file)
@@ -211,12 +211,7 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
   return isStarted;
 }
 
-void XGUI_OperationMgr::onAbortAllOperations()
-{
-  abortAllOperations();
-}
-
-bool XGUI_OperationMgr::abortAllOperations(const XGUI_MessageKind& theMessageKind)
+bool XGUI_OperationMgr::abortAllOperations()
 {
   bool aResult = true;
   if(!hasOperation())
@@ -224,29 +219,18 @@ bool XGUI_OperationMgr::abortAllOperations(const XGUI_MessageKind& theMessageKin
 
   if (operationsCount() == 1) {
     ModuleBase_Operation* aCurrentOperation = currentOperation();
-    if (canStopOperation(aCurrentOperation, theMessageKind)) {
+    if (canStopOperation(aCurrentOperation)) {
       abortOperation(aCurrentOperation);
     }
     else
       aResult = false;
   }
   else {
-    if (theMessageKind == XGUI_AbortOperationMessage) {
-      aResult = QMessageBox::question(qApp->activeWindow(),
-                                      tr("Abort operation"),
-                                      tr("All active operations will be aborted."),
-                                      QMessageBox::Ok | QMessageBox::Cancel,
-                                      QMessageBox::Cancel) == QMessageBox::Ok;
-    }
-    else if (theMessageKind == XGUI_InformationMessage) {
-      QString aMessage = tr("Please validate all your active operations before saving.");
-      QMessageBox::question(qApp->activeWindow(),
-                            tr("Validate operation"),
-                            aMessage,
-                            QMessageBox::Ok,
-                            QMessageBox::Ok);
-      aResult = false; // do not perform abort
-    }
+    aResult = QMessageBox::question(qApp->activeWindow(),
+                                    tr("Abort operation"),
+                                    tr("All active operations will be aborted."),
+                                    QMessageBox::Ok | QMessageBox::Cancel,
+                                    QMessageBox::Cancel) == QMessageBox::Ok;
     while(aResult && hasOperation()) {
       abortOperation(currentOperation());
     }
@@ -260,7 +244,7 @@ bool XGUI_OperationMgr::commitAllOperations()
   while (hasOperation()) {
     ModuleBase_Operation* anOperation = currentOperation();
     if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled()) {
-      anOperationProcessed = commitOperation();
+      anOperationProcessed = onCommitOperation();
     } else {
       abortOperation(anOperation);
       anOperationProcessed = true;
@@ -314,35 +298,33 @@ void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperati
   onValidateOperation();
 }
 
-bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation,
-                                         const XGUI_OperationMgr::XGUI_MessageKind& theMessageKind)
+bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation)
 {
   //in case of nested (sketch) operation no confirmation needed
   if (isGrantedOperation(theOperation->id()))
     return true;
   if (theOperation && theOperation->isModified()) {
-    if (theMessageKind == XGUI_AbortOperationMessage) {
-      QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
-      int anAnswer = QMessageBox::question(qApp->activeWindow(),
-                                           tr("Abort operation"),
-                                           aMessage,
-                                           QMessageBox::Ok | QMessageBox::Cancel,
-                                           QMessageBox::Cancel);
-      return anAnswer == QMessageBox::Ok;
-    }
-    else if (theMessageKind == XGUI_InformationMessage) {
-      QString aMessage = tr("Please validate your %1 before saving.").arg(theOperation->id());
-      QMessageBox::question(qApp->activeWindow(),
-                            tr("Validate operation"),
-                            aMessage,
-                            QMessageBox::Ok,
-                            QMessageBox::Ok);
-      return false;
-    }
+    QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
+    int anAnswer = QMessageBox::question(qApp->activeWindow(),
+                                         tr("Abort operation"),
+                                         aMessage,
+                                         QMessageBox::Ok | QMessageBox::Cancel,
+                                         QMessageBox::Cancel);
+    return anAnswer == QMessageBox::Ok;
   }
   return true;
 }
 
+bool XGUI_OperationMgr::commitOperation()
+{
+  //if (hasOperation() && currentOperation()->isValid()) {
+  //  onCommitOperation();
+  //  return true;
+  //}
+  //return false;
+  return onCommitOperation();
+}
+
 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
 {
   theOperation->resume();
@@ -440,7 +422,7 @@ void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
   }
 }
 
-bool XGUI_OperationMgr::commitOperation()
+bool XGUI_OperationMgr::onCommitOperation()
 {
   bool isCommitted = false;
   ModuleBase_Operation* anOperation = currentOperation();