1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 16:44:05 +02:00

* Fixed going back in shuffle history.

This commit is contained in:
Christian Muehlhaeuser
2012-11-28 09:38:56 +01:00
parent 3ce0686e42
commit 748bc99808

View File

@@ -140,6 +140,19 @@ PlayableProxyModelPlaylistInterface::setCurrentIndex( qint64 index )
} }
else else
{ {
if ( m_shuffled && m_shuffleHistory.count() > 1 )
{
if ( m_proxyModel.data()->itemFromQuery( m_shuffleHistory.at( m_shuffleHistory.count() - 2 ) ) &&
( m_proxyModel.data()->mapFromSource( item->index ) == m_proxyModel.data()->mapFromSource( m_proxyModel.data()->itemFromQuery( m_shuffleHistory.at( m_shuffleHistory.count() - 2 ) )->index ) ) )
{
// Note: the following lines aren't by mistake:
// We detected that we're going to the previous track in our shuffle history and hence we want to remove the currently playing and the previous track from the shuffle history.
// The upcoming track will be added right back to the history further down below in this method.
m_shuffleHistory.removeLast();
m_shuffleHistory.removeLast();
}
}
m_proxyModel.data()->setCurrentIndex( m_proxyModel.data()->mapFromSource( item->index ) ); m_proxyModel.data()->setCurrentIndex( m_proxyModel.data()->mapFromSource( item->index ) );
m_shuffleHistory << queryAt( index ); m_shuffleHistory << queryAt( index );
m_shuffleCache = QPersistentModelIndex(); m_shuffleCache = QPersistentModelIndex();
@@ -169,9 +182,8 @@ PlayableProxyModelPlaylistInterface::siblingIndex( int itemsAway, qint64 rootInd
{ {
if ( m_shuffleHistory.count() > 1 ) if ( m_shuffleHistory.count() > 1 )
{ {
m_shuffleHistory.removeLast(); if ( proxyModel->itemFromQuery( m_shuffleHistory.at( m_shuffleHistory.count() - 2 ) ) )
if ( proxyModel->itemFromQuery( m_shuffleHistory.last() ) ) idx = proxyModel->mapFromSource( proxyModel->itemFromQuery( m_shuffleHistory.at( m_shuffleHistory.count() - 2 ) )->index );
idx = proxyModel->mapFromSource( proxyModel->itemFromQuery( m_shuffleHistory.takeLast() )->index );
} }
else else
return -1; return -1;
@@ -231,6 +243,7 @@ PlayableProxyModelPlaylistInterface::siblingIndex( int itemsAway, qint64 rootInd
idx = proxyModel->mapFromSource( pitem->index ); idx = proxyModel->mapFromSource( pitem->index );
} }
if ( idx.isValid() )
idx = proxyModel->index( idx.row() + itemsAway, 0 ); idx = proxyModel->index( idx.row() + itemsAway, 0 );
} }
} }