From 524145405b292682c635db7412017c19ce86d1ea Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 31 Dec 2020 13:39:07 +0100 Subject: Minor refactoring. --- src/modlistview.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 7e9a0438..184a6be5 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -677,27 +677,25 @@ void ModListView::setup(OrganizerCore& core, CategoryFactory& factory, MainWindo m_sortProxy = new ModListSortProxy(core.currentProfile(), &core); setModel(m_sortProxy); - connect(m_sortProxy, &QAbstractItemModel::layoutAboutToBeChanged, - this, [this](const QList& parents, QAbstractItemModel::LayoutChangeHint hint) { + // update the proxy when changing the sort column/direction and the group + connect(m_sortProxy, &QAbstractItemModel::layoutAboutToBeChanged, [this](auto&& parents, auto&& hint) { if (hint == QAbstractItemModel::VerticalSortHint) { updateGroupByProxy(-1); } }); - sortByColumn(ModList::COL_PRIORITY, Qt::AscendingOrder); - - connect(ui.groupBy, QOverload::of(&QComboBox::currentIndexChanged), this, [&](int index) { + connect(ui.groupBy, QOverload::of(&QComboBox::currentIndexChanged), [=](int index) { updateGroupByProxy(index); onModFilterActive(m_sortProxy->isFilterActive()); - }); + }); + sortByColumn(ModList::COL_PRIORITY, Qt::AscendingOrder); connect(this, &ModListView::dragEntered, core.modList(), &ModList::onDragEnter); connect(this, &ModListView::dropEntered, m_byPriorityProxy, &ModListByPriorityProxy::onDropEnter); connect(model(), &QAbstractItemModel::layoutChanged, this, &ModListView::updateModCount); - connect(header(), &QHeaderView::sortIndicatorChanged, this, [&](int, Qt::SortOrder) { - verticalScrollBar()->repaint(); }); - connect(header(), &QHeaderView::sectionResized, this, [&](int logicalIndex, int oldSize, int newSize) { + connect(header(), &QHeaderView::sortIndicatorChanged, [=](int, Qt::SortOrder) { verticalScrollBar()->repaint(); }); + connect(header(), &QHeaderView::sectionResized, [=](int logicalIndex, int oldSize, int newSize) { m_sortProxy->setColumnVisible(logicalIndex, newSize != 0); }); GenericIconDelegate* contentDelegate = new GenericIconDelegate(this, Qt::UserRole + 3, ModList::COL_CONTENT, 150); -- cgit v1.3.1