From: stv Date: Thu, 21 Jul 2005 07:37:19 +0000 (+0000) Subject: no message X-Git-Tag: V3_0_1~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c12e45f66a59e9d73b5f7574118c92c331f781fd;p=modules%2Fgui.git no message --- diff --git a/src/Qtx/QtxTable.cxx b/src/Qtx/QtxTable.cxx index 6c56918d6..f2e05f175 100644 --- a/src/Qtx/QtxTable.cxx +++ b/src/Qtx/QtxTable.cxx @@ -13,6 +13,12 @@ myHeaderEditor( 0 ), myEditedHeader( 0 ), myEditedSection( -1 ) { + connect( verticalHeader(), SIGNAL( sizeChange( int, int, int ) ), + this, SLOT( onHeaderSizeChange( int, int, int ) ) ); + connect( horizontalHeader(), SIGNAL( sizeChange( int, int, int ) ), + this, SLOT( onHeaderSizeChange( int, int, int ) ) ); + connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), this, SLOT( onScrollBarMoved( int ) ) ); + connect( horizontalScrollBar(), SIGNAL( valueChanged( int ) ), this, SLOT( onScrollBarMoved( int ) ) ); } QtxTable::QtxTable( int numRows, int numCols, QWidget* parent, const char* name ) @@ -21,6 +27,12 @@ myHeaderEditor( 0 ), myEditedHeader( 0 ), myEditedSection( -1 ) { + connect( verticalHeader(), SIGNAL( sizeChange( int, int, int ) ), + this, SLOT( onHeaderSizeChange( int, int, int ) ) ); + connect( horizontalHeader(), SIGNAL( sizeChange( int, int, int ) ), + this, SLOT( onHeaderSizeChange( int, int, int ) ) ); + connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), this, SLOT( onScrollBarMoved( int ) ) ); + connect( horizontalScrollBar(), SIGNAL( valueChanged( int ) ), this, SLOT( onScrollBarMoved( int ) ) ); } QtxTable::~QtxTable() @@ -60,6 +72,13 @@ void QtxTable::endEditHeader( const bool accept ) endHeaderEdit( accept ); } +void QtxTable::hide() +{ + endHeaderEdit(); + + QTable::hide(); +} + bool QtxTable::eventFilter( QObject* o, QEvent* e ) { if ( e->type() == QEvent::MouseButtonDblClick ) @@ -108,6 +127,24 @@ bool QtxTable::eventFilter( QObject* o, QEvent* e ) return QTable::eventFilter( o, e ); } +void QtxTable::onScrollBarMoved( int ) +{ + updateHeaderEditor(); +} + +void QtxTable::onHeaderSizeChange( int, int, int ) +{ + if ( sender() == myEditedHeader ) + updateHeaderEditor(); +} + +void QtxTable::resizeEvent( QResizeEvent* e ) +{ + QTable::resizeEvent( e ); + + updateHeaderEditor(); +} + bool QtxTable::beginHeaderEdit( Orientation o, const int section ) { if ( !headerEditable( o ) || !header( o ) || !header( o )->isVisibleTo( this ) ) @@ -134,11 +171,14 @@ bool QtxTable::beginHeaderEdit( Orientation o, const int section ) myEditedSection = section; myHeaderEditor->reparent( this, QPoint( 0, 0 ), false ); - myHeaderEditor->resize( r.size() ); - myHeaderEditor->move( r.topLeft() ); + + updateHeaderEditor(); + myHeaderEditor->show(); + myHeaderEditor->setActiveWindow(); myHeaderEditor->setFocus(); + myHeaderEditor->installEventFilter( this ); return true; @@ -228,4 +268,28 @@ QRect QtxTable::headerSectionRect( QHeader* hdr, const int sec ) const return r; } +void QtxTable::updateHeaderEditor() +{ + if ( !myHeaderEditor || !myEditedHeader || myEditedSection < 0 ) + return; + + QRect r = headerSectionRect( myEditedHeader, myEditedSection ); + if ( !r.isValid() ) + return; + + if ( myEditedHeader == horizontalHeader() ) + { + r.setLeft( QMAX( r.left(), leftMargin() ) ); + r.setRight( QMIN( r.right(), width() - rightMargin() - 2 ) ); + } + else + { + r.setTop( QMAX( r.top(), topMargin() ) ); + r.setBottom( QMIN( r.bottom(), height() - bottomMargin() - 2 ) ); + } + + myHeaderEditor->resize( r.size() ); + myHeaderEditor->move( r.topLeft() ); +} + #endif diff --git a/src/Qtx/QtxTable.h b/src/Qtx/QtxTable.h index 644c8a2e4..977e06c1b 100644 --- a/src/Qtx/QtxTable.h +++ b/src/Qtx/QtxTable.h @@ -35,9 +35,16 @@ signals: void headerEdited( Orientation, int ); public slots: + virtual void hide(); virtual void setHeaderEditable( Orientation, bool ); +private slots: + void onScrollBarMoved( int ); + void onHeaderSizeChange( int, int, int ); + protected: + virtual void resizeEvent( QResizeEvent* ); + virtual bool beginHeaderEdit( Orientation, const int ); virtual void endHeaderEdit( const bool = true ); bool isHeaderEditing() const; @@ -47,6 +54,7 @@ protected: QHeader* header( Orientation o ) const; private: + void updateHeaderEditor(); void beginHeaderEdit( Orientation, const QPoint& ); QRect headerSectionRect( QHeader*, const int ) const;