summaryrefslogtreecommitdiff
path: root/src/categories.h
diff options
context:
space:
mode:
authorSilarn <jrim@rimpo.org>2019-12-23 15:58:21 -0600
committerJeremy Rimpo <jeremy.rimpo@servermonkey.com>2023-09-21 16:54:49 -0500
commit4fd45b937c0577a0c5c1699726e8132b97be8f5d (patch)
treea580bc33cab036a313c9edb6e48c888895e0d4ce /src/categories.h
parent0b6afd6a9a39c60b5420e40189bc0ac60a4766ba (diff)
WIP: Initial changes to fetch nexus categories
Diffstat (limited to 'src/categories.h')
-rw-r--r--src/categories.h45
1 files changed, 30 insertions, 15 deletions
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 <http://www.gnu.org/licenses/>.
*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<int>& 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<int> 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<int>& nexusIDs, int parentID);
+ int addCategory(const QString& name, const std::vector<NexusCategory>& 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<int>& nexusID,
- int parentID);
+ void addCategory(int id, const QString& name, const std::vector<NexusCategory>& nexusCats, int parentID);
+ void addCategory(int id, const QString& name, int parentID);
void setParents();
@@ -207,7 +222,7 @@ private:
std::vector<Category> m_Categories;
std::map<int, unsigned int> m_IDMap;
- std::map<int, unsigned int> m_NexusMap;
+ std::map<NexusCategory, unsigned int> m_NexusMap;
private:
// called by isDescendantOf()