Salome HOME
Bug 8970
authorasl <asl@opencascade.com>
Fri, 17 Jun 2005 08:37:03 +0000 (08:37 +0000)
committerasl <asl@opencascade.com>
Fri, 17 Jun 2005 08:37:03 +0000 (08:37 +0000)
src/ObjBrowser/OB_Browser.cxx
src/Qtx/QtxListView.cxx
src/Qtx/QtxListView.h

index f3fefa6fe976e45869f3768e0956ba30dd1b2c81..bc429a7d0ba70d7eff3f1dff59768058665678c8 100755 (executable)
@@ -963,7 +963,7 @@ bool OB_Browser::eventFilter( QObject* o, QEvent* e )
 
 void OB_Browser::contextMenuPopup( QPopupMenu* menu )
 {
-  QValueList<int> cols;
+/*  QValueList<int> cols;
   for ( QMap<int, int>::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 );
index e00dc39ef802870833e0cbe2fc27a60465d370c9..c45e6c7e5b9f93ab220de8d43c107d82934b37b2 100755 (executable)
@@ -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 );
+}
index adf2968f3e141795b496a8c92aa1c18d97184890..41b63577e99b99d898d394a62c427fd586815fb6 100755 (executable)
@@ -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;