diff options
author | Steru <jerrydream111@gmail.com> | 2024-08-16 22:19:42 +0200 |
---|---|---|
committer | Steru <jerrydream111@gmail.com> | 2024-08-16 23:58:46 +0200 |
commit | 88b1b119dfa35f36b64d81dbe6c84f46d86455c5 (patch) | |
tree | 864ba9c747ef86d61b6aeb01e8985676f906bd3e /src/model/CompetitorWithResults.cpp | |
parent | f24b4dcbd11336dabfd146c656e2437e4393b225 (diff) |
Compacted competitors into one object, deleted API class (now in sportmodel).
Diffstat (limited to 'src/model/CompetitorWithResults.cpp')
-rw-r--r-- | src/model/CompetitorWithResults.cpp | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/model/CompetitorWithResults.cpp b/src/model/CompetitorWithResults.cpp deleted file mode 100644 index 70d9473..0000000 --- a/src/model/CompetitorWithResults.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -#include "CompetitorWithResults.h" - -/** - * Replaces/sets the results of a competitor. - * - * @param results The results of the competitor. - * @return True, if successful. - */ -bool CompetitorWithResults::setResults(const QJsonObject &results) { - if (!results.contains("m_mark") - || !results.contains("m_medalType")) { - return false; - } - - this->m_mark = results["m_mark"].toString(); - this->m_medalType = results["m_medalType"].toString(); - - return true; -} - -/** - * Static compare method, which can compare the result times or points of two CompetitorsWithResult. - * Returns true, if the left competitor (lComp) got a real lesser score than the right competitor (rComp). - * - * @param lComp First competitor to compare. - * @param rComp Second competitor to compare. - * @return True, if the second competitor got a higher score. - */ -bool CompetitorWithResults::compare(CompetitorWithResults lComp, CompetitorWithResults rComp) { - QString l = lComp.getMark(); - QString r = rComp.getMark(); - - // check if values are numerical (-> not time values) - if (!l.contains(":") || !r.contains(":")) { - return l.toFloat() < r.toFloat(); - } - - // compare time values if not numerical - QString lTime(""), rTime(""); - - for (QChar c : l) if (c.isDigit()) lTime.append(c); - for (QChar c : r) if (c.isDigit()) rTime.append(c); - - return lTime.compare(rTime) < 0; -} - -bool CompetitorWithResults::setCompetitorWithResults(const QJsonObject &competitor) { - setCompetitor(competitor); - - if (!competitor.contains("results")) return false; - QJsonObject results = competitor["results"].toObject(); - return setResults(results); -} - -void CompetitorWithResults::setCompetitorWithResults(const CompetitorWithResults &competitor) { - setCompetitor(competitor); - setMark(competitor.m_mark); - setMedalType(competitor.m_medalType); - setStatistic(competitor.m_statistic); -} |