From 1ac3f4d8e8ee7461f047d34e196df40499e89557 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 6 Jan 2021 19:43:21 +0100 Subject: Display children contents in collapsed separator. --- src/icondelegate.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/icondelegate.cpp') diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp index 901b5731..813395a2 100644 --- a/src/icondelegate.cpp +++ b/src/icondelegate.cpp @@ -27,9 +27,16 @@ along with Mod Organizer. If not, see . using namespace MOBase; -IconDelegate::IconDelegate(QObject* parent) - : QStyledItemDelegate(parent) +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; + } + }); + } } void IconDelegate::paintIcons( -- cgit v1.3.1 From 5fb590efe3f101d2a9d284232b6aa4b54a9d5de4 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Fri, 8 Jan 2021 20:13:24 +0100 Subject: Fix vertical alignment of icons. --- src/icondelegate.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/icondelegate.cpp') diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp index 813395a2..7205ba62 100644 --- a/src/icondelegate.cpp +++ b/src/icondelegate.cpp @@ -49,6 +49,8 @@ void IconDelegate::paintIcons( int iconWidth = icons.size() > 0 ? ((option.rect.width() / icons.size()) - 4) : 16; iconWidth = std::min(16, iconWidth); + const int margin = (option.rect.height() - iconWidth) / 2; + painter->translate(option.rect.topLeft()); for (const QString &iconId : icons) { if (iconId.isEmpty()) { @@ -64,7 +66,7 @@ void IconDelegate::paintIcons( } QPixmapCache::insert(fullIconId, icon); } - painter->drawPixmap(x, 2, iconWidth, iconWidth, icon); + painter->drawPixmap(x, margin, iconWidth, iconWidth, icon); x += iconWidth + 4; } @@ -79,6 +81,7 @@ void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, else { QStyledItemDelegate::paint(painter, option, index); } + paintIcons(painter, option, index, getIcons(index)); } -- cgit v1.3.1