[vlc-devel] commit: Qt: playlist: use same context menu for both tree- and icon-view ( Jakob Leben )
git version control
git at videolan.org
Mon Jan 25 13:54:59 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Mon Jan 25 13:52:53 2010 +0100| [df8d2104697a38c439bc9f8944cbb28f598990c0] | committer: Jakob Leben
Qt: playlist: use same context menu for both tree- and icon-view
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=df8d2104697a38c439bc9f8944cbb28f598990c0
---
.../gui/qt4/components/playlist/standardpanel.cpp | 19 +++++++++++++------
.../gui/qt4/components/playlist/standardpanel.hpp | 2 +-
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index d7eab18..ea8ae94 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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();
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index 1730196..0f59996 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -90,7 +90,7 @@ private slots:
void popupSelectColumn( QPoint );
void toggleColumnShown( int );
void toggleView();
- void treeViewPopup( const QPoint & );
+ void playlistPopup( const QPoint & );
};
#endif
More information about the vlc-devel
mailing list