From 6e6768480d5a4ffe8c46300508a70057633f260c Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 5 Oct 2006 11:02:42 +0000 Subject: [PATCH] Errors in header edition. --- src/QDS/QDS_Datum.cxx | 16 +++++++ src/Qtx/QtxTable.cxx | 106 ++++++++++++++++++++++++++++++++++++------ src/Qtx/QtxTable.h | 12 ++++- 3 files changed, 120 insertions(+), 14 deletions(-) diff --git a/src/QDS/QDS_Datum.cxx b/src/QDS/QDS_Datum.cxx index a542a19b4..6f57de32b 100644 --- a/src/QDS/QDS_Datum.cxx +++ b/src/QDS/QDS_Datum.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -50,6 +51,8 @@ public: virtual void setGeometry( int x, int y, int w, int h ); virtual void setSizePolicy( QSizePolicy ); + virtual bool eventFilter( QObject*, QEvent* ); + private: QWidget* myWid; }; @@ -77,6 +80,9 @@ void QDS_Datum::Wrapper::setWidget( QWidget* wid ) if ( myWid == wid ) return; + if ( myWid ) + myWid->removeEventFilter( this ); + myWid = wid; if ( !myWid ) @@ -85,6 +91,8 @@ void QDS_Datum::Wrapper::setWidget( QWidget* wid ) if ( myWid->parent() != this ) myWid->reparent( this, QPoint( 0, 0 ) ); + myWid->installEventFilter( this ); + setTabOrder( this, myWid ); setFocusProxy( myWid ); @@ -92,6 +100,14 @@ void QDS_Datum::Wrapper::setWidget( QWidget* wid ) updateGeometry(); } +bool QDS_Datum::Wrapper::eventFilter( QObject* o, QEvent* e ) +{ + if ( o == widget() && ( e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut ) ) + QApplication::sendEvent( this, e ); + + return false; +} + void QDS_Datum::Wrapper::setSizePolicy( QSizePolicy sp ) { QWidget::setSizePolicy( sp ); diff --git a/src/Qtx/QtxTable.cxx b/src/Qtx/QtxTable.cxx index 1f7c0be55..6d110e63f 100644 --- a/src/Qtx/QtxTable.cxx +++ b/src/Qtx/QtxTable.cxx @@ -117,16 +117,6 @@ void QtxTable::endEditHeader( const bool accept ) endHeaderEdit( accept ); } -/*! - Finishes edition and hides table -*/ -void QtxTable::hide() -{ - endHeaderEdit(); - - QTable::hide(); -} - /*! Custom event filter Starts edition of header by double click @@ -168,10 +158,10 @@ bool QtxTable::eventFilter( QObject* o, QEvent* e ) } if ( o == myHeaderEditor && e->type() == QEvent::FocusOut && - isHeaderEditing() && ((QFocusEvent*)e)->reason() != QFocusEvent::Popup ) + ((QFocusEvent*)e)->reason() != QFocusEvent::Popup ) { - endHeaderEdit(); - return true; + endHeaderEdit(); + return true; } if ( e->type() == QEvent::Wheel && isHeaderEditing() ) @@ -180,6 +170,86 @@ bool QtxTable::eventFilter( QObject* o, QEvent* e ) return QTable::eventFilter( o, e ); } +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::setNumRows( int rows ) +{ + endHeaderEdit(); + QTable::setNumRows( rows ); +} + +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::setNumCols( int cols ) +{ + endHeaderEdit(); + QTable::setNumCols( cols ); +} + +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::insertRows( int row, int count ) +{ + endHeaderEdit(); + QTable::insertRows( row, count ); +} + +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::insertColumns( int col, int count ) +{ + endHeaderEdit(); + QTable::insertColumns( col, count ); +} + +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::removeRow( int row ) +{ + endHeaderEdit(); + QTable::removeRow( row ); +} + +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::removeRows( const QMemArray& rows ) +{ + endHeaderEdit(); + QTable::removeRows( rows ); +} + +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::removeColumn( int col ) +{ + endHeaderEdit(); + QTable::removeColumn( col ); +} + +/*! + Reimplemented for internal reasons. + Firstly end the edition of header. +*/ +void QtxTable::removeColumns( const QMemArray& cols ) +{ + endHeaderEdit(); + QTable::removeColumns( cols ); +} + /*! SLOT: called on scroll */ @@ -197,6 +267,16 @@ void QtxTable::onHeaderSizeChange( int, int, int ) updateHeaderEditor(); } +/*! + Custom hide event handler +*/ +void QtxTable::hideEvent( QHideEvent* e ) +{ + endHeaderEdit(); + + QTable::hideEvent( e ); +} + /*! Custom resize event handler */ diff --git a/src/Qtx/QtxTable.h b/src/Qtx/QtxTable.h index b7175d08e..a7d4f3ebf 100644 --- a/src/Qtx/QtxTable.h +++ b/src/Qtx/QtxTable.h @@ -48,19 +48,29 @@ public: virtual bool eventFilter( QObject*, QEvent* ); + virtual void setNumRows( int ); + virtual void setNumCols( int ); + signals: void headerEdited( QHeader*, int ); void headerEdited( Orientation, int ); public slots: - virtual void hide(); virtual void setHeaderEditable( Orientation, bool ); + virtual void insertRows( int, int = 1 ); + virtual void insertColumns( int, int = 1 ); + virtual void removeRow( int ); + virtual void removeRows( const QMemArray& ); + virtual void removeColumn( int ); + virtual void removeColumns( const QMemArray& ); + private slots: void onScrollBarMoved( int ); void onHeaderSizeChange( int, int, int ); protected: + virtual void hideEvent( QHideEvent* ); virtual void resizeEvent( QResizeEvent* ); virtual bool beginHeaderEdit( Orientation, const int ); -- 2.39.2