mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-30 09:10:53 +02:00
Make it possible to show the artist in the AlbumDelegate
This commit is contained in:
@@ -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 );
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user