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,
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();
......
......@@ -90,7 +90,7 @@ private slots:
void popupSelectColumn( QPoint );
void toggleColumnShown( int );
void toggleView();
void treeViewPopup( const QPoint & );
void playlistPopup( const QPoint & );
};
#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