refactor: put resource downloading classes in common namespace
Puts them all inside the 'ResourceDownload' namespace, so that it's a bit clearer from the outside that those belong to the same 'module'. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
@ -1,31 +1,35 @@
|
||||
#include "FlameResourceModels.h"
|
||||
|
||||
#include "Json.h"
|
||||
|
||||
#include "modplatform/flame/FlameModIndex.h"
|
||||
|
||||
namespace FlameMod {
|
||||
namespace ResourceDownload {
|
||||
|
||||
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
|
||||
const char* ListModel::sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" };
|
||||
const char* FlameModModel::sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" };
|
||||
|
||||
void ListModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj)
|
||||
FlameModModel::FlameModModel(FlameModPage* parent) : ModModel(parent, new FlameAPI) {}
|
||||
|
||||
void FlameModModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj)
|
||||
{
|
||||
FlameMod::loadIndexedPack(m, obj);
|
||||
}
|
||||
|
||||
// We already deal with the URLs when initializing the pack, due to the API response's structure
|
||||
void ListModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj)
|
||||
void FlameModModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj)
|
||||
{
|
||||
FlameMod::loadBody(m, obj);
|
||||
}
|
||||
|
||||
void ListModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr)
|
||||
void FlameModModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr)
|
||||
{
|
||||
FlameMod::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_associated_page->m_base_instance);
|
||||
}
|
||||
|
||||
auto ListModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
|
||||
auto FlameModModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
|
||||
{
|
||||
return Json::ensureArray(obj.object(), "data");
|
||||
}
|
||||
|
||||
} // namespace FlameMod
|
||||
} // namespace ResourceDownload
|
||||
|
@ -2,14 +2,18 @@
|
||||
|
||||
#include "modplatform/flame/FlameAPI.h"
|
||||
|
||||
namespace FlameMod {
|
||||
#include "ui/pages/modplatform/ModModel.h"
|
||||
|
||||
class ListModel : public ModPlatform::ListModel {
|
||||
#include "ui/pages/modplatform/flame/FlameResourcePages.h"
|
||||
|
||||
namespace ResourceDownload {
|
||||
|
||||
class FlameModModel : public ModModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ListModel(FlameModPage* parent) : ModPlatform::ListModel(parent, new FlameAPI) {}
|
||||
~ListModel() override = default;
|
||||
FlameModModel(FlameModPage* parent);
|
||||
~FlameModModel() override = default;
|
||||
|
||||
private:
|
||||
void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) override;
|
||||
@ -23,4 +27,4 @@ class ListModel : public ModPlatform::ListModel {
|
||||
inline auto getSorts() const -> const char** override { return sorts; };
|
||||
};
|
||||
|
||||
} // namespace FlameMod
|
||||
} // namespace ResourceDownload
|
||||
|
@ -40,10 +40,12 @@
|
||||
#include "FlameResourceModels.h"
|
||||
#include "ui/dialogs/ModDownloadDialog.h"
|
||||
|
||||
namespace ResourceDownload {
|
||||
|
||||
FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
|
||||
: ModPage(dialog, instance)
|
||||
{
|
||||
m_model = new FlameMod::ListModel(this);
|
||||
m_model = new FlameModModel(this);
|
||||
m_ui->packView->setModel(m_model);
|
||||
|
||||
// index is used to set the sorting with the flame api
|
||||
@ -95,3 +97,5 @@ void FlameModPage::openUrl(const QUrl& url)
|
||||
|
||||
ModPage::openUrl(url);
|
||||
}
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
@ -42,6 +42,16 @@
|
||||
|
||||
#include "ui/pages/modplatform/ModPage.h"
|
||||
|
||||
namespace ResourceDownload {
|
||||
|
||||
namespace Flame {
|
||||
static inline QString displayName() { return "CurseForge"; }
|
||||
static inline QIcon icon() { return APPLICATION->getThemedIcon("flame"); }
|
||||
static inline QString id() { return "curseforge"; }
|
||||
static inline QString debugName() { return "Flame"; }
|
||||
static inline QString metaEntryBase() { return "FlameMods"; };
|
||||
}
|
||||
|
||||
class FlameModPage : public ModPage {
|
||||
Q_OBJECT
|
||||
|
||||
@ -54,18 +64,20 @@ class FlameModPage : public ModPage {
|
||||
FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance);
|
||||
~FlameModPage() override = default;
|
||||
|
||||
inline auto displayName() const -> QString override { return "CurseForge"; }
|
||||
inline auto icon() const -> QIcon override { return APPLICATION->getThemedIcon("flame"); }
|
||||
inline auto id() const -> QString override { return "curseforge"; }
|
||||
inline auto helpPage() const -> QString override { return "Mod-platform"; }
|
||||
[[nodiscard]] bool shouldDisplay() const override;
|
||||
|
||||
inline auto debugName() const -> QString override { return "Flame"; }
|
||||
inline auto metaEntryBase() const -> QString override { return "FlameMods"; };
|
||||
[[nodiscard]] inline auto displayName() const -> QString override { return Flame::displayName(); }
|
||||
[[nodiscard]] inline auto icon() const -> QIcon override { return Flame::icon(); }
|
||||
[[nodiscard]] inline auto id() const -> QString override { return Flame::id(); }
|
||||
[[nodiscard]] inline auto debugName() const -> QString override { return Flame::debugName(); }
|
||||
[[nodiscard]] inline auto metaEntryBase() const -> QString override { return Flame::metaEntryBase(); }
|
||||
|
||||
auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const -> bool override;
|
||||
[[nodiscard]] inline auto helpPage() const -> QString override { return "Mod-platform"; }
|
||||
|
||||
bool validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
|
||||
bool optedOut(ModPlatform::IndexedVersion& ver) const override;
|
||||
|
||||
auto shouldDisplay() const -> bool override;
|
||||
|
||||
void openUrl(const QUrl& url) override;
|
||||
};
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
Reference in New Issue
Block a user