1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

use the sourceitem decoration role instead so we get teh supercollection icon

This commit is contained in:
Leo Franchi
2011-04-24 21:06:33 -04:00
parent 2507f8306c
commit 033987eedb

View File

@@ -404,12 +404,14 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
CollectionItem* colItem = qobject_cast< CollectionItem* >( item ); CollectionItem* colItem = qobject_cast< CollectionItem* >( item );
Q_ASSERT( colItem ); Q_ASSERT( colItem );
bool status = !( !colItem || colItem->source().isNull() || !colItem->source()->isOnline() ); bool status = !( !colItem || colItem->source().isNull() || !colItem->source()->isOnline() );
QPixmap avatar( RESPATH "images/user-avatar.png" );
QString tracks; QString tracks;
QString name = index.data().toString(); QString name = index.data().toString();
int figWidth = 0; int figWidth = 0;
QRect iconRect = option.rect.adjusted( 4, 6, -option.rect.width() + option.rect.height() - 12 + 4, -6 );
QPixmap avatar = index.data( Qt::DecorationRole ).value< QIcon >().pixmap( iconRect.size() );
if ( status && colItem && !colItem->source().isNull() ) if ( status && colItem && !colItem->source().isNull() )
{ {
tracks = QString::number( colItem->source()->trackCount() ); tracks = QString::number( colItem->source()->trackCount() );
@@ -419,7 +421,6 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
name = colItem->source()->friendlyName(); name = colItem->source()->friendlyName();
} }
QRect iconRect = option.rect.adjusted( 4, 6, -option.rect.width() + option.rect.height() - 12 + 4, -6 );
painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) ); painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );