Salome HOME
Provide reopening of transaction on resuming of Group operation
authorvsv <vsv@opencascade.com>
Thu, 6 Jun 2019 09:47:22 +0000 (12:47 +0300)
committervsv <vsv@opencascade.com>
Thu, 6 Jun 2019 09:47:22 +0000 (12:47 +0300)
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/ModuleBase/ModuleBase_OperationFeature.h
src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp

index 47344a7a37d06aa2d125d450a82c530cc7bb5768..aa2d464fcb4fda8c66cf1f089b413a279ec4cdc2 100644 (file)
@@ -59,7 +59,8 @@
 #endif
 
 ModuleBase_OperationFeature::ModuleBase_OperationFeature(const QString& theId, QObject* theParent)
-: ModuleBase_Operation(theId, theParent), myIsEditing(false), myNeedToBeAborted(false)
+: ModuleBase_Operation(theId, theParent), myIsEditing(false), myNeedToBeAborted(false),
+myRestartTransactionOnResume(false)
 {
 }
 
@@ -523,3 +524,11 @@ void ModuleBase_OperationFeature::setPropertyPanel(ModuleBase_IPropertyPanel* th
       theProp->setFocusOnOkButton();
   }
 }
+
+void ModuleBase_OperationFeature::resumeOperation()
+{
+  if (myRestartTransactionOnResume) {
+    ModelAPI_Session::get()->startOperation(this->id().toStdString(), true);
+    myRestartTransactionOnResume = false;
+  }
+}
index 4eaceb42f1c11d2b81af5eda97729d0d36844e7c..14ce24a86c0b0b79c1a35cc4f0bd70f4868727f4 100644 (file)
@@ -147,6 +147,11 @@ Q_OBJECT
   /// \return custom validity state (it is almost always true)
   bool isNeedToBeAborted() const { return myNeedToBeAborted; }
 
+  /// Call this function on launch of a nested operation
+  /// when transaction has to be reopened on resume of main operation
+  /// By default transaction is not reopened on resuming
+  void openTransactionOnResume() { myRestartTransactionOnResume = true; }
+
  public slots:
   /// Starts operation
   /// Public slot. Verifies whether operation can be started and starts operation.
@@ -174,6 +179,9 @@ Q_OBJECT
   /// Hide feature/results if they were hided on start
   virtual void stopOperation();
 
+  /// Virtual method called after operation resume (see resume() method for more description)
+  virtual void resumeOperation();
+
   /// Creates an operation new feature
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
@@ -207,6 +215,8 @@ Q_OBJECT
   /// Last current feature before editing operation. It is cashed when Edit operation is started
   /// in order to restore the document current feature on commit/abort this operation.
   FeaturePtr myPreviousCurrentFeature;
+
+  bool myRestartTransactionOnResume;
 };
 
 #endif
index a8b818e26e54807c2afdd95b37eb8e4d223e31c8..9f6136b7dfee2225131e979c9a77f264d6d5d59e 100644 (file)
@@ -107,6 +107,12 @@ ModuleBase_FilterStarter::ModuleBase_FilterStarter(const std::string& theFeature
 
 void ModuleBase_FilterStarter::onFiltersLaunch()
 {
+  ModuleBase_Operation* aParentOp = myWorkshop->currentOperation();
+  ModuleBase_OperationFeature* aFeatureOp = dynamic_cast<ModuleBase_OperationFeature*>(aParentOp);
+  if (aFeatureOp)
+    // Open transaction on filters operation finish
+    aFeatureOp->openTransactionOnResume();
+
   QWidget* aParent = parentWidget();
   ModuleBase_WidgetMultiSelector* aSelector =
     dynamic_cast<ModuleBase_WidgetMultiSelector*>(aParent);