diff options
Diffstat (limited to 'launcher/ui/pages/modplatform/flame')
-rw-r--r-- | launcher/ui/pages/modplatform/flame/FlameModModel.cpp | 48 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/flame/FlameModModel.h | 34 |
2 files changed, 11 insertions, 71 deletions
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp index cff29a79..7588a714 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp @@ -1,53 +1,7 @@ #include "FlameModModel.h" -#include "FlameModPage.h" -#include "minecraft/PackProfile.h" - -#include <Json.h> namespace FlameMod { -ListModel::ListModel(FlameModPage* parent) : ModPlatform::ListModel(parent) {} - -ListModel::~ListModel() {} - - -void FlameMod::ListModel::searchRequestFinished(QJsonDocument& doc) -{ - jobPtr.reset(); - - QList<ModPlatform::IndexedPack> newList; - auto packs = doc.array(); - for(auto packRaw : packs) { - auto packObj = packRaw.toObject(); - - ModPlatform::IndexedPack pack; - try - { - FlameMod::loadIndexedPack(pack, packObj); - newList.append(pack); - } - catch(const JSONValidationError &e) - { - qWarning() << "Error while loading mod from Flame: " << e.cause(); - continue; - } - } - if(packs.size() < 25) { - searchState = Finished; - } else { - nextSearchOffset += 25; - searchState = CanPossiblyFetchMore; - } - beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1); - modpacks.append(newList); - endInsertRows(); -} - -const char* sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" }; - -const char** FlameMod::ListModel::getSorts() const -{ - return sorts; -} +const char* ListModel::sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" }; } // namespace FlameMod diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.h b/launcher/ui/pages/modplatform/flame/FlameModModel.h index 022ec32e..204834c9 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModModel.h +++ b/launcher/ui/pages/modplatform/flame/FlameModModel.h @@ -1,39 +1,25 @@ #pragma once -#include <RWStorage.h> - -#include <QIcon> -#include <QList> -#include <QMetaType> -#include <QSortFilterProxyModel> -#include <QString> -#include <QStringList> -#include <QStyledItemDelegate> -#include <QThreadPool> - -#include <net/NetJob.h> -#include <functional> - -#include "BaseInstance.h" #include "FlameModPage.h" #include "modplatform/flame/FlameModIndex.h" namespace FlameMod { -typedef std::function<void(QString)> LogoCallback; - class ListModel : public ModPlatform::ListModel { Q_OBJECT public: - ListModel(FlameModPage* parent); - virtual ~ListModel(); - - private slots: - void searchRequestFinished(QJsonDocument& doc) override; + ListModel(FlameModPage* parent) : ModPlatform::ListModel(parent) {} +; + virtual ~ListModel() = default; private: - const char** getSorts() const override; + void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) override { FlameMod::loadIndexedPack(m, obj); }; + + QJsonArray documentToArray(QJsonDocument& obj) const override { return obj.array(); }; + + static const char* sorts[6]; + const char** getSorts() const override { return sorts; }; }; -} // namespace Modrinth +} // namespace FlameMod |