From ea6292168a6acd4c263913f0ccd7dd64daf4f5cf Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Fri, 23 Feb 2018 01:45:58 +0100 Subject: Revert "Applied clang-format on source" This reverts commit 5e5c9c07291f6b09623d31c92b1fb61c4ede576e. --- src/icondelegate.cpp | 71 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) (limited to 'src/icondelegate.cpp') diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp index 4125210a..e502dc69 100644 --- a/src/icondelegate.cpp +++ b/src/icondelegate.cpp @@ -18,43 +18,50 @@ along with Mod Organizer. If not, see . */ #include "icondelegate.h" -#include #include #include #include +#include #include -IconDelegate::IconDelegate(QObject* parent) : QStyledItemDelegate(parent) {} - -void IconDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - QStyledItemDelegate::paint(painter, option, index); - - QList icons = getIcons(index); - - int x = 4; - painter->save(); - - int iconWidth = icons.size() > 0 ? ((option.rect.width() / icons.size()) - 4) : 16; - iconWidth = std::min(16, iconWidth); - - painter->translate(option.rect.topLeft()); - for (const QString& iconId : icons) { - if (iconId.isEmpty()) { - x += iconWidth + 4; - continue; - } - QPixmap icon; - QString fullIconId = QString("%1_%2").arg(iconId).arg(iconWidth); - if (!QPixmapCache::find(fullIconId, &icon)) { - icon = QIcon(iconId).pixmap(iconWidth, iconWidth); - if (icon.isNull()) { - qWarning("failed to load icon %s", qPrintable(iconId)); - } - QPixmapCache::insert(fullIconId, icon); - } - painter->drawPixmap(x, 2, iconWidth, iconWidth, icon); - x += iconWidth + 4; + +IconDelegate::IconDelegate(QObject *parent) + : QStyledItemDelegate(parent) +{ +} + + +void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyledItemDelegate::paint(painter, option, index); + + QList icons = getIcons(index); + + int x = 4; + painter->save(); + + int iconWidth = icons.size() > 0 ? ((option.rect.width() / icons.size()) - 4) : 16; + iconWidth = std::min(16, iconWidth); + + painter->translate(option.rect.topLeft()); + for (const QString &iconId : icons) { + if (iconId.isEmpty()) { + x += iconWidth + 4; + continue; + } + QPixmap icon; + QString fullIconId = QString("%1_%2").arg(iconId).arg(iconWidth); + if (!QPixmapCache::find(fullIconId, &icon)) { + icon = QIcon(iconId).pixmap(iconWidth, iconWidth); + if (icon.isNull()) { + qWarning("failed to load icon %s", qPrintable(iconId)); + } + QPixmapCache::insert(fullIconId, icon); } + painter->drawPixmap(x, 2, iconWidth, iconWidth, icon); + x += iconWidth + 4; + } - painter->restore(); + painter->restore(); } + -- cgit v1.3.1