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-12-19 00:11:46 +05:30
|
|
|
#include "ui/widgets/ModFilterWidget.h"
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-04-03 03:04:26 +05:30
|
|
|
class Version;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-12-17 03:33:52 +05:30
|
|
|
namespace ResourceDownload {
|
|
|
|
|
|
|
|
class ModPage;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-12-17 03:33:52 +05:30
|
|
|
class ModModel : public ResourceModel {
|
2022-03-03 05:47:10 +05:30
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-12-19 00:11:46 +05:30
|
|
|
ModModel(const BaseInstance&, 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-12-19 00:11:46 +05:30
|
|
|
void setFilter(std::shared_ptr<ModFilterWidget::Filter> filter) { m_filter = filter; }
|
|
|
|
|
2022-03-08 00:52:57 +05:30
|
|
|
public slots:
|
2022-03-08 02:16:18 +05:30
|
|
|
void searchRequestFinished(QJsonDocument& doc);
|
2022-07-19 03:47:44 +05:30
|
|
|
void infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index);
|
2022-12-19 00:11:46 +05:30
|
|
|
void versionRequestSucceeded(QJsonDocument doc, ModPlatform::IndexedPack& pack, 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-03-03 05:47:10 +05:30
|
|
|
protected:
|
|
|
|
int currentSort = 0;
|
2022-12-19 00:11:46 +05:30
|
|
|
|
|
|
|
std::shared_ptr<ModFilterWidget::Filter> m_filter = nullptr;
|
2022-03-03 05:47:10 +05:30
|
|
|
};
|
2022-12-17 03:33:52 +05:30
|
|
|
|
|
|
|
} // namespace ResourceDownload
|