2022-03-03 00:17:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
2022-03-07 19:22:57 +00:00
|
|
|
#include "modplatform/ModIndex.h"
|
2022-11-25 12:23:46 +00:00
|
|
|
#include "modplatform/ResourceAPI.h"
|
|
|
|
|
|
|
|
#include "ui/pages/modplatform/ResourceModel.h"
|
2022-12-18 18:41:46 +00:00
|
|
|
#include "ui/widgets/ModFilterWidget.h"
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-04-02 22:34:26 +01:00
|
|
|
class Version;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-12-16 22:03:52 +00:00
|
|
|
namespace ResourceDownload {
|
|
|
|
|
|
|
|
class ModPage;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-12-16 22:03:52 +00:00
|
|
|
class ModModel : public ResourceModel {
|
2022-03-03 00:17:10 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-12-18 18:41:46 +00:00
|
|
|
ModModel(const BaseInstance&, ResourceAPI* api);
|
2022-03-07 19:22:57 +00:00
|
|
|
|
2022-03-07 20:46:18 +00:00
|
|
|
/* Ask the API for more information */
|
2022-12-20 15:15:17 +00:00
|
|
|
void searchWithTerm(const QString& term, unsigned int sort, bool filter_changed);
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-03-07 22:29:59 +00: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 22:29:59 +00:00
|
|
|
virtual void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) = 0;
|
|
|
|
|
2022-12-18 18:41:46 +00:00
|
|
|
void setFilter(std::shared_ptr<ModFilterWidget::Filter> filter) { m_filter = filter; }
|
|
|
|
|
2022-03-07 19:22:57 +00:00
|
|
|
public slots:
|
2022-03-07 20:46:18 +00:00
|
|
|
void searchRequestFinished(QJsonDocument& doc);
|
2022-07-18 23:17:44 +01:00
|
|
|
void infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index);
|
2022-12-18 18:41:46 +00:00
|
|
|
void versionRequestSucceeded(QJsonDocument doc, ModPlatform::IndexedPack& pack, const QModelIndex& index);
|
2022-03-07 19:22:57 +00:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
public slots:
|
|
|
|
ResourceAPI::SearchArgs createSearchArguments() override;
|
|
|
|
ResourceAPI::SearchCallbacks createSearchCallbacks() override;
|
2022-03-07 19:22:57 +00:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
|
|
|
ResourceAPI::VersionSearchCallbacks createVersionsCallbacks(QModelIndex&) override;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override;
|
|
|
|
ResourceAPI::ProjectInfoCallbacks createInfoCallbacks(QModelIndex&) override;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
|
|
|
protected:
|
2022-03-08 14:12:35 +00:00
|
|
|
virtual auto documentToArray(QJsonDocument& obj) const -> QJsonArray = 0;
|
2022-03-03 02:01:23 +00:00
|
|
|
|
2022-03-03 00:17:10 +00:00
|
|
|
protected:
|
2022-12-18 18:41:46 +00:00
|
|
|
std::shared_ptr<ModFilterWidget::Filter> m_filter = nullptr;
|
2022-03-03 00:17:10 +00:00
|
|
|
};
|
2022-12-16 22:03:52 +00:00
|
|
|
|
|
|
|
} // namespace ResourceDownload
|