summaryrefslogtreecommitdiff
path: root/src/icondelegate.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2022-05-17 11:47:01 +0200
committerMikaël Capelle <capelle.mikael@gmail.com>2023-07-09 17:20:40 +0200
commitd13f6bb870cdda71257f665367be8ef9fca86255 (patch)
tree52e214718478f1e52856572f5aa1a2ac58537f9f /src/icondelegate.cpp
parent86bb01ba9eac879d3685c439ac9da0028bc4bc80 (diff)
Apply clang-format.
Diffstat (limited to 'src/icondelegate.cpp')
-rw-r--r--src/icondelegate.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp
index 23235814..bec7d995 100644
--- a/src/icondelegate.cpp
+++ b/src/icondelegate.cpp
@@ -18,41 +18,42 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "icondelegate.h"
-#include <log.h>
+#include <QDebug>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
-#include <QDebug>
#include <QPixmapCache>
+#include <log.h>
using namespace MOBase;
-IconDelegate::IconDelegate(QTreeView* view, int column, int compactSize) :
- QStyledItemDelegate(view), m_column(column), m_compactSize(compactSize), m_compact(false)
+IconDelegate::IconDelegate(QTreeView* view, int column, int compactSize)
+ : QStyledItemDelegate(view), m_column(column), m_compactSize(compactSize),
+ m_compact(false)
{
if (view) {
- connect(view->header(), &QHeaderView::sectionResized, [=](int column, int, int size) {
- if (column == m_column) {
- m_compact = size < m_compactSize;
- }
- });
+ connect(view->header(), &QHeaderView::sectionResized,
+ [=](int column, int, int size) {
+ if (column == m_column) {
+ m_compact = size < m_compactSize;
+ }
+ });
}
}
-void IconDelegate::paintIcons(
- QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index, const QList<QString>& icons)
+void IconDelegate::paintIcons(QPainter* painter, const QStyleOptionViewItem& option,
+ const QModelIndex& index, const QList<QString>& icons)
{
int x = 4;
painter->save();
int iconWidth = icons.size() > 0 ? ((option.rect.width() / icons.size()) - 4) : 16;
- iconWidth = std::min(16, iconWidth);
+ iconWidth = std::min(16, iconWidth);
const int margin = (option.rect.height() - iconWidth) / 2;
painter->translate(option.rect.topLeft());
- for (const QString &iconId : icons) {
+ for (const QString& iconId : icons) {
if (iconId.isEmpty()) {
x += iconWidth + 4;
continue;
@@ -73,15 +74,14 @@ void IconDelegate::paintIcons(
painter->restore();
}
-void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+void IconDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
+ const QModelIndex& index) const
{
if (auto* w = qobject_cast<QAbstractItemView*>(parent())) {
w->itemDelegate()->paint(painter, option, index);
- }
- else {
+ } else {
QStyledItemDelegate::paint(painter, option, index);
}
paintIcons(painter, option, index, getIcons(index));
}
-