Skip to content

Commit

Permalink
* Fixed freezing when filtering out the current item in a tree-view a…
Browse files Browse the repository at this point in the history
…nd trying to advance to the next track.
  • Loading branch information
muesli committed Nov 8, 2011
1 parent f3eb8fa commit 6ec8f12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
12 changes: 3 additions & 9 deletions src/libtomahawk/playlist/trackproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
qDebug() << Q_FUNC_INFO;

QModelIndex idx = index( 0, 0 );
if( rowCount() )
if ( rowCount() )
{
if ( m_shuffled )
{
Expand All @@ -123,12 +123,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
idx = currentIndex();

// random mode is disabled
if ( m_repeatMode == PlaylistInterface::RepeatOne )
{
// repeat one track
idx = index( idx.row(), 0 );
}
else
if ( m_repeatMode != PlaylistInterface::RepeatOne )
{
// keep progressing through the playlist normally
idx = index( idx.row() + itemsAway, 0 );
Expand All @@ -152,7 +147,7 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )
}

// Try to find the next available PlaylistItem (with results)
if ( idx.isValid() ) do
while ( idx.isValid() )
{
TrackModelItem* item = itemFromIndex( mapToSource( idx ) );
if ( item && item->query()->playable() )
Expand All @@ -165,7 +160,6 @@ TrackProxyModel::siblingItem( int itemsAway, bool readOnly )

idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0 );
}
while ( idx.isValid() );

if ( !readOnly )
setCurrentIndex( QModelIndex() );
Expand Down
17 changes: 9 additions & 8 deletions src/libtomahawk/playlist/treeproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,14 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
return Tomahawk::result_ptr();

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 ( m_repeatMode != PlaylistInterface::RepeatOne )
idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
}

if ( !idx.isValid() && m_repeatMode == PlaylistInterface::RepeatAll )
{
Expand All @@ -355,11 +358,8 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
}

// Try to find the next available PlaylistItem (with results)
if ( idx.isValid() ) do
while ( idx.isValid() )
{
if ( !idx.isValid() )
break;

TreeModelItem* item = itemFromIndex( mapToSource( idx ) );
if ( item && !item->result().isNull() && item->result()->isOnline() )
{
Expand All @@ -368,8 +368,9 @@ TreeProxyModel::siblingItem( int itemsAway, bool readOnly )
setCurrentIndex( idx );
return item->result();
}

idx = index( idx.row() + ( itemsAway > 0 ? 1 : -1 ), 0, idx.parent() );
}
while ( idx.isValid() );

if ( !readOnly )
setCurrentIndex( QModelIndex() );
Expand Down

0 comments on commit 6ec8f12

Please sign in to comment.