From: stv Date: Mon, 6 Jun 2005 09:26:20 +0000 (+0000) Subject: Multi columns support X-Git-Tag: T3_0_0_a2~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ec4f1f47028b00ac5b5d106ba51abba02b974bd7;p=modules%2Fgui.git Multi columns support --- diff --git a/src/Qtx/QtxListView.cxx b/src/Qtx/QtxListView.cxx index 801c59cb2..ad8be3cfd 100755 --- a/src/Qtx/QtxListView.cxx +++ b/src/Qtx/QtxListView.cxx @@ -77,6 +77,8 @@ QtxListView::~QtxListView() int QtxListView::addColumn( const QString& label, int width ) { int res = QListView::addColumn( label, width ); + for ( int i = myAppropriate.count(); i <= res; i++ ) + myAppropriate.append( 1 ); onHeaderResized(); return res; } @@ -84,6 +86,8 @@ int QtxListView::addColumn( const QString& label, int width ) int QtxListView::addColumn( const QIconSet& iconset, const QString& label, int width ) { int res = QListView::addColumn( iconset, label, width ); + for ( int i = myAppropriate.count(); i <= res; i++ ) + myAppropriate.append( 1 ); onHeaderResized(); return res; } @@ -91,9 +95,24 @@ int QtxListView::addColumn( const QIconSet& iconset, const QString& label, int w void QtxListView::removeColumn( int index ) { QListView::removeColumn( index ); + if ( index >= 0 && index < (int)myAppropriate.count() ) + myAppropriate.remove( myAppropriate.at( index ) ); onHeaderResized(); } +bool QtxListView::appropriate( const int index ) const +{ + return index >= 0 && index < (int)myAppropriate.count() && myAppropriate[index]; +} + +void QtxListView::setAppropriate( const int index, const bool on ) +{ + if ( index < 0 || index >= (int)myAppropriate.count() ) + return; + + myAppropriate[index] = on ? 1 : 0; +} + void QtxListView::resize( int w, int h ) { QListView::resize( w, h ); @@ -216,14 +235,18 @@ void QtxListView::onButtonClicked() return; myPopup->clear(); - for( int i=0, n=header()->count(); iinsertItem( header()->label( i ) ); - myPopup->setItemChecked( id, isShown( i ) ); + if ( appropriate( i ) ) + { + int id = myPopup->insertItem( header()->label( i ), i ); + myPopup->setItemChecked( id, isShown( i ) ); + } } int x = myButton->x(), y = myButton->y() + myButton->height(); - myPopup->exec( mapToGlobal( QPoint( x, y ) ) ); + if ( myPopup->count() ) + myPopup->exec( mapToGlobal( QPoint( x, y ) ) ); } void QtxListView::onShowHide( int id ) @@ -231,8 +254,7 @@ void QtxListView::onShowHide( int id ) if ( myHeaderState != HeaderButton ) return; - int ind = myPopup->indexOf( id ); - setShown( ind, !isShown( ind ) ); + setShown( id, !isShown( id ) ); } void QtxListView::viewportResizeEvent( QResizeEvent* e ) diff --git a/src/Qtx/QtxListView.h b/src/Qtx/QtxListView.h index 354b7a885..d17ad59e3 100755 --- a/src/Qtx/QtxListView.h +++ b/src/Qtx/QtxListView.h @@ -39,6 +39,9 @@ public: bool isShown( int ) const; void setShown( int, bool ); + bool appropriate( const int ) const; + virtual void setAppropriate( const int, const bool ); + virtual QSize sizeHint() const; virtual QSize minimumSizeHint() const; @@ -65,6 +68,7 @@ private: QPopupMenu* myPopup; QButton* myButton; ColumnsMap myColumns; + QIntList myAppropriate; int myHeaderState; };