From ad5ccc8f4b31497cafa271aa188312a1eba29ce9 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 24 Sep 2014 05:59:17 +0200 Subject: [PATCH] * Move along item selection with song change, if the previously playing track is the single selected item in a TrackView. --- src/libtomahawk/playlist/TrackView.cpp | 13 +++++++++++++ src/libtomahawk/playlist/TrackView.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/libtomahawk/playlist/TrackView.cpp b/src/libtomahawk/playlist/TrackView.cpp index e2bb59ac0..89c80f487 100644 --- a/src/libtomahawk/playlist/TrackView.cpp +++ b/src/libtomahawk/playlist/TrackView.cpp @@ -162,6 +162,7 @@ TrackView::setProxyModel( PlayableProxyModel* model ) disconnect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( verifySize() ) ); disconnect( m_proxyModel, SIGNAL( expandRequest( QPersistentModelIndex ) ), this, SLOT( expand( QPersistentModelIndex ) ) ); disconnect( m_proxyModel, SIGNAL( selectRequest( QPersistentModelIndex ) ), this, SLOT( select( QPersistentModelIndex ) ) ); + disconnect( m_proxyModel, SIGNAL( currentIndexChanged( QModelIndex, QModelIndex ) ), this, SLOT( onCurrentIndexChanged( QModelIndex, QModelIndex ) ) ); } m_proxyModel = model; @@ -174,6 +175,7 @@ TrackView::setProxyModel( PlayableProxyModel* model ) connect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( verifySize() ) ); connect( m_proxyModel, SIGNAL( expandRequest( QPersistentModelIndex ) ), SLOT( expand( QPersistentModelIndex ) ) ); connect( m_proxyModel, SIGNAL( selectRequest( QPersistentModelIndex ) ), SLOT( select( QPersistentModelIndex ) ) ); + connect( m_proxyModel, SIGNAL( currentIndexChanged( QModelIndex, QModelIndex ) ), SLOT( onCurrentIndexChanged( QModelIndex, QModelIndex ) ) ); m_delegate = new PlaylistItemDelegate( this, m_proxyModel ); QTreeView::setItemDelegate( m_delegate ); @@ -276,6 +278,17 @@ TrackView::onModelEmptyCheck() } +void +TrackView::onCurrentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex ) +{ + if ( selectedIndexes().count() == 1 && currentIndex() == oldIndex ) + { + selectionModel()->select( newIndex, QItemSelectionModel::SelectCurrent ); + currentChanged( newIndex, oldIndex ); + } +} + + void TrackView::onViewChanged() { diff --git a/src/libtomahawk/playlist/TrackView.h b/src/libtomahawk/playlist/TrackView.h index 7ea641a64..2fd9dfb05 100644 --- a/src/libtomahawk/playlist/TrackView.h +++ b/src/libtomahawk/playlist/TrackView.h @@ -130,6 +130,7 @@ private slots: void onFilterChanged( const QString& filter ); void onModelFilling(); void onModelEmptyCheck(); + void onCurrentIndexChanged( const QModelIndex& newIndex, const QModelIndex& oldIndex ); void onCustomContextMenu( const QPoint& pos );