From: dmv Date: Mon, 1 Feb 2010 14:59:08 +0000 (+0000) Subject: IPAL21559 Double spin boxes work bad in the Salome Preferences X-Git-Tag: V5_1_4a1~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1aa233b3bca98ecfcd461c0968a0ba32a1a0773b;p=modules%2Fgui.git IPAL21559 Double spin boxes work bad in the Salome Preferences --- diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 3a346ec3b..6fb5b4359 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -2671,6 +2671,19 @@ QVariant QtxPagePrefSpinItem::step() const return QVariant(); } +/*! + \brief Get double spin box preference item precision value. + \return double spin box precision + \sa setPrecision() +*/ +QVariant QtxPagePrefSpinItem::precision() const +{ + if ( QtxDoubleSpinBox* dsb = ::qobject_cast( control() ) ) + return dsb->decimals(); + else + return QVariant(); +} + /*! \brief Get spin box preference item minimum value. \return spin box minimum value @@ -2765,6 +2778,22 @@ void QtxPagePrefSpinItem::setStep( const QVariant& step ) } } +/*! + \brief Set double spin box preference item precision value. + \param step new double spin box precision value + \sa precision() +*/ +void QtxPagePrefSpinItem::setPrecision( const QVariant& prec ) +{ + if ( QtxDoubleSpinBox* dsb = ::qobject_cast( control() ) ) + { + if ( prec.canConvert( QVariant::Int ) ) { + dsb->setDecimals( prec.toInt() ); + dsb->setPrecision( prec.toInt() ); + } + } +} + /*! \brief Set spin box preference item minimum value. \param min new spin box minimum value @@ -2882,6 +2911,8 @@ QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const return maximum(); else if ( name == "step" ) return step(); + else if ( name == "precision" ) + return precision(); else if ( name == "prefix" ) return prefix(); else if ( name == "suffix" ) @@ -2911,6 +2942,8 @@ void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& v setMaximum( val ); else if ( name == "step" ) setStep( val ); + else if ( name == "precision" ) + setPrecision( val ); else if ( name == "prefix" ) { if ( val.canConvert( QVariant::String ) ) @@ -2937,6 +2970,7 @@ void QtxPagePrefSpinItem::updateSpinBox() { QVariant val; QVariant stp = step(); + QVariant prec = precision(); QVariant min = minimum(); QVariant max = maximum(); @@ -2960,6 +2994,7 @@ void QtxPagePrefSpinItem::updateSpinBox() control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); setStep( stp ); + setPrecision( prec ); setMinimum( min ); setMaximum( max ); diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index f853ba6ac..bbc634240 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -472,6 +472,7 @@ public: virtual ~QtxPagePrefSpinItem(); QVariant step() const; + QVariant precision() const; QVariant minimum() const; QVariant maximum() const; @@ -480,6 +481,7 @@ public: QString specialValueText() const; void setStep( const QVariant& ); + void setPrecision( const QVariant& ); void setMinimum( const QVariant& ); void setMaximum( const QVariant& );