aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/ModModel.cpp
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-12-16 19:03:52 -0300
committerflow <flowlnlnln@gmail.com>2023-01-13 16:23:06 -0300
commit433a802c6ed3070b1b2f4435937a456eb4192f78 (patch)
treeba939d277a46b0cc0cac8ad62dd9c0442eaf7c35 /launcher/ui/pages/modplatform/ModModel.cpp
parent6a1807995390b2a2cbe074ee1f47d3791e0e3f10 (diff)
downloadPrismLauncher-433a802c6ed3070b1b2f4435937a456eb4192f78.tar.gz
PrismLauncher-433a802c6ed3070b1b2f4435937a456eb4192f78.tar.bz2
PrismLauncher-433a802c6ed3070b1b2f4435937a456eb4192f78.zip
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>
Diffstat (limited to 'launcher/ui/pages/modplatform/ModModel.cpp')
-rw-r--r--launcher/ui/pages/modplatform/ModModel.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp
index 31aae746..59399c59 100644
--- a/launcher/ui/pages/modplatform/ModModel.cpp
+++ b/launcher/ui/pages/modplatform/ModModel.cpp
@@ -7,19 +7,19 @@
#include <QMessageBox>
-namespace ModPlatform {
+namespace ResourceDownload {
-ListModel::ListModel(ModPage* parent, ResourceAPI* api) : ResourceModel(parent, api) {}
+ModModel::ModModel(ModPage* parent, ResourceAPI* api) : ResourceModel(parent, api) {}
/******** Make data requests ********/
-ResourceAPI::SearchArgs ListModel::createSearchArguments()
+ResourceAPI::SearchArgs ModModel::createSearchArguments()
{
auto profile = static_cast<MinecraftInstance&>(m_associated_page->m_base_instance).getPackProfile();
return { ModPlatform::ResourceType::MOD, m_next_search_offset, m_search_term,
getSorts()[currentSort], profile->getModLoaders(), getMineVersions() };
}
-ResourceAPI::SearchCallbacks ListModel::createSearchCallbacks()
+ResourceAPI::SearchCallbacks ModModel::createSearchCallbacks()
{
return { [this](auto& doc) {
if (!s_running_models.constFind(this).value())
@@ -28,14 +28,14 @@ ResourceAPI::SearchCallbacks ListModel::createSearchCallbacks()
} };
}
-ResourceAPI::VersionSearchArgs ListModel::createVersionsArguments(QModelIndex& entry)
+ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& entry)
{
auto const& pack = m_packs[entry.row()];
auto profile = static_cast<MinecraftInstance&>(m_associated_page->m_base_instance).getPackProfile();
return { pack.addonId.toString(), getMineVersions(), profile->getModLoaders() };
}
-ResourceAPI::VersionSearchCallbacks ListModel::createVersionsCallbacks(QModelIndex& entry)
+ResourceAPI::VersionSearchCallbacks ModModel::createVersionsCallbacks(QModelIndex& entry)
{
auto const& pack = m_packs[entry.row()];
@@ -46,12 +46,12 @@ ResourceAPI::VersionSearchCallbacks ListModel::createVersionsCallbacks(QModelInd
} };
}
-ResourceAPI::ProjectInfoArgs ListModel::createInfoArguments(QModelIndex& entry)
+ResourceAPI::ProjectInfoArgs ModModel::createInfoArguments(QModelIndex& entry)
{
auto& pack = m_packs[entry.row()];
return { pack };
}
-ResourceAPI::ProjectInfoCallbacks ListModel::createInfoCallbacks(QModelIndex& entry)
+ResourceAPI::ProjectInfoCallbacks ModModel::createInfoCallbacks(QModelIndex& entry)
{
return { [this, entry](auto& doc, auto& pack) {
if (!s_running_models.constFind(this).value())
@@ -60,7 +60,7 @@ ResourceAPI::ProjectInfoCallbacks ListModel::createInfoCallbacks(QModelIndex& en
} };
}
-void ListModel::searchWithTerm(const QString& term, const int sort, const bool filter_changed)
+void ModModel::searchWithTerm(const QString& term, const int sort, const bool filter_changed)
{
if (m_search_term == term && m_search_term.isNull() == term.isNull() && currentSort == sort && !filter_changed) {
return;
@@ -74,7 +74,7 @@ void ListModel::searchWithTerm(const QString& term, const int sort, const bool f
/******** Request callbacks ********/
-void ListModel::searchRequestFinished(QJsonDocument& doc)
+void ModModel::searchRequestFinished(QJsonDocument& doc)
{
QList<ModPlatform::IndexedPack> newList;
auto packs = documentToArray(doc);
@@ -108,7 +108,7 @@ void ListModel::searchRequestFinished(QJsonDocument& doc)
endInsertRows();
}
-void ListModel::infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index)
+void ModModel::infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index)
{
qDebug() << "Loading mod info";
@@ -133,7 +133,7 @@ void ListModel::infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack
m_associated_page->updateUi();
}
-void ListModel::versionRequestSucceeded(QJsonDocument doc, QString addonId, const QModelIndex& index)
+void ModModel::versionRequestSucceeded(QJsonDocument doc, QString addonId, const QModelIndex& index)
{
auto current = m_associated_page->getCurrentPack();
if (addonId != current.addonId) {
@@ -159,16 +159,16 @@ void ListModel::versionRequestSucceeded(QJsonDocument doc, QString addonId, cons
m_associated_page->updateVersionList();
}
-} // namespace ModPlatform
-
/******** Helpers ********/
#define MOD_PAGE(x) static_cast<ModPage*>(x)
-auto ModPlatform::ListModel::getMineVersions() const -> std::optional<std::list<Version>>
+auto ModModel::getMineVersions() const -> std::optional<std::list<Version>>
{
auto versions = MOD_PAGE(m_associated_page)->getFilter()->versions;
if (!versions.empty())
return versions;
return {};
}
+
+} // namespace ResourceDownload