Salome HOME
Delete key regression corrections: in previous implementation sketch entities did...
[modules/shaper.git] / src / XGUI / XGUI_ErrorMgr.cpp
index afacb5d82e77cb29e1212b3a39dda5e9bdd88961..9e379850c166e734290e95753d20f16c45c29c18 100644 (file)
@@ -55,13 +55,21 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
                                       (workshop()->operationMgr()->currentOperation());
   if (aFOperation && aFOperation->feature() == theFeature) {
     QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
-    QString anError = myWorkshop->module()->getFeatureError(theFeature);
-
+    
     ModuleBase_ModelWidget* anActiveWidget = activeWidget();
-    QString aWidgetError = myWorkshop->module()->getWidgetError(anActiveWidget);
-    if (anError.isEmpty())
-      anError = aWidgetError;
-
+    bool isApplyEnabledByActiveWidget = false;
+    if (anActiveWidget)
+      isApplyEnabledByActiveWidget = anActiveWidget->getValueState() ==
+                                     ModuleBase_ModelWidget::ModifiedInPP;
+    QString anError = "";
+    QString aWidgetError = "";
+    if (!isApplyEnabledByActiveWidget) {
+      anError = myWorkshop->module()->getFeatureError(theFeature);
+      if (anActiveWidget)
+        aWidgetError = anActiveWidget->getError();
+      if (anError.isEmpty())
+        anError = aWidgetError;
+    }
     updateActionState(anOkAction, anError);
     updateToolTip(anActiveWidget, aWidgetError);
   }
@@ -70,9 +78,11 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
 void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
 {
   QString anError = myWorkshop->module()->getFeatureError(theFeature);
-  if (anError.isEmpty())
-    anError = myWorkshop->module()->getWidgetError(activeWidget());
-
+  if (anError.isEmpty()) {
+    ModuleBase_ModelWidget* anActiveWidget = activeWidget();
+    if (anActiveWidget)
+      anError = anActiveWidget->getError();
+  }
   XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
   if (workshop()->isFeatureOfNested(theFeature)) {
     QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
@@ -82,6 +92,19 @@ void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature)
   }
 }
 
+bool XGUI_ErrorMgr::isApplyEnabled() const
+{
+  bool isEnabled = false;
+  XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                      (workshop()->operationMgr()->currentOperation());
+  if (aFOperation) {
+    QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
+    isEnabled = anOkAction && anOkAction->isEnabled();
+  }
+  return isEnabled;
+}
+
 void XGUI_ErrorMgr::updateActionState(QAction* theAction, const QString& theError)
 {
   bool anEnabled = theError.isEmpty();
@@ -101,7 +124,7 @@ void XGUI_ErrorMgr::onWidgetChanged()
   if (!aModelWidget || !aModelWidget->feature().get())
     return;
 
-  QString aWidgetError = myWorkshop->module()->getWidgetError(aModelWidget);
+  QString aWidgetError = aModelWidget->getError();
   updateToolTip(aModelWidget, aWidgetError);
 }