Commit 9c191f2f authored by Jakob Leben's avatar Jakob Leben

Qt: make playlist tree-view popup menu work again

parent a706d73d
...@@ -81,8 +81,11 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -81,8 +81,11 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
treeView->setDragEnabled( true ); treeView->setDragEnabled( true );
treeView->setAcceptDrops( true ); treeView->setAcceptDrops( true );
treeView->setDropIndicatorShown( true ); treeView->setDropIndicatorShown( true );
treeView->setContextMenuPolicy( Qt::CustomContextMenu );
//treeView->installEventFilter( this );
//<jleben> I guess we don't need that
installEventFilter( treeView );
/* Saved Settings */ /* Saved Settings */
getSettings()->beginGroup("Playlist"); getSettings()->beginGroup("Playlist");
if( getSettings()->contains( "headerStateV2" ) ) if( getSettings()->contains( "headerStateV2" ) )
...@@ -106,6 +109,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -106,6 +109,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
model,activateItem( const QModelIndex& ) ); model,activateItem( const QModelIndex& ) );
CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ), CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
this, popupSelectColumn( QPoint ) ); this, popupSelectColumn( QPoint ) );
CONNECT( treeView, customContextMenuRequested( const QPoint & ),
this, treeViewPopup( const QPoint & ) );
CONNECT( model, currentChanged( const QModelIndex& ), CONNECT( model, currentChanged( const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) ); this, handleExpansion( const QModelIndex& ) );
...@@ -211,6 +216,15 @@ void StandardPLPanel::popupSelectColumn( QPoint pos ) ...@@ -211,6 +216,15 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
menu.exec( QCursor::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 ) void StandardPLPanel::toggleColumnShown( int i )
{ {
treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) ); treeView->setColumnHidden( i, !treeView->isColumnHidden( i ) );
......
...@@ -90,6 +90,7 @@ private slots: ...@@ -90,6 +90,7 @@ private slots:
void popupSelectColumn( QPoint ); void popupSelectColumn( QPoint );
void toggleColumnShown( int ); void toggleColumnShown( int );
void toggleView(); void toggleView();
void treeViewPopup( 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