From 68c9ae8592a51b87dc3228b8ebd13737bf2dc7f5 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Tue, 29 Dec 2020 16:06:15 +0100 Subject: Fix controls without indentation. --- src/modlistview.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index be7471aa..9192c01a 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -29,19 +29,6 @@ public: } } - QRect subElementRect(QStyle::SubElement element, const QStyleOption* option, const QWidget* widget) const override - { - QRect rect = QProxyStyle::subElementRect(element, option, widget); - switch (element) { - case SE_ItemViewItemCheckIndicator: - case SE_ItemViewItemDecoration: - case SE_ItemViewItemText: - case SE_ItemViewItemFocusRect: - rect.adjust(-20, 0, 0, 0); - break; - } - return rect; - } }; class ModListStyledItemDelegated : public QStyledItemDelegate @@ -80,6 +67,17 @@ ModListView::ModListView(QWidget* parent) setItemDelegate(new ModListStyledItemDelegated(this)); } +QRect ModListView::visualRect(const QModelIndex& index) const +{ + QRect rect = QTreeView::visualRect(index); + if (index.isValid() && !index.model()->hasChildren(index) && index.parent().isValid()) { + auto parentIndex = index.parent().data(ModList::IndexRole).toInt(); + if (ModInfo::getByIndex(parentIndex)->isSeparator()) { + rect.adjust(-indentation(), 0, 0, 0); + } + } + return rect; +} void ModListView::setModel(QAbstractItemModel* model) { -- cgit v1.3.1