From 5e5c9c07291f6b09623d31c92b1fb61c4ede576e Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Thu, 22 Feb 2018 16:54:34 +0100 Subject: Applied clang-format on source --- src/icondelegate.cpp | 71 +++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 39 deletions(-) (limited to 'src/icondelegate.cpp') diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp index e502dc69..4125210a 100644 --- a/src/icondelegate.cpp +++ b/src/icondelegate.cpp @@ -18,50 +18,43 @@ 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); +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->drawPixmap(x, 2, iconWidth, iconWidth, icon); - x += iconWidth + 4; - } - painter->restore(); + painter->restore(); } - -- cgit v1.3.1