Salome HOME
Fix for editing of double value
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Jul 2015 17:20:07 +0000 (20:20 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Jul 2015 17:20:33 +0000 (20:20 +0300)
src/ModuleBase/ModuleBase_ParamSpinBox.cpp
src/ModuleBase/ModuleBase_Tools.cpp

index 4569e2b8fe351e47b8e1ece1465cceefe6d62e4e..58cd37d6289065ecf8c2ad02e85a088857db5f68 100644 (file)
@@ -135,6 +135,7 @@ void ModuleBase_ParamSpinBox::setValue(const double value)
  */
 void ModuleBase_ParamSpinBox::setText(const QString& value)
 {
+  myTextValue = value;
   lineEdit()->setText(value);
 }
 
@@ -165,19 +166,20 @@ bool ModuleBase_ParamSpinBox::hasVariable() const
 
 bool ModuleBase_ParamSpinBox::hasVariable(const QString& theText) const
 {
-  QString aDigitPattern = QString("[-+]?[0-9]*[%1]?[0-9]+([eE][-+]?[0-9]+)?");
-
+  //const QString aDigitPattern = QString("[-+]?[0-9]*[%1]?[0-9]*([eE][-+]?[0-9]+)?");
+
+  //bool aHasDigit = false;
+  //{
+  //  QRegExp varNameMask(aDigitPattern.arg("."));
+  //  aHasDigit = varNameMask.exactMatch(theText);
+  //}
+  //if (!aHasDigit)
+  //{
+  //  QRegExp varNameMask(aDigitPattern.arg(","));
+  //  aHasDigit = varNameMask.exactMatch(theText);
+  //}
   bool aHasDigit = false;
-  {
-    QRegExp varNameMask(aDigitPattern.arg("."));
-    aHasDigit = varNameMask.exactMatch(theText);
-  }
-  if (!aHasDigit)
-  {
-    QRegExp varNameMask(aDigitPattern.arg(","));
-    aHasDigit = varNameMask.exactMatch(theText);
-  }
-
+  theText.toDouble(&aHasDigit);
   return !aHasDigit;
 
 }
index d3739e8439d7e354045067a8998ae158a6962588..b3cb302bafa019c79bba39090242b325e90a5352 100644 (file)
@@ -114,17 +114,19 @@ QPixmap lighter(const QString& theIcon, const int theLighterValue)
 
 void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText)
 {
-  if (theSpin->text() != theText) {
-    // In order to avoid extra text setting because it will
-    // reset cursor position in control
-    bool isBlocked = theSpin->blockSignals(true);
-    theSpin->setText(theText);
-    theSpin->blockSignals(isBlocked);
-  }
+  if (theSpin->text() == theText) 
+    return;
+  // In order to avoid extra text setting because it will
+  // reset cursor position in control
+  bool isBlocked = theSpin->blockSignals(true);
+  theSpin->setText(theText);
+  theSpin->blockSignals(isBlocked);
 }
 
 void setSpinValue(QDoubleSpinBox* theSpin, double theValue)
 {
+  if (theSpin->value() == theValue)
+    return;
   bool isBlocked = theSpin->blockSignals(true);
   theSpin->setValue(theValue);
   theSpin->blockSignals(isBlocked);
@@ -132,6 +134,8 @@ void setSpinValue(QDoubleSpinBox* theSpin, double theValue)
 
 void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue)
 {
+  if (theSpin->value() == theValue)
+    return;
   bool isBlocked = theSpin->blockSignals(true);
   theSpin->setValue(theValue);
   theSpin->blockSignals(isBlocked);