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