From 671d96383b2668ef773a49ba943328ddf0c98420 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 25 Feb 2015 17:48:37 +0100 Subject: icon delegates now use a pixmap cache to improve rendering performance --- src/icondelegate.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/icondelegate.cpp') diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp index 8c2fe5cc..794ac7f3 100644 --- a/src/icondelegate.cpp +++ b/src/icondelegate.cpp @@ -22,6 +22,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include IconDelegate::IconDelegate(QObject *parent) @@ -34,7 +35,7 @@ void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, { QStyledItemDelegate::paint(painter, option, index); - QList icons = getIcons(index); + QList icons = getIcons(index); int x = 4; painter->save(); @@ -43,8 +44,14 @@ void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, iconWidth = std::min(16, iconWidth); painter->translate(option.rect.topLeft()); - for (auto iter = icons.begin(); iter != icons.end(); ++iter) { - painter->drawPixmap(x, 2, iconWidth, iconWidth, iter->pixmap(QSize(iconWidth, iconWidth))); + for (const QString &iconId : icons) { + QPixmap icon; + QString fullIconId = QString("%1_%2").arg(iconId).arg(iconWidth); + if (!QPixmapCache::find(fullIconId, &icon)) { + icon = QIcon(iconId).pixmap(iconWidth, iconWidth); + QPixmapCache::insert(fullIconId, icon); + } + painter->drawPixmap(x, 2, iconWidth, iconWidth, icon); x += iconWidth + 4; } -- cgit v1.3.1