From: ouv Date: Thu, 6 Nov 2008 10:03:04 +0000 (+0000) Subject: Minor change X-Git-Tag: TG_DumpPython_Extension_1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=92375b0d725cf1c5286daba303ad451865dc5c19;p=modules%2Fgui.git Minor change --- diff --git a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx index 25a5a87d3..95e4d1c85 100644 --- a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx +++ b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx @@ -109,17 +109,17 @@ double SalomeApp_DoubleSpinBox::valueFromText( const QString& text ) const { QString str = text; + bool ok = false; double value = 0; if( findVariable( str, value ) ) - str = QString::number( value ); - - int pos = 0; - if( checkRange( str ) && QtxDoubleSpinBox::validate( str, pos ) == QValidator::Acceptable ) - value = QtxDoubleSpinBox::valueFromText( str ); + ok = true; else - value = defaultValue(); + value = str.toDouble( &ok ); + + if( ok && checkRange( value ) ) + return value; - return value; + return defaultValue(); } /*! @@ -154,12 +154,14 @@ bool SalomeApp_DoubleSpinBox::isValid() const { QString str = text(); + bool ok = false; double value = 0; if( findVariable( str, value ) ) - str = QString::number( value ); + ok = true; + else + value = str.toDouble( &ok ); - int pos = 0; - return checkRange( str ) && QtxDoubleSpinBox::validate( str, pos ) == QValidator::Acceptable; + return ok && checkRange( value ); } /*! @@ -200,14 +202,12 @@ double SalomeApp_DoubleSpinBox::defaultValue() const \brief This function is used to check that string value lies within predefined range. \return check status */ -bool SalomeApp_DoubleSpinBox::checkRange( const QString& str ) const +bool SalomeApp_DoubleSpinBox::checkRange( const double value ) const { if( !myIsRangeSet ) return true; - bool ok = false; - double value = str.toDouble( &ok ); - return ok && value >= myMinimum && value <= myMaximum; + return value >= myMinimum && value <= myMaximum; } /*! diff --git a/src/SalomeApp/SalomeApp_DoubleSpinBox.h b/src/SalomeApp/SalomeApp_DoubleSpinBox.h index 8aed2cf4b..7ce95ed2d 100644 --- a/src/SalomeApp/SalomeApp_DoubleSpinBox.h +++ b/src/SalomeApp/SalomeApp_DoubleSpinBox.h @@ -50,7 +50,7 @@ public: protected: double defaultValue() const; - bool checkRange( const QString& ) const; + bool checkRange( const double ) const; bool findVariable( const QString&, double& ) const; private: