summaryrefslogtreecommitdiff
path: root/src/categories.h
diff options
context:
space:
mode:
authorSilarn <jrim@rimpo.org>2019-12-23 23:16:36 -0600
committerJeremy Rimpo <jeremy.rimpo@servermonkey.com>2023-09-21 17:03:43 -0500
commit127db7799ed4847b151a35a16cefab6c494128ef (patch)
treedd31c995fee70d2fd0367eeaa6ad916755060256 /src/categories.h
parent4fd45b937c0577a0c5c1699726e8132b97be8f5d (diff)
WIP: Category QObj refactor
Diffstat (limited to 'src/categories.h')
-rw-r--r--src/categories.h40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/categories.h b/src/categories.h
index 232288a7..e9f00726 100644
--- a/src/categories.h
+++ b/src/categories.h
@@ -31,7 +31,7 @@ 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 : QObject {
+class CategoryFactory : public QObject {
Q_OBJECT;
friend class CategoriesDialog;
@@ -53,14 +53,35 @@ public:
};
public:
+ struct NexusCategory {
+ NexusCategory(const QString& name, const int nexusID)
+ : m_Name(name), m_ID(nexusID) {}
+ QString m_Name;
+ int m_ID;
+
+ friend bool operator==(const NexusCategory& LHS, const NexusCategory& RHS) {
+ return LHS.m_ID == RHS.m_ID;
+ }
+
+ friend bool operator==(const NexusCategory& LHS, const int RHS) {
+ return LHS.m_ID == RHS;
+ }
+
+ friend bool operator<(const NexusCategory& LHS, const NexusCategory& RHS) {
+ return LHS.m_ID < RHS.m_ID;
+ }
+ };
+
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) {}
+ Category(int sortValue, int id, const QString& name, int parentID, std::vector<NexusCategory> nexusCats)
+ : m_SortValue(sortValue), m_ID(id), m_Name(name), m_HasChildren(false), m_ParentID(parentID)
+ , m_NexusCats(nexusCats) {}
int m_SortValue;
int m_ID;
int m_ParentID;
bool m_HasChildren;
QString m_Name;
+ std::vector<NexusCategory> m_NexusCats;
friend bool operator<(const Category& LHS, const Category& RHS)
{
@@ -68,13 +89,6 @@ 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
@@ -206,7 +220,7 @@ signals:
void requestNexusCategories();
private:
- CategoryFactory();
+ explicit CategoryFactory();
void loadDefaultCategories();
@@ -215,11 +229,7 @@ private:
void setParents();
- static void cleanup();
-
private:
- static CategoryFactory* s_Instance;
-
std::vector<Category> m_Categories;
std::map<int, unsigned int> m_IDMap;
std::map<NexusCategory, unsigned int> m_NexusMap;