diff options
author | Steru <jerrydream111@gmail.com> | 2024-08-03 20:19:05 +0200 |
---|---|---|
committer | Steru <jerrydream111@gmail.com> | 2024-08-03 20:19:05 +0200 |
commit | d399c562f5fad76ed8018c712a635f49715a8fed (patch) | |
tree | ae54011fe27a607d43329ee4e9be98ad3a8fe770 /src/discipline/Sport.h | |
parent | a767d83d81755710fc760a6d3dc040b4a379c16a (diff) |
Added another filter and sort functions. Also using mock data to test.
Diffstat (limited to 'src/discipline/Sport.h')
-rw-r--r-- | src/discipline/Sport.h | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/discipline/Sport.h b/src/discipline/Sport.h index 9c993fb..3b1c7f4 100644 --- a/src/discipline/Sport.h +++ b/src/discipline/Sport.h @@ -23,18 +23,46 @@ public: set<QString> getCategories(); QJsonArray getCompetitorsByCategory(QString category); - // chainable - QJsonObject filterByName(QJsonObject discipline, QString name); - QJsonObject filterByCountry(QJsonObject discipline, QString name); + // filter to change the current competitor array + void filterByName(QJsonArray& competitors, QString name); + void filterByCountry(QJsonArray& competitors, QString nocShort); + + // sort functions to change the order of the current competitor array + void sortByName(QJsonArray &competitors); + void sortByCountry(QJsonArray &competitors); + void sortByResult(QJsonArray &competitors); void setDiscipline(QJsonObject discipline) { - this->discipline = discipline; + this->discipline = QJsonObject(discipline); } private: + /* + * Analysis of provided competitor objects: + * + * Attributes: + * - code + * - noc (national olympics comittee) + * - name (sometimes the country name? mostly the competitors name) + * - order + * [- results] (only if the results are out!) + * + * + * Analysis of provided result objects: + * + * Attributes: + * - position + * - mark + * - medalType + * - irk + * [- winnerLoserTie] (only if provided in the discipline?) + */ QJsonObject discipline; + void filterCompetitors(QJsonArray& competitors, QString attribute, QString filter); + void sortCompetitors(QJsonArray &competitors, function<bool (const QJsonValue &left, const QJsonValue &right)> compare); + }; |