#include "ModuleBase_Tools.h"
#include "ModuleBase_WidgetValidator.h"
+#include <Events_InfoMessage.h>
+
#include <ModelAPI_Data.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_Events.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <Config_Translator.h>
+#include <Config_PropManager.h>
#include <Events_Loop.h>
myAttributeID = theData ? theData->widgetId() : "";
myIsObligatory = theData->getBooleanAttribute(ATTR_OBLIGATORY, true);
+ myIsValueEnabled = On; // not defined or "true"
+ std::string anEnableValue = theData->getProperty(DOUBLE_WDG_ENABLE_VALUE);
+ if (anEnableValue == "false")
+ myIsValueEnabled = Off;
+ if (anEnableValue == DOUBLE_WDG_ENABLE_VALUE_BY_PREFERENCES)
+ myIsValueEnabled = DefinedInPreferences;
+
connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
}
return theObject->data()->attribute(attributeID())->isInitialized();
}
+bool ModuleBase_ModelWidget::isValueEnabled() const
+{
+ bool anEnabled = true;
+ if (myIsValueEnabled == DefinedInPreferences) {
+ bool aCanDisable = Config_PropManager::boolean(SKETCH_TAB_NAME, "disable_input_fields", "true");
+ if (aCanDisable)
+ anEnabled = false;
+ }
+ else if (myIsValueEnabled == Off)
+ anEnabled = false;
+ return anEnabled;
+}
+
void ModuleBase_ModelWidget::processValueState()
{
if (myState == ModifiedInPP || myState == ModifiedInViewer)
return anError;
std::string aValidatorID;
- std::string anErrorMsg;
+ Events_InfoMessage 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;
+ anErrorMsg = anAttributeID + " - " + aValidatorID + ": " + anErrorMsg.messageString();
+ }
+
+ if (!anErrorMsg.empty()) {
+ std::string aStr = Config_Translator::translate(anErrorMsg);
+ std::string aCodec = Config_Translator::codec(anErrorMsg.context());
+ anError = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
}
- anError = QString::fromStdString(anErrorMsg);
if (anError.isEmpty() && theValueStateChecked)
anError = getValueStateError();
/// after debug, it may be corrected
myFlushUpdateBlocked = !isUpdateFlushed;
myFeature = theFeature;
- if (theToStoreValue)
- storeValue();
+ if (theToStoreValue) {
+ /// it is possible that the attribute is filled before the operation is started,
+ /// e.g. by reentrant operation case some attributes are filled by values of
+ /// feature of previous operation, we should not lost them here
+ if (!theFeature->data()->attribute(attributeID())->isInitialized())
+ storeValue();
+ }
myFlushUpdateBlocked = false;
}