diff options
| author | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2018-02-23 01:45:58 +0100 |
|---|---|---|
| committer | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2018-02-23 01:45:58 +0100 |
| commit | ea6292168a6acd4c263913f0ccd7dd64daf4f5cf (patch) | |
| tree | 312024abbd7c3c100274f3a8031d49096480b654 /src/icondelegate.cpp | |
| parent | 5e5c9c07291f6b09623d31c92b1fb61c4ede576e (diff) | |
Revert "Applied clang-format on source"
This reverts commit 5e5c9c07291f6b09623d31c92b1fb61c4ede576e.
Diffstat (limited to 'src/icondelegate.cpp')
| -rw-r--r-- | src/icondelegate.cpp | 61 |
1 files changed, 34 insertions, 27 deletions
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 <http://www.gnu.org/licenses/>. */
#include "icondelegate.h"
-#include <QDebug>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
+#include <QDebug>
#include <QPixmapCache>
-IconDelegate::IconDelegate(QObject* parent) : QStyledItemDelegate(parent) {}
-void IconDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
- QStyledItemDelegate::paint(painter, option, index);
+IconDelegate::IconDelegate(QObject *parent)
+ : QStyledItemDelegate(parent)
+{
+}
+
- QList<QString> icons = getIcons(index);
+void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ QStyledItemDelegate::paint(painter, option, index);
- int x = 4;
- painter->save();
+ QList<QString> icons = getIcons(index);
- int iconWidth = icons.size() > 0 ? ((option.rect.width() / icons.size()) - 4) : 16;
- iconWidth = std::min(16, iconWidth);
+ int x = 4;
+ painter->save();
- 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;
+ 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();
}
+
|
