#include <QLocale>
#include <QRegExp>
#include <QToolTip>
+#include <QApplication>
#include <string>
#include <iostream>
*/
void ModuleBase_ParamSpinBox::stepBy(int steps)
{
- if (hasVariable())
+ if ((!myTextValue.isEmpty()) && hasVariable())
return;
ModuleBase_DoubleSpinBox::stepBy(steps);
*/
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
{
- if (hasVariable(myTextValue)){
+ if ((!myTextValue.isEmpty()) && hasVariable(myTextValue)){
return myTextValue;
}
return ModuleBase_DoubleSpinBox::textFromValue(theValue);
*/
void ModuleBase_ParamSpinBox::setValue(const double value)
{
- ModuleBase_DoubleSpinBox::setValue(value);
-
myTextValue = ModuleBase_DoubleSpinBox::textFromValue(value);
+ ModuleBase_DoubleSpinBox::setValue(value);
}
/*!
// 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;
}
/*!
void ModuleBase_ParamSpinBox::showEvent(QShowEvent* theEvent)
{
ModuleBase_DoubleSpinBox::showEvent(theEvent);
- if (hasVariable(myTextValue)) {
+ if ((!myTextValue.isEmpty()) && hasVariable(myTextValue)) {
setText(myTextValue);
}
}