mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Add shuffle/repeat support to treeview
This commit is contained in:
parent
51d89c7210
commit
5df328424d
@ -333,10 +333,30 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
|
||||
|
||||
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)
|
||||
if ( idx.isValid() ) do
|
||||
{
|
||||
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
|
||||
if ( !idx.isValid() )
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user