+QString ModuleBase_ModelWidget::getError(const bool theValueStateChecked) 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;
+ 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.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());
+ }
+
+ if (anError.isEmpty() && theValueStateChecked)
+ anError = getValueStateError();
+
+ anError = translateString(anError);
+ return anError;
+}
+
+
+QString ModuleBase_ModelWidget::translateString(const QString& theMsg) const
+{
+ if (!theMsg.isEmpty()) {
+ std::string aContext = feature()->getKind();
+ std::string aStr = Config_Translator::translate(aContext, theMsg.toStdString().c_str());
+ std::string aCodec = Config_Translator::codec(aContext);
+ return QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
+ }
+ return theMsg;
+}
+
+