1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-30 01:00:13 +02:00

Make it possible to show the artist in the AlbumDelegate

This commit is contained in:
Uwe L. Korn
2013-07-08 21:29:04 +02:00
parent 5ef778fd85
commit 0af3deea56
2 changed files with 10 additions and 3 deletions

View File

@@ -43,10 +43,11 @@
using namespace Tomahawk;
AlbumItemDelegate::AlbumItemDelegate( TrackView* parent, PlayableProxyModel* proxy )
AlbumItemDelegate::AlbumItemDelegate( TrackView* parent, PlayableProxyModel* proxy, bool showArtist )
: PlaylistItemDelegate( parent, proxy )
, m_view( parent )
, m_model( proxy )
, m_showArtist( showArtist )
{
}
@@ -119,7 +120,12 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
leftRect.setWidth( leftRect.width() - rightRect.width() );
}
const QString text = painter->fontMetrics().elidedText( track->track(), Qt::ElideRight, leftRect.width() );
QString rawText = track->track();
if ( m_showArtist )
{
rawText = QString( "%1 - %2" ).arg( track->artist() ).arg( rawText );
}
const QString text = painter->fontMetrics().elidedText( rawText, Qt::ElideRight, leftRect.width() );
painter->setPen( opt.palette.text().color() );
painter->drawText( leftRect, text, m_centerOption );

View File

@@ -40,7 +40,7 @@ class DLLEXPORT AlbumItemDelegate : public PlaylistItemDelegate
Q_OBJECT
public:
AlbumItemDelegate( TrackView* parent = 0, PlayableProxyModel* proxy = 0 );
AlbumItemDelegate( TrackView* parent = 0, PlayableProxyModel* proxy = 0, bool showArtist = false );
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
@@ -50,6 +50,7 @@ protected:
private:
TrackView* m_view;
PlayableProxyModel* m_model;
bool m_showArtist;
};
#endif // ALBUMITEMDELEGATE_H