mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +02:00
Add shuffle/repeat support to treeview
This commit is contained in:
@@ -333,10 +333,30 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
|
|||||||
|
|
||||||
QModelIndex idx = currentIndex();
|
QModelIndex idx = currentIndex();
|
||||||
|
|
||||||
|
if ( m_shuffled )
|
||||||
|
idx = index( qrand() % rowCount( idx.parent() ), 0, idx.parent() );
|
||||||
|
else if ( m_repeatMode == PlaylistInterface::RepeatOne )
|
||||||
|
idx = index( idx.row(), 0, idx.parent() );
|
||||||
|
else
|
||||||
|
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||||
|
|
||||||
|
if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
|
||||||
|
{
|
||||||
|
if ( itemsAway > 0 )
|
||||||
|
{
|
||||||
|
// reset to first item
|
||||||
|
idx = index( 0, 0, currentIndex().parent() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// reset to last item
|
||||||
|
idx = index( rowCount( currentIndex().parent() ) - 1, 0, currentIndex().parent() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try to find the next available PlaylistItem (with results)
|
// Try to find the next available PlaylistItem (with results)
|
||||||
if ( idx.isValid() ) do
|
if ( idx.isValid() ) do
|
||||||
{
|
{
|
||||||
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
|
||||||
if ( !idx.isValid() )
|
if ( !idx.isValid() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user