]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1107 Tab key does not change focus to Apply in circle sketch feature.
authornds <nds@opencascade.com>
Tue, 15 Dec 2015 12:25:20 +0000 (15:25 +0300)
committernds <nds@opencascade.com>
Tue, 15 Dec 2015 12:25:20 +0000 (15:25 +0300)
A processing for the double click in the viewer.

src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/PartSet/PartSet_WidgetPoint2dDistance.cpp
src/XGUI/XGUI_ErrorMgr.cpp

index 2994da26d18154cd9885e4bf0722e3804c0e3097..343f3a086fc22649fbda698b6e7f375ee105301b 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <Events_Loop.h>
 
-#include <ModelAPI_Validator.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <ModelAPI_Session.h>
@@ -86,35 +85,6 @@ QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature)
   return ModelAPI_Tools::getFeatureError(theFeature).c_str();
 }
 
-QString ModuleBase_IModule::getWidgetError(ModuleBase_ModelWidget* theWidget)
-{
-  QString anError;
-
-  if (!theWidget || !theWidget->feature().get())
-    return anError;
-
-  std::string anAttributeID = theWidget->attributeID();
-  AttributePtr anAttribute = theWidget->feature()->attribute(anAttributeID);
-  if (!anAttribute.get())
-    return anError;
-
-  std::string aValidatorID;
-  std::string anErrorMsg;
-
-  static ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
-  if (!aValidators->validate(anAttribute, aValidatorID, anErrorMsg)) {
-    if (anErrorMsg.empty())
-      anErrorMsg = "unknown error.";
-    anErrorMsg = anAttributeID + " - " + aValidatorID + ": " + anErrorMsg;
-  }
-
-  anError = QString::fromStdString(anErrorMsg);
-  if (anError.isEmpty())
-    anError = theWidget->getValueStateError();
-
-  return anError;
-}
-
 void ModuleBase_IModule::grantedOperationIds(ModuleBase_Operation* theOperation,
                                              QStringList& theIds) const
 {
index acd6b49acef50c0332d35978bfdaf2c63b38693b..ac70964372e9bc16625a6602e8d3bb868a4fcbbf 100755 (executable)
@@ -191,11 +191,6 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   //! \return string value\r
   virtual QString getFeatureError(const FeaturePtr& theFeature);\r
 \r
-  //! Returns the widget error, get it from the attribute validator and state of the widget\r
-  //! If the feature is correct, it returns an empty value\r
-  //! \return string value\r
-  virtual QString getWidgetError(ModuleBase_ModelWidget* theWidget);\r
-\r
   /// Returns list of granted operation indices\r
   virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;\r
 \r
index 504b8ca8f95de6723a3a75d5e2fd075eca1760e0..feba11647d2650e378e7af013afc71d9075c33ff 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -80,6 +81,35 @@ QString ModuleBase_ModelWidget::getValueStateError() const
   return anError;
 }
 
+QString ModuleBase_ModelWidget::getError() const
+{
+  QString anError;
+
+  if (!feature().get())
+    return anError;
+
+  std::string anAttributeID = attributeID();
+  AttributePtr anAttribute = feature()->attribute(anAttributeID);
+  if (!anAttribute.get())
+    return anError;
+
+  std::string aValidatorID;
+  std::string anErrorMsg;
+
+  static ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+  if (!aValidators->validate(anAttribute, aValidatorID, anErrorMsg)) {
+    if (anErrorMsg.empty())
+      anErrorMsg = "unknown error.";
+    anErrorMsg = anAttributeID + " - " + aValidatorID + ": " + anErrorMsg;
+  }
+
+  anError = QString::fromStdString(anErrorMsg);
+  if (anError.isEmpty())
+    anError = getValueStateError();
+
+  return anError;
+}
+
 void ModuleBase_ModelWidget::enableFocusProcessing()
 {
   QList<QWidget*> aMyControls = getControls();
index f535b2fa7898d6d6eefc6be3b6e5086de9317579..bed820c9780ab52b3a9a1c296392c87bd291e2e2 100644 (file)
@@ -92,6 +92,11 @@ Q_OBJECT
   /// By default it returns true
   virtual bool canSetValue() const { return true; };
 
+  //! Returns the widget error, get it from the attribute validator and state of the widget
+  //! If the feature is correct, it returns an empty value
+  //! \return string value
+  QString getError() const;
+
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// \param theValues the wrapped selection values
index 71d002025927133a3f6ba51a4569b51d237c0420..562604dc05578878b5ef62c137adebad2296788b 100644 (file)
@@ -95,7 +95,10 @@ void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWn
 
   std::shared_ptr<GeomAPI_Pnt2d> aPnt = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
   setPoint(feature(), aPnt);
-  emit focusOutWidget(this);
+
+  // if the validator of the control returns false, focus should not be switched
+  if (getError().isEmpty())
+    emit focusOutWidget(this);
 }
 
 void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
index 7156e296fffbb4bb4edfef22b9d78a65dfebad6a..9e379850c166e734290e95753d20f16c45c29c18 100644 (file)
@@ -65,7 +65,8 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
     QString aWidgetError = "";
     if (!isApplyEnabledByActiveWidget) {
       anError = myWorkshop->module()->getFeatureError(theFeature);
-      aWidgetError = myWorkshop->module()->getWidgetError(anActiveWidget);
+      if (anActiveWidget)
+        aWidgetError = anActiveWidget->getError();
       if (anError.isEmpty())
         anError = aWidgetError;
     }
@@ -77,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);
@@ -121,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);
 }