-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "ModuleBase_ParamSpinBox.h"
ModuleBase_ParamSpinBox::ModuleBase_ParamSpinBox(QWidget* theParent, int thePrecision)
: QAbstractSpinBox(theParent),
- myPrecision(thePrecision),
myIsEquation(false),
myAcceptVariables(true),
mySingleStep(1),
- myMinimum(DBL_MIN),
+ myMinimum(-DBL_MAX),
myMaximum(DBL_MAX)
{
myCompleter = new QCompleter(this);
myValidator = new QDoubleValidator(this);
myValidator->setLocale(locale());
myValidator->setRange(myMinimum, myMaximum);
- myValidator->setDecimals(myPrecision);
+ myValidator->setDecimals(thePrecision);
}
void ModuleBase_ParamSpinBox::setCompletionList(QStringList& theList)
aVal = myMinimum;
else if (aVal > myMaximum)
aVal = myMaximum;
- QString aText = QString::number(aVal, 'g', decimals());
+ QString aText = (myValidator->decimals() == 0) ? QString::number((int)aVal) :
+ QString::number(aVal, 'g', decimals());
lineEdit()->blockSignals(true);
lineEdit()->setText(aText);
lineEdit()->blockSignals(false);
lineEdit()->setText(value);
emit textChanged(value);
}
+ else {
+ bool isConv = false;
+ double aVal = value.toDouble(&isConv);
+ if (isConv)
+ setValue(aVal);
+ }
}
/*!