Album Applet and Unknown Album
Wyatt Epp
wyatt.epp at gmail.com
Sun Sep 16 09:27:53 UTC 2012
All,
I noticed recently that the Albums applet in context view doesn't have
an entry for the case of tracks that have no album tag. In the
collection browser, this is represented by an album entry called
"Unknown Album", and I enquired on IRC about whether I should file a
bug about it or wait for the QML context changes to land. However,
after a discussion about why this is desirable in the first place, I
took a look at the code at src/context/applets/albums/AlbumItem.cpp to
see if it would be easy to just add it and found something rather
peculiar in AlbumItem::update():
void
AlbumItem::update()
{
if( !m_album )
return;
Meta::TrackList tracks = m_album->tracks();
if( !tracks.isEmpty() )
+--- 6 lines: {-----------------------------------------------------
QString albumName = m_album->name();
albumName = albumName.isEmpty() ? i18n("Unknown") : albumName;
QString name = ( m_showArtist && m_album->hasAlbumArtist() )
? QString( "%1 - %2" ).arg(
m_album->albumArtist()->name(), albumName )
: albumName;
setData( name, NameRole );
qint64 totalTime = 0;
foreach( Meta::TrackPtr item, tracks )
totalTime += item->length();
QString trackCount = i18np( "%1 track", "%1 tracks", tracks.size() );
QString lengthText = QString( "%1, %2" ).arg( trackCount,
Meta::msToPrettyTime( totalTime ) );
setData( lengthText, AlbumLengthRole );
QPixmap cover = The::svgHandler()->imageWithBorder( m_album,
m_iconSize, 3 );
setIcon( QIcon( cover ) );
}
You may not remember, but in Amarok 1.4 the equivalent of the Albums
applet showed an "Unknown" entry that grouped tracks lacking an album
tag by an artist in the manner I describe. Now, I admit I'm not a
C++/Qt guru or anything, but if I'm reading this right, thabove code
does exactly that. Aside from the part where it's not working
(verified with someone else) and I'm not quite sure how to figure out
why. (If I had to guess, maybe "Unknown Album" is doesn't have an
associated Meta::AlbumPtr (m_album) so it returns immediately?)
Thoughts?
Cheers,
Wyatt Epp
More information about the Amarok-devel
mailing list