From 6e4b1790ae4057dfafd39dadff04c8d9b5f2eaeb Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Thu, 31 Dec 2020 02:29:31 +0100 Subject: Move the separator context menu. --- src/modlistcontextmenu.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'src/modlistcontextmenu.h') diff --git a/src/modlistcontextmenu.h b/src/modlistcontextmenu.h index 05e6b601..8452bc65 100644 --- a/src/modlistcontextmenu.h +++ b/src/modlistcontextmenu.h @@ -9,6 +9,7 @@ #include "modinfo.h" +class CategoryFactory; class ModListView; class ModListViewActions; class OrganizerCore; @@ -18,7 +19,47 @@ class ModListGlobalContextMenu : public QMenu Q_OBJECT public: - ModListGlobalContextMenu(OrganizerCore& core, ModListView* modListView, QWidget* parent = nullptr); + ModListGlobalContextMenu( + OrganizerCore& core, ModListView* modListView, QWidget* parent = nullptr); + +}; + +class ModListChangeCategoryMenu : public QMenu +{ + Q_OBJECT +public: + + ModListChangeCategoryMenu( + CategoryFactory& categories, ModInfo::Ptr mod, QMenu* parent = nullptr); + + // return a list of pair from the menu + // + std::vector> categories() const; + +private: + + // populate the tree with the category, using the enabled/disabled state from the + // given mod + // + bool populate(QMenu* menu, CategoryFactory& categories, ModInfo::Ptr mod, int targetId = 0); + + // internal implementation of categories() for recursion + // + std::vector> categories(const QMenu* menu) const; +}; + +class ModListPrimaryCategoryMenu : public QMenu +{ + Q_OBJECT +public: + + ModListPrimaryCategoryMenu(CategoryFactory& categories, ModInfo::Ptr mod, QMenu* parent = nullptr); + +private: + + // populate the categories + // + void populate(const CategoryFactory& categories, ModInfo::Ptr mod); }; @@ -30,7 +71,8 @@ public: // creates a new context menu, the given index is the one for the click and should be valid // - ModListContextMenu(OrganizerCore& core, const QModelIndex& index, ModListView* modListView); + ModListContextMenu( + const QModelIndex& index, OrganizerCore& core, CategoryFactory& categories, ModListView* modListView); public: // TODO: Move this to private when all is done @@ -38,6 +80,11 @@ public: // TODO: Move this to private when all is done // QMenu* createSendToContextMenu(); + // special menu for categories + // + void addMenuAsPushButton(QMenu* menu); + + // add actions/menus to this menu for each type of mod // void addOverwriteActions(ModInfo::Ptr mod); @@ -47,6 +94,7 @@ public: // TODO: Move this to private when all is done void addRegularActions(ModInfo::Ptr mod); OrganizerCore& m_core; + CategoryFactory& m_categories; QModelIndex m_index; QModelIndexList m_selected; ModListView* m_view; -- cgit v1.3.1