Salome HOME
Splash screen was implemented. Changes in packages SUIT and Session are integrated.
[modules/gui.git] / src / Qtx / QtxListView.cxx
index 2ae608b74df0661611d80c4ce2b82120d9c2d87c..6b3946f2c1e9f210c4544eca906969a2d04d75bf 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() ) );
 }
 
@@ -176,16 +179,21 @@ void QtxListView::setShown( int ind, bool sh )
   }
   else
   {
-    data.width = columnWidth( ind );
-    data.resizeable = header()->isResizeEnabled( ind );
+    int w = columnWidth( ind );
+    bool r = header()->isResizeEnabled( ind );
     setColumnWidth( ind, 0 );
     header()->setResizeEnabled( false, ind );
+    data.width = w;
+    data.resizeable = r;
   }
   updateContents();
 }
 
 void QtxListView::setColumnWidth( int c, int w )
 {
+  if ( myColumns.contains( c ) )
+    myColumns[c].width = w;
+
   QListView::setColumnWidth( c, !myColumns.contains( c ) ? w : 0 );
 }
 
@@ -247,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++ )
   {
@@ -261,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 ) );
 }
 
@@ -280,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 QListView::eventFilter( o, e );
+}