branches/stable/extragear/multimedia/amarok/src
Seb Ruiz
ruiz at kde.org
Tue Oct 9 05:08:51 UTC 2007
SVN commit 723237 by seb:
Fix random album mode with compilations. Patch thanks to Siavosh Benabbas. Sorry it took so long, I've been away.
BUG: 133164
CCMAIL: sbenabas at gmail.com
CCMAIL: amarok at kde.org
M +16 -4 playlistitem.cpp
--- branches/stable/extragear/multimedia/amarok/src/playlistitem.cpp #723236:723237
@@ -417,7 +417,8 @@
return m_album->tracks.at( index + 1 );
if( track() )
for( int i = 0, n = m_album->tracks.count(); i < n; ++i )
- if( m_album->tracks.at( i )->track() > track() )
+ if( m_album->tracks.at( i )->discNumber() > discNumber() ||
+ ( m_album->tracks.at( i )->discNumber() == discNumber() && m_album->tracks.at( i )->track() > track() ) )
return m_album->tracks.at( i );
else
for( QListViewItemIterator it( const_cast<PlaylistItem*>(this), QListViewItemIterator::Visible ); *it; ++it )
@@ -440,7 +441,9 @@
return m_album->tracks.at( index - 1 );
if( track() )
for( int i = m_album->tracks.count() - 1; i >= 0; --i )
- if( m_album->tracks.at( i )->track() && m_album->tracks.at( i )->track() < track() )
+ if( m_album->tracks.at( i )->track() &&
+ ( m_album->tracks.at( i )->discNumber() < discNumber() ||
+ ( m_album->tracks.at( i )->discNumber() == discNumber() && m_album->tracks.at( i )->track() < track() ) ) )
return m_album->tracks.at( i );
else
for( QListViewItemIterator it( const_cast<PlaylistItem*>(this), QListViewItemIterator::Visible ); *it; --it )
@@ -1028,11 +1031,20 @@
if( Amarok::entireAlbums() && m_album )
{
const uint prevCount = m_album->tracks.count();
- if( !track() || !m_album->tracks.count() || ( m_album->tracks.getLast()->track() && m_album->tracks.getLast()->track() < track() ) )
+ // Multiple tracks with same track number are possible;
+ // e.g. with "various_artist" albums or albums with multiple disks.
+ // We are trying to keep m_album->tracks sorted first by discNumber() and then by track().
+ // It seems that the following assumption is made for the following:
+ // ``Either all the tracks in an album have their track()'s set (to nonzero) or none of them have.''
+ if( !track() || !m_album->tracks.count() ||
+ ( m_album->tracks.getLast()->track() &&
+ ( ( m_album->tracks.getLast()->discNumber() < discNumber() ) ||
+ ( m_album->tracks.getLast()->discNumber() == discNumber() && m_album->tracks.getLast()->track() < track() ) ) ) )
m_album->tracks.append( this );
else
for( int i = 0, n = m_album->tracks.count(); i < n; ++i )
- if( m_album->tracks.at(i)->track() > track() || !m_album->tracks.at(i)->track() )
+ if(!m_album->tracks.at(i)->track() || m_album->tracks.at(i)->discNumber() > discNumber() ||
+ ( m_album->tracks.at(i)->discNumber() == discNumber() && m_album->tracks.at(i)->track() > track() ) )
{
m_album->tracks.insert( i, this );
break;
More information about the Amarok
mailing list