diff options
author | flow <flowlnlnln@gmail.com> | 2022-08-09 01:58:22 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-08-20 10:45:01 -0300 |
commit | ec62d8e97334d3b5a30cea00858e7035468f3609 (patch) | |
tree | e87204d6c76c40191fe39d0324ff5bb6a9f787cd /launcher/minecraft/mod/tasks/LocalModParseTask.h | |
parent | 3225f514f64533394e14bf7aee4e61c19a72ed2f (diff) | |
download | PrismLauncher-ec62d8e97334d3b5a30cea00858e7035468f3609.tar.gz PrismLauncher-ec62d8e97334d3b5a30cea00858e7035468f3609.tar.bz2 PrismLauncher-ec62d8e97334d3b5a30cea00858e7035468f3609.zip |
refactor: move general code from mod model to its own model
This aims to continue decoupling other types of resources (e.g. resource
packs, shader packs, etc) from mods, so that we don't have to
continuously watch our backs for changes to one of them affecting the
others.
To do so, this creates a more general list model for resources, based on
the mods one, that allows you to extend it with functionality for other
resources.
I had to do some template and preprocessor stuff to get around the
QObject limitation of not allowing templated classes, so that's sadge :c
On the other hand, I tried cleaning up most general-purpose code in the
mod model, and added some documentation, because it looks nice :D
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/minecraft/mod/tasks/LocalModParseTask.h')
-rw-r--r-- | launcher/minecraft/mod/tasks/LocalModParseTask.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.h b/launcher/minecraft/mod/tasks/LocalModParseTask.h index ed92394c..dbecb449 100644 --- a/launcher/minecraft/mod/tasks/LocalModParseTask.h +++ b/launcher/minecraft/mod/tasks/LocalModParseTask.h @@ -2,17 +2,17 @@ #include <QDebug> #include <QObject> -#include <QRunnable> #include "minecraft/mod/Mod.h" #include "minecraft/mod/ModDetails.h" -class LocalModParseTask : public QObject, public QRunnable +#include "tasks/Task.h" + +class LocalModParseTask : public Task { Q_OBJECT public: struct Result { - QString id; std::shared_ptr<ModDetails> details; }; using ResultPtr = std::shared_ptr<Result>; @@ -20,11 +20,10 @@ public: return m_result; } - LocalModParseTask(int token, Mod::ModType type, const QFileInfo & modFile); - void run(); + LocalModParseTask(int token, ResourceType type, const QFileInfo & modFile); + void executeTask() override; -signals: - void finished(int token); + [[nodiscard]] int token() const { return m_token; } private: void processAsZip(); @@ -33,7 +32,7 @@ private: private: int m_token; - Mod::ModType m_type; + ResourceType m_type; QFileInfo m_modFile; ResultPtr m_result; }; |