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>
This commit is contained in:
flow
2022-12-20 12:15:17 -03:00
parent c8eca4fb85
commit 36571c5e22
17 changed files with 93 additions and 61 deletions

View File

@ -21,7 +21,7 @@ class ModModel : public ResourceModel {
ModModel(const BaseInstance&, ResourceAPI* api);
/* Ask the API for more information */
void searchWithTerm(const QString& term, const int sort, const bool filter_changed);
void searchWithTerm(const QString& term, unsigned int sort, bool filter_changed);
virtual void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0;
virtual void loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0;
@ -46,11 +46,8 @@ class ModModel : public ResourceModel {
protected:
virtual auto documentToArray(QJsonDocument& obj) const -> QJsonArray = 0;
virtual auto getSorts() const -> const char** = 0;
protected:
int currentSort = 0;
std::shared_ptr<ModFilterWidget::Filter> m_filter = nullptr;
};