]> git.sesse.net Git - vlc/commitdiff
Qt: make playlist tree-view popup menu work again
authorJakob Leben <jleben@videolan.org>
Mon, 25 Jan 2010 01:42:07 +0000 (02:42 +0100)
committerJakob Leben <jleben@videolan.org>
Mon, 25 Jan 2010 01:42:07 +0000 (02:42 +0100)
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index be568896b5e8df2db2af672dd0f2175adde2ebde..d7eab18b269c33fe895e19f8b53aa9a8cea8f997 100644 (file)
@@ -81,8 +81,11 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     treeView->setDragEnabled( true );
     treeView->setAcceptDrops( true );
     treeView->setDropIndicatorShown( true );
+    treeView->setContextMenuPolicy( Qt::CustomContextMenu );
+
+    //treeView->installEventFilter( this );
+    //<jleben> I guess we don't need that
 
-    installEventFilter( treeView );
     /* Saved Settings */
     getSettings()->beginGroup("Playlist");
     if( getSettings()->contains( "headerStateV2" ) )
@@ -106,6 +109,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
              model,activateItem( const QModelIndex& ) );
     CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
              this, popupSelectColumn( QPoint ) );
+    CONNECT( treeView, customContextMenuRequested( const QPoint & ),
+             this, treeViewPopup( const QPoint & ) );
     CONNECT( model, currentChanged( const QModelIndex& ),
              this, handleExpansion( const QModelIndex& ) );
 
@@ -211,6 +216,15 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
     menu.exec( QCursor::pos() );
 }
 
+void StandardPLPanel::treeViewPopup( const QPoint &point )
+{
+    QModelIndex index = treeView->indexAt( point );
+    QPoint globalPoint = treeView->viewport()->mapToGlobal( point );
+    QItemSelectionModel *selection = treeView->selectionModel();
+    QModelIndexList list = selection->selectedIndexes();
+    model->popup( index, globalPoint, list );
+}
+
 void StandardPLPanel::toggleColumnShown( int i )
 {
     treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) );
index bb060f49f9ec40bfa264881cc59e5dd6e682269b..1730196989b2890c3f3ad62b059bacdd17bc4993 100644 (file)
@@ -90,6 +90,7 @@ private slots:
     void popupSelectColumn( QPoint );
     void toggleColumnShown( int );
     void toggleView();
+    void treeViewPopup( const QPoint & );
 };
 
 #endif