From e8ba0666db0a8c13d1fa202366308d3938538e60 Mon Sep 17 00:00:00 2001 From: stv Date: Tue, 17 Jan 2006 08:36:45 +0000 Subject: [PATCH] Method isEmpty corrected. --- src/QDS/QDS_SpinBox.cxx | 19 ++++++++++++------- src/QDS/QDS_SpinBox.h | 4 ++-- src/QDS/QDS_SpinBoxDbl.cxx | 10 +++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/QDS/QDS_SpinBox.cxx b/src/QDS/QDS_SpinBox.cxx index d25322c3f..b77aa8ba0 100644 --- a/src/QDS/QDS_SpinBox.cxx +++ b/src/QDS/QDS_SpinBox.cxx @@ -1,6 +1,7 @@ #include "QDS_SpinBox.h" -#include +#include + #include /*! @@ -24,8 +25,8 @@ QDS_SpinBox::~QDS_SpinBox() QString QDS_SpinBox::getString() const { QString res; - QSpinBox* aSpinBox = spinBox(); - if ( aSpinBox ) + QtxIntSpinBox* aSpinBox = spinBox(); + if ( aSpinBox && !aSpinBox->isCleared() ) { res = aSpinBox->text(); if ( !aSpinBox->suffix().isEmpty() ) @@ -41,16 +42,20 @@ QString QDS_SpinBox::getString() const */ void QDS_SpinBox::setString( const QString& txt ) { - if ( spinBox() ) + if ( !spinBox() ) + return; + + spinBox()->setCleared( txt.isEmpty() ); + if ( !txt.isEmpty() ) spinBox()->setValue( txt.toInt() ); } /*! Returns pointer to QSpinBox widget. */ -QSpinBox* QDS_SpinBox::spinBox() const +QtxIntSpinBox* QDS_SpinBox::spinBox() const { - return ::qt_cast( controlWidget() ); + return ::qt_cast( controlWidget() ); } /*! @@ -58,7 +63,7 @@ QSpinBox* QDS_SpinBox::spinBox() const */ QWidget* QDS_SpinBox::createControl( QWidget* parent ) { - QSpinBox* aSpinBox = new QSpinBox( parent ); + QtxIntSpinBox* aSpinBox = new QtxIntSpinBox( parent ); aSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); connect( aSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged( int ) ) ); return aSpinBox; diff --git a/src/QDS/QDS_SpinBox.h b/src/QDS/QDS_SpinBox.h index d6490edbf..f018ddfb8 100644 --- a/src/QDS/QDS_SpinBox.h +++ b/src/QDS/QDS_SpinBox.h @@ -3,7 +3,7 @@ #include "QDS_Datum.h" -class QSpinBox; +class QtxIntSpinBox; class QDS_EXPORT QDS_SpinBox : public QDS_Datum { @@ -20,7 +20,7 @@ private slots: void onValueChanged( int ); protected: - QSpinBox* spinBox() const; + QtxIntSpinBox* spinBox() const; virtual QWidget* createControl( QWidget* ); diff --git a/src/QDS/QDS_SpinBoxDbl.cxx b/src/QDS/QDS_SpinBoxDbl.cxx index 42d1e2f9e..92ffe65c8 100644 --- a/src/QDS/QDS_SpinBoxDbl.cxx +++ b/src/QDS/QDS_SpinBoxDbl.cxx @@ -28,7 +28,7 @@ QString QDS_SpinBoxDbl::getString() const { QString res; QtxDblSpinBox* sb = spinBox(); - if ( sb ) + if ( sb && !sb->isCleared() ) { bool hasFocus = sb->hasFocus(); if ( hasFocus ) @@ -52,12 +52,16 @@ QString QDS_SpinBoxDbl::getString() const */ void QDS_SpinBoxDbl::setString( const QString& txt ) { - if ( spinBox() ) + if ( !spinBox() ) + return; + + spinBox()->setCleared( txt.isEmpty() ); + if ( !txt.isEmpty() ) spinBox()->setValue( txt.toDouble() ); } /*! - Returns pointer to XMLGUI_SpinBoxDbl widget. + Returns pointer to QtxDblSpinBox widget. */ QtxDblSpinBox* QDS_SpinBoxDbl::spinBox() const { -- 2.39.2