From 9ff26b37b7cb8bd37d64102b675c215252071599 Mon Sep 17 00:00:00 2001 From: stv Date: Tue, 29 Aug 2006 11:26:38 +0000 Subject: [PATCH] Subcontrol wrapper behaviour corrected. Methods hide(), show(), setShown() were modified. --- src/QDS/QDS_Datum.cxx | 62 +++++++++++++++---------------------------- src/QDS/QDS_Datum.h | 6 ++--- 2 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/QDS/QDS_Datum.cxx b/src/QDS/QDS_Datum.cxx index 37be33349..349cbc173 100644 --- a/src/QDS/QDS_Datum.cxx +++ b/src/QDS/QDS_Datum.cxx @@ -45,16 +45,13 @@ public: QWidget* widget() const; void setWidget( QWidget* ); - virtual bool eventFilter( QObject*, QEvent* ); - -protected: - virtual void resizeEvent( QResizeEvent* ); + virtual void setGeometry( int x, int y, int w, int h ); + virtual void setSizePolicy( QSizePolicy ); private: QWidget* myWid; }; - QDS_Datum::Wrapper::Wrapper( QWidget* parent ) : QWidget( parent ), myWid( 0 ) @@ -78,9 +75,6 @@ void QDS_Datum::Wrapper::setWidget( QWidget* wid ) if ( myWid == wid ) return; - if ( myWid ) - myWid->removeEventFilter( this ); - myWid = wid; if ( !myWid ) @@ -94,27 +88,22 @@ void QDS_Datum::Wrapper::setWidget( QWidget* wid ) myWid->updateGeometry(); updateGeometry(); - - myWid->installEventFilter( this ); } -bool QDS_Datum::Wrapper::eventFilter( QObject* o, QEvent* e ) +void QDS_Datum::Wrapper::setSizePolicy( QSizePolicy sp ) { - if ( e->type() == QEvent::Resize && o == widget() ) - { - QResizeEvent* re = (QResizeEvent*)e; - if ( re->size() != size() ) - resize( re->size() ); - } - return QWidget::eventFilter( o, e ); + QWidget::setSizePolicy( sp ); + + if ( widget() ) + widget()->setSizePolicy( sp ); } -void QDS_Datum::Wrapper::resizeEvent( QResizeEvent* e ) +void QDS_Datum::Wrapper::setGeometry( int x, int y, int w, int h ) { - QWidget::resizeEvent( e ); + QWidget::setGeometry( x, y, w, h ); if ( widget() && widget()->size() != size() ) - widget()->resize( size() ); + widget()->setGeometry( 0, 0, width(), height() ); } /*! @@ -634,10 +623,15 @@ void QDS_Datum::setEnabled( bool on ) */ void QDS_Datum::setShown( const bool visible, const int flags ) { - if ( visible ) - show( flags ); - else - hide( flags ); + initDatum(); + + uint flag = Units; + while ( flag ) + { + if ( flags & flag && widget( flag ) ) + widget( flag )->setShown( visible ); + flag = flag >> 1; + } } /*! @@ -646,14 +640,7 @@ void QDS_Datum::setShown( const bool visible, const int flags ) */ void QDS_Datum::show( const int element ) { - initDatum(); - - if ( ( element & Label ) && labelWidget() ) - labelWidget()->show(); - if ( ( element & Units ) && unitsWidget() ) - unitsWidget()->show(); - if ( ( element & Control ) && controlWidget() ) - controlWidget()->show(); + setShown( true, element ); } /*! @@ -662,14 +649,7 @@ void QDS_Datum::show( const int element ) */ void QDS_Datum::hide( const int element ) { - initDatum(); - - if ( ( element & Label ) && labelWidget() ) - labelWidget()->hide(); - if ( ( element & Units ) && unitsWidget() ) - unitsWidget()->hide(); - if ( ( element & Control ) && controlWidget() ) - controlWidget()->hide(); + setShown( false, element ); } /*! diff --git a/src/QDS/QDS_Datum.h b/src/QDS/QDS_Datum.h index e650cd213..45ef3458c 100644 --- a/src/QDS/QDS_Datum.h +++ b/src/QDS/QDS_Datum.h @@ -82,9 +82,9 @@ public: virtual bool isEnabled( const int = Control ) const; virtual void setEnabled( const bool, const int ); - void show( const int = -1 ); - void hide( const int = -1 ); - void setShown( const bool, const int = -1 ); + void show( const int = All ); + void hide( const int = All ); + virtual void setShown( const bool, const int = All ); QWidget* widget( const int ) const; void setFocus(); -- 2.39.2