Salome HOME
bos #30182 Fix compilation problem
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetIntValue.cpp
index fa8a77159e5bff3469b4e816fa4e245c5359f3eb..cb2e503f0f3c513921e0e0149143bed765e13488 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // 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_WidgetIntValue.h>
@@ -161,7 +160,7 @@ bool ModuleBase_WidgetIntValue::storeValueCustom()
       // Nullyfy the parameter reference without deletion of the created
       myParameter = FeaturePtr();
     }
-    anAttribute->setText(aText.toStdString());
+    anAttribute->setText(aText.toStdWString());
   } else {
     // it is important to set the empty text value to the attribute before set the value
     // because setValue tries to calculate the attribute value according to the
@@ -170,7 +169,7 @@ bool ModuleBase_WidgetIntValue::storeValueCustom()
       anAttribute->setExpressionError("");
       anAttribute->setExpressionInvalid(false);
     }
-    anAttribute->setText("");
+    anAttribute->setText(L"");
     anAttribute->setValue(mySpinBox->value());
   }
   updateObject(myFeature);
@@ -181,9 +180,9 @@ bool ModuleBase_WidgetIntValue::restoreValueCustom()
 {
   DataPtr aData = myFeature->data();
   AttributeIntegerPtr anAttribute = aData->integer(attributeID());
-  std::string aTextRepr = anAttribute->text();
+  std::wstring aTextRepr = anAttribute->text();
   if (!aTextRepr.empty()) {
-    QString aText = QString::fromStdString(aTextRepr);
+    QString aText = QString::fromStdWString(aTextRepr);
     //if (aText.endsWith('=')) {
     //  if (!myParameter.get()) {
     //    QString aName = aText.left(aText.indexOf('=')).trimmed();
@@ -231,3 +230,18 @@ bool ModuleBase_WidgetIntValue::processEnter()
   }
   return isModified;
 }
+
+bool ModuleBase_WidgetIntValue::isModified() const
+{
+  QString aText = mySpinBox->text();
+  if (aText.isEmpty())
+    return false;
+
+  if (myHasDefault) {
+    bool aOk = false;
+    int aVal = aText.toInt(&aOk);
+    if (!aOk || aVal == myDefVal)
+      return false;
+  }
+  return true;
+}
\ No newline at end of file