From 3bb189a42724ad028402ee8d4418703350ff1a2c Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Fri, 1 Jan 2021 14:32:40 +0100 Subject: Add method to retrieve the grouping mode. --- src/modlistview.cpp | 21 ++++++++++++++++++++- src/modlistview.h | 14 ++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index f6a564ac..9f94354e 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -103,7 +103,7 @@ void ModListView::setProfile(Profile* profile) bool ModListView::hasCollapsibleSeparators() const { - return m_sortProxy != nullptr && m_sortProxy->sourceModel() == m_byPriorityProxy; + return groupByMode() == GroupByMode::SEPARATOR; } int ModListView::sortColumn() const @@ -111,6 +111,25 @@ int ModListView::sortColumn() const return m_sortProxy ? m_sortProxy->sortColumn() : -1; } +ModListView::GroupByMode ModListView::groupByMode() const +{ + if (m_sortProxy == nullptr) { + return GroupByMode::NONE; + } + else if (m_sortProxy->sourceModel() == m_byPriorityProxy) { + return GroupByMode::SEPARATOR; + } + else if (m_sortProxy->sourceModel() == m_byCategoryProxy) { + return GroupByMode::CATEGORY; + } + else if (m_sortProxy->sourceModel() == m_byNexusIdProxy) { + return GroupByMode::NEXUS_ID; + } + else { + return GroupByMode::NONE; + } +} + ModListViewActions& ModListView::actions() const { return *m_actions; diff --git a/src/modlistview.h b/src/modlistview.h index dac96822..84e55e2b 100644 --- a/src/modlistview.h +++ b/src/modlistview.h @@ -36,6 +36,14 @@ public: OnViewport = DropIndicatorPosition::OnViewport }; + // indiucate the groupby mode + enum class GroupByMode { + NONE, + SEPARATOR, + CATEGORY, + NEXUS_ID + }; + public: explicit ModListView(QWidget* parent = 0); @@ -58,6 +66,10 @@ public: // int sortColumn() const; + // the current group mode + // + GroupByMode groupByMode() const; + // retrieve the actions from the view // ModListViewActions& actions() const; @@ -173,6 +185,8 @@ private: // void updateGroupByProxy(int groupIndex); + // index in the groupby combo + // enum GroupBy { NONE = 0, CATEGORY = 1, -- cgit v1.3.1