Commit df8d2104 authored by Jakob Leben's avatar Jakob Leben

Qt: playlist: use same context menu for both tree- and icon-view

parent 8f145234
...@@ -110,7 +110,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -110,7 +110,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ), CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
this, popupSelectColumn( QPoint ) ); this, popupSelectColumn( QPoint ) );
CONNECT( treeView, customContextMenuRequested( const QPoint & ), CONNECT( treeView, customContextMenuRequested( const QPoint & ),
this, treeViewPopup( const QPoint & ) ); this, playlistPopup( const QPoint & ) );
CONNECT( model, currentChanged( const QModelIndex& ), CONNECT( model, currentChanged( const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) ); this, handleExpansion( const QModelIndex& ) );
...@@ -216,11 +216,15 @@ void StandardPLPanel::popupSelectColumn( QPoint pos ) ...@@ -216,11 +216,15 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
menu.exec( QCursor::pos() ); menu.exec( QCursor::pos() );
} }
void StandardPLPanel::treeViewPopup( const QPoint &point ) void StandardPLPanel::playlistPopup( const QPoint &point )
{ {
QModelIndex index = treeView->indexAt( point ); QAbstractItemView *aView;
QPoint globalPoint = treeView->viewport()->mapToGlobal( point ); if ( treeView->isVisible() ) aView = treeView;
QItemSelectionModel *selection = treeView->selectionModel(); else aView = iconView;
QModelIndex index = aView->indexAt( point );
QPoint globalPoint = aView->viewport()->mapToGlobal( point );
QItemSelectionModel *selection = aView->selectionModel();
QModelIndexList list = selection->selectedIndexes(); QModelIndexList list = selection->selectedIndexes();
model->popup( index, globalPoint, list ); model->popup( index, globalPoint, list );
} }
...@@ -316,7 +320,10 @@ void StandardPLPanel::toggleView() ...@@ -316,7 +320,10 @@ void StandardPLPanel::toggleView()
{ {
iconView = new PlIconView( model, this ); iconView = new PlIconView( model, this );
layout->addWidget( iconView, 1, 0, 1, -1 ); 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(); treeView->hide();
iconView->show(); iconView->show();
......
...@@ -90,7 +90,7 @@ private slots: ...@@ -90,7 +90,7 @@ private slots:
void popupSelectColumn( QPoint ); void popupSelectColumn( QPoint );
void toggleColumnShown( int ); void toggleColumnShown( int );
void toggleView(); void toggleView();
void treeViewPopup( const QPoint & ); void playlistPopup( const QPoint & );
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment