// 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;
/// \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();
{
}
+void ModuleBase_WidgetExprEditor::initializeValueByActivate()
+{
+}
+
bool ModuleBase_WidgetExprEditor::storeValueCustom() const
{
// A rare case when plugin was not loaded.
return false;
DataPtr aData = myFeature->data();
AttributeStringPtr aStringAttr = aData->string(attributeID());
+
QString aWidgetValue = myEditor->toPlainText();
aStringAttr->setValue(aWidgetValue.toStdString());
updateObject(myFeature);
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;