]> git.sesse.net Git - vlc/commitdiff
Qt: playlist: use same context menu for both tree- and icon-view
authorJakob Leben <jleben@videolan.org>
Mon, 25 Jan 2010 12:52:53 +0000 (13:52 +0100)
committerJakob Leben <jleben@videolan.org>
Mon, 25 Jan 2010 12:52:53 +0000 (13:52 +0100)
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index d7eab18b269c33fe895e19f8b53aa9a8cea8f997..ea8ae94ca9f89be0bd782bc791d2be1ebf1485e0 100644 (file)
@@ -110,7 +110,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
              this, popupSelectColumn( QPoint ) );
     CONNECT( treeView, customContextMenuRequested( const QPoint & ),
-             this, treeViewPopup( const QPoint & ) );
+             this, playlistPopup( const QPoint & ) );
     CONNECT( model, currentChanged( const QModelIndex& ),
              this, handleExpansion( const QModelIndex& ) );
 
@@ -216,11 +216,15 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
     menu.exec( QCursor::pos() );
 }
 
-void StandardPLPanel::treeViewPopup( const QPoint &point )
+void StandardPLPanel::playlistPopup( const QPoint &point )
 {
-    QModelIndex index = treeView->indexAt( point );
-    QPoint globalPoint = treeView->viewport()->mapToGlobal( point );
-    QItemSelectionModel *selection = treeView->selectionModel();
+    QAbstractItemView *aView;
+    if ( treeView->isVisible() ) aView = treeView;
+    else aView = iconView;
+
+    QModelIndex index = aView->indexAt( point );
+    QPoint globalPoint = aView->viewport()->mapToGlobal( point );
+    QItemSelectionModel *selection = aView->selectionModel();
     QModelIndexList list = selection->selectedIndexes();
     model->popup( index, globalPoint, list );
 }
@@ -316,7 +320,10 @@ void StandardPLPanel::toggleView()
         {
             iconView = new PlIconView( model, this );
             layout->addWidget( iconView, 1, 0, 1, -1 );
-            installEventFilter( iconView );
+            //iconView->installEventFilter( this );
+            iconView->setContextMenuPolicy( Qt::CustomContextMenu );
+            CONNECT( iconView, customContextMenuRequested( const QPoint & ),
+                     this, playlistPopup( const QPoint & ) );
         }
         treeView->hide();
         iconView->show();
index 1730196989b2890c3f3ad62b059bacdd17bc4993..0f59996fae5e9219c66d96f10162ad333a6e90f5 100644 (file)
@@ -90,7 +90,7 @@ private slots:
     void popupSelectColumn( QPoint );
     void toggleColumnShown( int );
     void toggleView();
-    void treeViewPopup( const QPoint & );
+    void playlistPopup( const QPoint & );
 };
 
 #endif