Salome HOME
updated copyright message
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetExprEditor.cpp
index b9099882564f192633f3a7e244af3347587748a7..862b196439fd3f1c1a1768ced86e9a6ff07a2436 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <ModuleBase_WidgetExprEditor.h>
 #include <ModuleBase_Tools.h>
 
+#include <Locale_Convert.h>
+
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Validator.h>
@@ -234,7 +235,7 @@ ModuleBase_WidgetExprEditor::ModuleBase_WidgetExprEditor( QWidget* theParent,
   aMainLay->addWidget(myResultLabel);
   myEditor = new ExpressionEditor(this);
   myEditor->setMinimumHeight(20);
-  myEditor->setPlaceHolderText( QString::fromStdString( thePlaceHolder ) );
+  myEditor->setPlaceHolderText( translate( thePlaceHolder ) );
   aMainLay->addWidget(myEditor);
   this->setLayout(aMainLay);
 
@@ -269,7 +270,7 @@ bool ModuleBase_WidgetExprEditor::storeValueCustom()
   AttributeStringPtr aStringAttr = aData->string(attributeID());
 
   QString aWidgetValue = myEditor->toPlainText();
-  aStringAttr->setValue(aWidgetValue.toStdString());
+  aStringAttr->setValue(aWidgetValue.toStdWString());
   updateObject(myFeature);
 
   // Try to get the value
@@ -304,8 +305,12 @@ bool ModuleBase_WidgetExprEditor::restoreValueCustom()
   bool isBlocked = myEditor->blockSignals(true);
   QTextCursor aCursor = myEditor->textCursor();
   int pos = aCursor.position();
-  std::string aRestoredStr = aStringAttr->value();
-  myEditor->setPlainText(QString::fromStdString(aRestoredStr));
+  QString aRestoredStr;
+  if (aStringAttr->isUValue())
+    aRestoredStr = QString::fromStdWString(Locale::Convert::toWString(aStringAttr->valueU()));
+  else
+    aRestoredStr = QString::fromStdString(aStringAttr->value());
+  myEditor->setPlainText(aRestoredStr);
   aCursor.setPosition(pos);
   myEditor->setTextCursor(aCursor);
   myEditor->blockSignals(isBlocked);