From: nds Date: Tue, 15 Dec 2015 12:25:20 +0000 (+0300) Subject: #1107 Tab key does not change focus to Apply in circle sketch feature. X-Git-Tag: V_2.1.0~179 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2b21081bbbd86d0432cc408a1194df7804143209;p=modules%2Fshaper.git #1107 Tab key does not change focus to Apply in circle sketch feature. A processing for the double click in the viewer. --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 2994da26d..343f3a086 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -12,7 +12,6 @@ #include -#include #include #include #include @@ -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 { diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index acd6b49ac..ac7096437 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -191,11 +191,6 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject //! \return string value virtual QString getFeatureError(const FeaturePtr& theFeature); - //! 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 - virtual QString getWidgetError(ModuleBase_ModelWidget* theWidget); - /// Returns list of granted operation indices virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const; diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 504b8ca8f..feba11647 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -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 aMyControls = getControls(); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index f535b2fa7..bed820c97 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -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 diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp index 71d002025..562604dc0 100644 --- a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp +++ b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp @@ -95,7 +95,10 @@ void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWn std::shared_ptr aPnt = std::shared_ptr(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) diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index 7156e296f..9e379850c 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -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); }