[vlc-devel] commit: Qt: make playlist tree-view popup menu work again (Jakob Leben )

git version control git at videolan.org
Mon Jan 25 02:43:31 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Mon Jan 25 02:42:07 2010 +0100| [9c191f2fbb13aa7162d61c52a15dd290702fb803] | committer: Jakob Leben 

Qt: make playlist tree-view popup menu work again

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9c191f2fbb13aa7162d61c52a15dd290702fb803
---

 .../gui/qt4/components/playlist/standardpanel.cpp  |   16 +++++++++++++++-
 .../gui/qt4/components/playlist/standardpanel.hpp  |    1 +
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index be56889..d7eab18 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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 ) );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index bb060f4..1730196 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -90,6 +90,7 @@ private slots:
     void popupSelectColumn( QPoint );
     void toggleColumnShown( int );
     void toggleView();
+    void treeViewPopup( const QPoint & );
 };
 
 #endif




More information about the vlc-devel mailing list