feat: change task container in ModDownloadDialog to a QHash

Previously, we used a unique_ptr to a ModDownloadTask to keep track of
the selected mod to download when we accepted the dialog.

In order to allow multiple mods to be selected at once for download,
this has been changed to a QHash where the key is the mods name (since
it doesn't seem right to allow for multiple versions of the same mod to
be downloaded at once), and the value is a pointer to the corresponding
ModDownloadTask.
This commit is contained in:
flow
2022-02-21 21:34:06 -03:00
parent 613b351f13
commit 9c6727e27f
4 changed files with 35 additions and 10 deletions

View File

@ -29,9 +29,11 @@ public:
QString dialogTitle() override;
QList<BasePage *> getPages() override;
void setSuggestedMod(const QString & name = QString(), ModDownloadTask * task = nullptr);
void addSelectedMod(const QString & name = QString(), ModDownloadTask * task = nullptr);
void removeSelectedMod(const QString & name = QString());
bool isModSelected(const QString & name, const QString & filename) const;
ModDownloadTask * getTask();
const QList<ModDownloadTask*> getTasks();
const std::shared_ptr<ModFolderModel> &mods;
public slots:
@ -49,6 +51,6 @@ private:
ModrinthPage *modrinthPage = nullptr;
FlameModPage *flameModPage = nullptr;
std::unique_ptr<ModDownloadTask> modTask;
QHash<QString, ModDownloadTask*> modTask;
BaseInstance *m_instance;
};