#include <QKeyEvent>
#include <QLineEdit>
-#include <QToolTip>
+#include <QLocale>
#include <QRegExp>
+#include <QToolTip>
#include <string>
#include <iostream>
*/
void ModuleBase_ParamSpinBox::stepBy(int steps)
{
- if (hasVariable())
+ if ((!myTextValue.isEmpty()) && hasVariable())
return;
ModuleBase_DoubleSpinBox::stepBy(steps);
*/
void ModuleBase_ParamSpinBox::onTextChanged(const QString& text)
{
+ ModuleBase_DoubleSpinBox::onTextChanged(text);
myTextValue = text;
}
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);
}
/*!
*/
void ModuleBase_ParamSpinBox::setText(const QString& value)
{
+ myTextValue = value;
lineEdit()->setText(value);
}
bool ModuleBase_ParamSpinBox::hasVariable(const QString& theText) const
{
- QRegExp varNameMask("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?");
- return !varNameMask.exactMatch(theText);
+ //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;
+ theText.toDouble(&aHasDigit);
+ return !aHasDigit;
+
}
/*!
bool ModuleBase_ParamSpinBox::findVariable(const QString& theName,
double& outValue) const
{
-
- return ModelAPI_Tools::findVariable(theName.toStdString(), outValue);
+ ResultParameterPtr aParam;
+ return ModelAPI_Tools::findVariable(theName.toStdString(), outValue, aParam);
}
/*!
\brief This function is called when the spinbox recieves key press event.
*/
-void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e)
-{
- if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
- QWidget::keyPressEvent(e);
- } else {
- ModuleBase_DoubleSpinBox::keyPressEvent(e);
- }
-}
+//void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e)
+//{
+// if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
+// QWidget::keyPressEvent(e);
+// } else {
+// ModuleBase_DoubleSpinBox::keyPressEvent(e);
+// }
+//}
/*!
\brief This function is called when the spinbox recieves show event.
void ModuleBase_ParamSpinBox::showEvent(QShowEvent* theEvent)
{
ModuleBase_DoubleSpinBox::showEvent(theEvent);
- if (hasVariable(myTextValue)) {
+ if ((!myTextValue.isEmpty()) && hasVariable(myTextValue)) {
setText(myTextValue);
}
}