1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

* Add a QPixmap-cache to the TreeView delegate.

This commit is contained in:
Christian Muehlhaeuser
2011-07-25 03:55:02 +02:00
parent d4ccbdfa56
commit 1a3cae012e
2 changed files with 13 additions and 1 deletions

View File

@@ -133,8 +133,18 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
QRect r = option.rect.adjusted( 4, 4, -option.rect.width() + option.rect.height() - 4, -4 );
// painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );
QPixmap scover;
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover;
painter->drawPixmap( r, cover.scaled( r.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
if ( m_cache.contains( cover.cacheKey() ) )
{
scover = m_cache.value( cover.cacheKey() );
}
else
{
scover = cover.scaled( r.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation );
m_cache.insert( cover.cacheKey(), scover );
}
painter->drawPixmap( r, scover );
QTextOption to;
to.setAlignment( Qt::AlignVCenter );

View File

@@ -43,6 +43,8 @@ private:
ArtistView* m_view;
TreeProxyModel* m_model;
mutable QHash< qint64, QPixmap > m_cache;
QPixmap m_nowPlayingIcon;
QPixmap m_defaultCover;
};