From: asl Date: Fri, 17 Jun 2005 08:37:03 +0000 (+0000) Subject: Bug 8970 X-Git-Tag: T3_0_0_a4~93 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=85e5b4d84e563cdba6b57d1aa73fc18d071e3574;p=modules%2Fgui.git Bug 8970 --- diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index f3fefa6fe..bc429a7d0 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -963,7 +963,7 @@ bool OB_Browser::eventFilter( QObject* o, QEvent* e ) void OB_Browser::contextMenuPopup( QPopupMenu* menu ) { - QValueList cols; +/* QValueList cols; for ( QMap::ConstIterator it = myColumnIds.begin(); it != myColumnIds.end(); ++it ) { if ( appropriateColumn( it.key() ) ) @@ -983,7 +983,7 @@ void OB_Browser::contextMenuPopup( QPopupMenu* menu ) menu->setItemParameter( id, *iter ); } if ( menu->count() != num ) - menu->insertSeparator(); + menu->insertSeparator();*/ DataObjectList selected; getSelected( selected ); diff --git a/src/Qtx/QtxListView.cxx b/src/Qtx/QtxListView.cxx index e00dc39ef..c45e6c7e5 100755 --- a/src/Qtx/QtxListView.cxx +++ b/src/Qtx/QtxListView.cxx @@ -62,11 +62,14 @@ void QtxListView::initialize() myButton = but; connect( myButton, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - - myPopup = new QPopupMenu( this ); - connect( myPopup, SIGNAL( activated( int ) ), this, SLOT( onShowHide( int ) ) ); + } + else + { + header()->installEventFilter( this ); } + myPopup = new QPopupMenu( this ); + connect( myPopup, SIGNAL( activated( int ) ), this, SLOT( onShowHide( int ) ) ); connect( header(), SIGNAL( sizeChange( int, int, int ) ), this, SLOT( onHeaderResized() ) ); } @@ -252,11 +255,8 @@ void QtxListView::onHeaderResized() } } -void QtxListView::onButtonClicked() +void QtxListView::showPopup( const int x, const int y ) { - if ( myHeaderState != HeaderButton ) - return; - myPopup->clear(); for ( int i = 0; i < columns(); i++ ) { @@ -266,17 +266,27 @@ void QtxListView::onButtonClicked() myPopup->setItemChecked( id, isShown( i ) ); } } - int x = myButton->x(), - y = myButton->y() + myButton->height(); - if ( myPopup->count() ) + + if( myPopup->count() ) myPopup->exec( mapToGlobal( QPoint( x, y ) ) ); } -void QtxListView::onShowHide( int id ) +void QtxListView::onButtonClicked() { if ( myHeaderState != HeaderButton ) return; + int x = myButton->x(), + y = myButton->y() + myButton->height(); + + showPopup( x, y ); +} + +void QtxListView::onShowHide( int id ) +{ + //if ( myHeaderState != HeaderButton ) + // return; + setShown( id, !isShown( id ) ); } @@ -285,3 +295,18 @@ void QtxListView::viewportResizeEvent( QResizeEvent* e ) QListView::viewportResizeEvent( e ); onHeaderResized(); } + +bool QtxListView::eventFilter( QObject* o, QEvent* e ) +{ + if( o==header() && e->type()==QEvent::MouseButtonPress ) + { + QMouseEvent* me = ( QMouseEvent* )e; + if( me->button()==Qt::RightButton ) + { + showPopup( me->x()+2, me->y()+2 ); + return true; + } + } + + return QObject::eventFilter( o, e ); +} diff --git a/src/Qtx/QtxListView.h b/src/Qtx/QtxListView.h index adf2968f3..41b63577e 100755 --- a/src/Qtx/QtxListView.h +++ b/src/Qtx/QtxListView.h @@ -58,6 +58,8 @@ protected slots: protected: virtual void viewportResizeEvent( QResizeEvent* ); + virtual bool eventFilter( QObject*, QEvent* ); + virtual void showPopup( const int x, const int y ); private: typedef struct { int width; bool resizeable; } ColumnData;