2022-03-02 21:17:10 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
2022-03-07 16:22:57 -03:00
|
|
|
#include "modplatform/ModIndex.h"
|
2022-11-25 09:23:46 -03:00
|
|
|
#include "modplatform/ResourceAPI.h"
|
|
|
|
|
|
|
|
#include "ui/pages/modplatform/ResourceModel.h"
|
2022-03-02 21:17:10 -03:00
|
|
|
|
2022-04-02 18:34:26 -03:00
|
|
|
class Version;
|
2022-03-02 21:17:10 -03:00
|
|
|
|
2022-12-16 19:03:52 -03:00
|
|
|
namespace ResourceDownload {
|
|
|
|
|
|
|
|
class ModPage;
|
2022-03-02 21:17:10 -03:00
|
|
|
|
2022-12-16 19:03:52 -03:00
|
|
|
class ModModel : public ResourceModel {
|
2022-03-02 21:17:10 -03:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-12-16 19:03:52 -03:00
|
|
|
ModModel(ModPage* parent, ResourceAPI* api);
|
2022-03-07 16:22:57 -03:00
|
|
|
|
2022-03-07 17:46:18 -03:00
|
|
|
/* Ask the API for more information */
|
2022-04-14 10:27:03 -03:00
|
|
|
void searchWithTerm(const QString& term, const int sort, const bool filter_changed);
|
2022-03-02 21:17:10 -03:00
|
|
|
|
2022-03-07 19:29:59 -03:00
|
|
|
virtual void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0;
|
2022-11-13 00:52:24 +00:00
|
|
|
virtual void loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0;
|
2022-03-07 19:29:59 -03:00
|
|
|
virtual void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) = 0;
|
|
|
|
|
2022-03-07 16:22:57 -03:00
|
|
|
public slots:
|
2022-03-07 17:46:18 -03:00
|
|
|
void searchRequestFinished(QJsonDocument& doc);
|
2022-03-02 23:01:23 -03:00
|
|
|
|
2022-07-18 19:17:44 -03:00
|
|
|
void infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index);
|
2022-05-24 09:38:48 -03:00
|
|
|
|
2022-07-18 19:28:46 -03:00
|
|
|
void versionRequestSucceeded(QJsonDocument doc, QString addonId, const QModelIndex& index);
|
2022-03-07 16:22:57 -03:00
|
|
|
|
2022-11-25 09:23:46 -03:00
|
|
|
public slots:
|
|
|
|
ResourceAPI::SearchArgs createSearchArguments() override;
|
|
|
|
ResourceAPI::SearchCallbacks createSearchCallbacks() override;
|
2022-03-07 16:22:57 -03:00
|
|
|
|
2022-11-25 09:23:46 -03:00
|
|
|
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
|
|
|
ResourceAPI::VersionSearchCallbacks createVersionsCallbacks(QModelIndex&) override;
|
2022-03-02 21:17:10 -03:00
|
|
|
|
2022-11-25 09:23:46 -03:00
|
|
|
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override;
|
|
|
|
ResourceAPI::ProjectInfoCallbacks createInfoCallbacks(QModelIndex&) override;
|
2022-03-02 21:17:10 -03:00
|
|
|
|
|
|
|
protected:
|
2022-03-08 11:12:35 -03:00
|
|
|
virtual auto documentToArray(QJsonDocument& obj) const -> QJsonArray = 0;
|
|
|
|
virtual auto getSorts() const -> const char** = 0;
|
2022-03-02 23:01:23 -03:00
|
|
|
|
2022-11-25 09:23:46 -03:00
|
|
|
inline auto getMineVersions() const -> std::optional<std::list<Version>>;
|
2022-03-24 18:39:53 -03:00
|
|
|
|
2022-03-02 21:17:10 -03:00
|
|
|
protected:
|
|
|
|
int currentSort = 0;
|
|
|
|
};
|
2022-12-16 19:03:52 -03:00
|
|
|
|
|
|
|
} // namespace ResourceDownload
|