Salome HOME
bos #30182 Fix compilation problem
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetIntValue.cpp
index 0e131bb1dc8dda8766947714177e795ea9a01e38..cb2e503f0f3c513921e0e0149143bed765e13488 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  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
@@ -160,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
@@ -169,7 +169,7 @@ bool ModuleBase_WidgetIntValue::storeValueCustom()
       anAttribute->setExpressionError("");
       anAttribute->setExpressionInvalid(false);
     }
-    anAttribute->setText("");
+    anAttribute->setText(L"");
     anAttribute->setValue(mySpinBox->value());
   }
   updateObject(myFeature);
@@ -180,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();
@@ -230,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