From 4fd45b937c0577a0c5c1699726e8132b97be8f5d Mon Sep 17 00:00:00 2001 From: Silarn Date: Mon, 23 Dec 2019 15:58:21 -0600 Subject: WIP: Initial changes to fetch nexus categories --- src/categories.h | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'src/categories.h') diff --git a/src/categories.h b/src/categories.h index b938bd19..232288a7 100644 --- a/src/categories.h +++ b/src/categories.h @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . *to look up categories, optimized to where the request comes from. Therefore be very *careful which of the two you have available **/ -class CategoryFactory -{ +class CategoryFactory : QObject { + Q_OBJECT; friend class CategoriesDialog; @@ -53,19 +53,14 @@ public: }; public: - struct Category - { - Category(int sortValue, int id, const QString& name, - const std::vector& nexusIDs, int parentID) - : m_SortValue(sortValue), m_ID(id), m_Name(name), m_HasChildren(false), - m_NexusIDs(nexusIDs), m_ParentID(parentID) - {} + struct Category { + Category(int sortValue, int id, const QString& name, int parentID) + : m_SortValue(sortValue), m_ID(id), m_Name(name), m_HasChildren(false), m_ParentID(parentID) {} int m_SortValue; int m_ID; int m_ParentID; bool m_HasChildren; QString m_Name; - std::vector m_NexusIDs; friend bool operator<(const Category& LHS, const Category& RHS) { @@ -73,6 +68,13 @@ public: } }; + struct NexusCategory { + NexusCategory(const QString &name, const int nexusID) + : m_Name(name), m_ID(nexusID) {} + QString m_Name; + int m_ID; + }; + public: /** * @brief reset the list of categories @@ -89,7 +91,7 @@ public: **/ void saveCategories(); - int addCategory(const QString& name, const std::vector& nexusIDs, int parentID); + int addCategory(const QString& name, const std::vector& nexusCats, int parentID); /** * @brief retrieve the number of available categories @@ -183,20 +185,33 @@ public: * * @return the reference to the singleton **/ - static CategoryFactory& instance(); + static CategoryFactory* instance(); /** * @return path to the file that contains the categories list */ static QString categoriesFilePath(); + /** + * @return path to the file that contains the nexus category mappings + */ + static QString nexusMappingFilePath(); + +public slots: + + void mapNexusCategories(QString, QVariant, QVariant data); + +signals: + + void requestNexusCategories(); + private: CategoryFactory(); void loadDefaultCategories(); - void addCategory(int id, const QString& name, const std::vector& nexusID, - int parentID); + void addCategory(int id, const QString& name, const std::vector& nexusCats, int parentID); + void addCategory(int id, const QString& name, int parentID); void setParents(); @@ -207,7 +222,7 @@ private: std::vector m_Categories; std::map m_IDMap; - std::map m_NexusMap; + std::map m_NexusMap; private: // called by isDescendantOf() -- cgit v1.3.1