aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/flame
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-12-20 12:15:17 -0300
committerflow <flowlnlnln@gmail.com>2023-01-13 16:23:07 -0300
commit36571c5e2237c98e194cff326480ebe3e661c586 (patch)
tree7a7bb0f1df380ded2ed6be227f61ef01e86c6e77 /launcher/ui/pages/modplatform/flame
parentc8eca4fb8508a22b9d4819d57627dd684f8d98c5 (diff)
downloadPrismLauncher-36571c5e2237c98e194cff326480ebe3e661c586.tar.gz
PrismLauncher-36571c5e2237c98e194cff326480ebe3e661c586.tar.bz2
PrismLauncher-36571c5e2237c98e194cff326480ebe3e661c586.zip
refactor(RD): clear up sorting methods
This refactors the sorting methods to join every bit of it into a single list, easing maintanance. It also removes the weird index contraint on the list of methods by adding an index field to the DS that holds the method. Lastly, it puts the available methods on their respective API, so other resources on the same API can re-use them later on. Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/ui/pages/modplatform/flame')
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp3
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourceModels.h4
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp8
3 files changed, 1 insertions, 14 deletions
diff --git a/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp b/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp
index d0f109de..a1cd1f26 100644
--- a/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameResourceModels.cpp
@@ -7,9 +7,6 @@
namespace ResourceDownload {
-// NOLINTNEXTLINE(modernize-avoid-c-arrays)
-const char* FlameModModel::sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" };
-
FlameModModel::FlameModModel(BaseInstance const& base) : ModModel(base, new FlameAPI) {}
void FlameModModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj)
diff --git a/launcher/ui/pages/modplatform/flame/FlameResourceModels.h b/launcher/ui/pages/modplatform/flame/FlameResourceModels.h
index 7b253dce..47fbbe1a 100644
--- a/launcher/ui/pages/modplatform/flame/FlameResourceModels.h
+++ b/launcher/ui/pages/modplatform/flame/FlameResourceModels.h
@@ -21,10 +21,6 @@ class FlameModModel : public ModModel {
void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) override;
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override;
-
- // NOLINTNEXTLINE(modernize-avoid-c-arrays)
- static const char* sorts[6];
- inline auto getSorts() const -> const char** override { return sorts; };
};
} // namespace ResourceDownload
diff --git a/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp b/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
index 67737a76..e34be7fd 100644
--- a/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
@@ -48,13 +48,7 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
m_model = new FlameModModel(instance);
m_ui->packView->setModel(m_model);
- // index is used to set the sorting with the flame api
- m_ui->sortByBox->addItem(tr("Sort by Featured"));
- m_ui->sortByBox->addItem(tr("Sort by Popularity"));
- m_ui->sortByBox->addItem(tr("Sort by Last Updated"));
- m_ui->sortByBox->addItem(tr("Sort by Name"));
- m_ui->sortByBox->addItem(tr("Sort by Author"));
- m_ui->sortByBox->addItem(tr("Sort by Downloads"));
+ addSortings();
// sometimes Qt just ignores virtual slots and doesn't work as intended it seems,
// so it's best not to connect them in the parent's contructor...