mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-14 10:05:32 +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:
@@ -63,10 +63,10 @@ QList< Tomahawk::query_ptr >
|
|||||||
PlayableProxyModelPlaylistInterface::tracks()
|
PlayableProxyModelPlaylistInterface::tracks()
|
||||||
{
|
{
|
||||||
if ( m_proxyModel.isNull() )
|
if ( m_proxyModel.isNull() )
|
||||||
return QList< Tomahawk::query_ptr >();
|
return QList< query_ptr >();
|
||||||
|
|
||||||
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
||||||
QList<Tomahawk::query_ptr> queries;
|
QList< query_ptr > queries;
|
||||||
|
|
||||||
for ( int i = 0; i < proxyModel->rowCount( QModelIndex() ); i++ )
|
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;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_shuffled << itemsAway << readOnly;
|
||||||
|
|
||||||
if ( m_proxyModel.isNull() )
|
if ( m_proxyModel.isNull() )
|
||||||
return Tomahawk::result_ptr();
|
return result_ptr();
|
||||||
|
|
||||||
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
||||||
|
|
||||||
@@ -112,6 +112,19 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
|||||||
if ( proxyModel->rowCount() )
|
if ( proxyModel->rowCount() )
|
||||||
{
|
{
|
||||||
if ( m_shuffled )
|
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
|
// random mode is enabled
|
||||||
if ( m_shuffleCache.isValid() )
|
if ( m_shuffleCache.isValid() )
|
||||||
@@ -146,6 +159,7 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if ( proxyModel->currentIndex().isValid() )
|
else if ( proxyModel->currentIndex().isValid() )
|
||||||
{
|
{
|
||||||
// random mode is disabled
|
// random mode is disabled
|
||||||
@@ -196,7 +210,8 @@ PlayableProxyModelPlaylistInterface::siblingItem( int itemsAway, bool readOnly )
|
|||||||
|
|
||||||
if ( !readOnly )
|
if ( !readOnly )
|
||||||
proxyModel->setCurrentIndex( QModelIndex() );
|
proxyModel->setCurrentIndex( QModelIndex() );
|
||||||
return Tomahawk::result_ptr();
|
|
||||||
|
return result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -204,7 +219,7 @@ Tomahawk::result_ptr
|
|||||||
PlayableProxyModelPlaylistInterface::currentItem() const
|
PlayableProxyModelPlaylistInterface::currentItem() const
|
||||||
{
|
{
|
||||||
if ( m_proxyModel.isNull() )
|
if ( m_proxyModel.isNull() )
|
||||||
return Tomahawk::result_ptr();
|
return result_ptr();
|
||||||
|
|
||||||
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
PlayableProxyModel* proxyModel = m_proxyModel.data();
|
||||||
|
|
||||||
@@ -212,6 +227,6 @@ PlayableProxyModelPlaylistInterface::currentItem() const
|
|||||||
if ( item && !item->query().isNull() && item->query()->playable() )
|
if ( item && !item->query().isNull() && item->query()->playable() )
|
||||||
return item->query()->results().at( 0 );
|
return item->query()->results().at( 0 );
|
||||||
|
|
||||||
return Tomahawk::result_ptr();
|
return result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user