]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
A correction for the parameters:
authornds <nds@opencascade.com>
Wed, 21 Oct 2015 15:18:09 +0000 (18:18 +0300)
committernds <nds@opencascade.com>
Mon, 2 Nov 2015 09:50:22 +0000 (12:50 +0300)
after entering the parameter name, when the value input gets the focus,
an error message is displayed (unnexpected EOF while parsing (<string>,
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.

src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetExprEditor.cpp
src/ModuleBase/ModuleBase_WidgetExprEditor.h

index 721c6c7b0470afd3ce84db7a0ee2517d58a6f7d2..c84b8e6462063d7de4692decf84aea7ed3365414 100644 (file)
@@ -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;
index c805502d1b9a4aabcf9325a6aecb1eacacfe03d4..f1d257362076ea7b0204cb8f1219782adba2afd7 100644 (file)
@@ -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();
index a7e7878e65d52e34722b4cf43f88c2a758e09006..b11bd67146184a661473321a58d4f8b0dabef582 100644 (file)
@@ -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);
index eb2ff9aa1e1d861f68b164aa0e3efc207e30d452..69f36b46c3da1061496b446ef8788ffee1b2d881 100644 (file)
@@ -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;