From: nds Date: Wed, 21 Oct 2015 15:18:09 +0000 (+0300) Subject: A correction for the parameters: X-Git-Tag: V_2.0.0_alfa1~48 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a26b3aee26fc2761728ea778939800b9b02e2a61;p=modules%2Fshaper.git A correction for the parameters: after entering the parameter name, when the value input gets the focus, an error message is displayed (unnexpected EOF while parsing (, line 0) while the user didn't type yet anything. It's not fair. The decision: do not set the editor value to the feature attribute by the control activation. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 721c6c7b0..c84b8e646 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -122,20 +122,24 @@ void ModuleBase_ModelWidget::activate() // It should happens in the creation mode only because all fields are filled in the edition mode if (!isEditingMode()) { AttributePtr anAttribute = myFeature->data()->attribute(myAttributeID); - if (anAttribute.get() != NULL && !anAttribute->isInitialized()) { - if (isComputedDefault()) { - if (myFeature->compute(myAttributeID)) { - restoreValue(); - } - } - else { - storeValue(); - } - } + if (anAttribute.get() != NULL && !anAttribute->isInitialized()) + initializeValueByActivate(); } activateCustom(); } +void ModuleBase_ModelWidget::initializeValueByActivate() +{ + if (isComputedDefault()) { + if (myFeature->compute(myAttributeID)) { + restoreValue(); + } + } + else { + storeValue(); + } +} + QWidget* ModuleBase_ModelWidget::getControlAcceptingFocus(const bool isFirst) { QWidget* aControl = 0; diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index c805502d1..f1d257362 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -225,6 +225,10 @@ protected: /// \param theState a new state void setValueState(const ValueState& theState); + /// Compute the feature default value and fill the controls with it + /// or store the control value to the feature + virtual void initializeValueByActivate(); + /// Saves the internal parameters to the given feature. Emits signals before and after store /// \return True in success bool storeValue(); diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp index a7e7878e6..b11bd6714 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.cpp @@ -263,6 +263,10 @@ ModuleBase_WidgetExprEditor::~ModuleBase_WidgetExprEditor() { } +void ModuleBase_WidgetExprEditor::initializeValueByActivate() +{ +} + bool ModuleBase_WidgetExprEditor::storeValueCustom() const { // A rare case when plugin was not loaded. @@ -270,6 +274,7 @@ bool ModuleBase_WidgetExprEditor::storeValueCustom() const return false; DataPtr aData = myFeature->data(); AttributeStringPtr aStringAttr = aData->string(attributeID()); + QString aWidgetValue = myEditor->toPlainText(); aStringAttr->setValue(aWidgetValue.toStdString()); updateObject(myFeature); diff --git a/src/ModuleBase/ModuleBase_WidgetExprEditor.h b/src/ModuleBase/ModuleBase_WidgetExprEditor.h index eb2ff9aa1..69f36b46c 100644 --- a/src/ModuleBase/ModuleBase_WidgetExprEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetExprEditor.h @@ -135,6 +135,9 @@ protected slots: void onTextChanged(); protected: + /// Do not initialize value on the widget activation + virtual void initializeValueByActivate(); + /// Saves the internal parameters to the given feature /// \return True in success virtual bool storeValueCustom() const;