Salome HOME
Update merging two Coincidence constraints (issue #955)
[modules/shaper.git] / src / ModuleBase / ModuleBase_ParamSpinBox.cpp
index 8b09ac9fece6ec394cf21314cd0a580084d3e274..febd29badbf419cdbf187edbbcf8533742bf04e6 100644 (file)
@@ -11,6 +11,7 @@
 #include <QLocale>
 #include <QRegExp>
 #include <QToolTip>
+#include <QApplication>
 
 #include <string>
 #include <iostream>
@@ -73,7 +74,6 @@ void ModuleBase_ParamSpinBox::connectSignalsAndSlots()
  */
 void ModuleBase_ParamSpinBox::onTextChanged(const QString& text)
 {
-  ModuleBase_DoubleSpinBox::onTextChanged(text);
   myTextValue = text;
 }
 
@@ -85,11 +85,11 @@ void ModuleBase_ParamSpinBox::onTextChanged(const QString& text)
  */
 double ModuleBase_ParamSpinBox::valueFromText(const QString& theText) const
 {
-  if (!hasVariable(theText)) {
+  if (!hasVariable(theText))
     return ModuleBase_DoubleSpinBox::valueFromText(theText);
-  }
-  // small hack: return length of the string to iniiate valuesChanged signal
-  return theText.length();
+
+  // small hack: return length of the string to initiate valuesChanged signal
+  return qHash(theText);
 }
 
 QString ModuleBase_ParamSpinBox::textFromValue (double theValue) const
@@ -178,10 +178,19 @@ bool ModuleBase_ParamSpinBox::hasVariable(const QString& theText) const
   //  QRegExp varNameMask(aDigitPattern.arg(","));
   //  aHasDigit = varNameMask.exactMatch(theText);
   //}
-  bool aHasDigit = false;
-  theText.toDouble(&aHasDigit);
-  return !aHasDigit;
-
+  bool isDouble = false;
+  QLocale::c().toDouble(theText, &isDouble);
+
+//  theText.toDouble(&isDouble);
+//  if (isDouble) {
+//    QLocale aLoc; // create default locale
+//    QChar aDecPnt = aLoc.decimalPoint();
+//    if (aDecPnt == '.')
+//      isDouble = theText.contains(aDecPnt) || (!theText.contains(','));
+//    else if (aDecPnt == ',')
+//      isDouble = theText.contains(aDecPnt) || (!theText.contains('.'));
+//  }
+  return !isDouble;
 }
 
 /*!