From: vsv Date: Wed, 8 Jul 2015 17:20:07 +0000 (+0300) Subject: Fix for editing of double value X-Git-Tag: V_1.3.0~67 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9914f396e78ea9e6523d709b23cb30a34166a1bb;p=modules%2Fshaper.git Fix for editing of double value --- diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index 4569e2b8f..58cd37d62 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -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; } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index d3739e843..b3cb302ba 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -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);