1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-10 08:04:25 +02:00

* When shuffle is enabled and we want to play the previous track, actually go back in shuffle history.

This commit is contained in:
Christian Muehlhaeuser
2012-11-15 17:13:14 +01:00
parent d5c9d523db
commit 21a1dcfeb3

View File

@@ -63,10 +63,10 @@ QList< Tomahawk::query_ptr >
PlayableProxyModelPlaylistInterface::tracks()
{
if ( m_proxyModel.isNull() )
return QList< Tomahawk::query_ptr >();
return QList< query_ptr >();
PlayableProxyModel* proxyModel = m_proxyModel.data();
QList<Tomahawk::query_ptr> queries;
QList< query_ptr > queries;
for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ )
{
@@ -99,7 +99,7 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_shuffled << itemsAway << readOnly;
if ( m_proxyModel.isNull() )
return Tomahawk::result_ptr();
return result_ptr();
PlayableProxyModel* proxyModel = m_proxyModel.data();
@@ -112,6 +112,19 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
if ( proxyModel->rowCount() )
{
if ( m_shuffled )
{
if ( itemsAway < 0 )
{
if ( m_shuffleHistory.count() > 1 )
{
m_shuffleHistory.removeLast();
if ( proxyModel->itemFromQuery( m_shuffleHistory.last() ) )
idx = proxyModel->mapFromSource( proxyModel->itemFromQuery( m_shuffleHistory.takeLast() )->index );
}
else
return result_ptr();
}
else
{
// random mode is enabled
if ( m_shuffleCache.isValid() )
@@ -146,6 +159,7 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
}
}
}
}
else if ( proxyModel->currentIndex().isValid() )
{
// random mode is disabled
@@ -196,7 +210,8 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
if ( !readOnly )
proxyModel->setCurrentIndex( QModelIndex() );
return Tomahawk::result_ptr();
return result_ptr();
}
@@ -204,7 +219,7 @@ Tomahawk::result_ptr
PlayableProxyModelPlaylistInterface::currentItem() const
{
if ( m_proxyModel.isNull() )
return Tomahawk::result_ptr();
return result_ptr();
PlayableProxyModel* proxyModel = m_proxyModel.data();
@@ -212,6 +227,6 @@ PlayableProxyModelPlaylistInterface::currentItem() const
if ( item && !item->query().isNull() && item->query()->playable() )
return item->query()->results().at( 0 );
return Tomahawk::result_ptr();
return result_ptr();
}