summaryrefslogtreecommitdiff
path: root/src/model/CompetitorWithResults.cpp
diff options
context:
space:
mode:
authorSteru <jerrydream111@gmail.com>2024-08-16 15:39:05 +0200
committerOrangerot <purple@orangerot.dev>2024-08-26 11:19:38 +0200
commitd40fcd9017ccb441c1859606c6c2583c13ac5866 (patch)
tree206ec6ebcc48d009176407ea5438eed8dbad6511 /src/model/CompetitorWithResults.cpp
parentb6c86f02ff7ecb74cc96af61d8216b232bcecb3e (diff)
Fixed constructors.
Diffstat (limited to 'src/model/CompetitorWithResults.cpp')
-rw-r--r--src/model/CompetitorWithResults.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/model/CompetitorWithResults.cpp b/src/model/CompetitorWithResults.cpp
index 9dbd615..70d9473 100644
--- a/src/model/CompetitorWithResults.cpp
+++ b/src/model/CompetitorWithResults.cpp
@@ -10,7 +10,7 @@
bool CompetitorWithResults::setResults(const QJsonObject &results) {
if (!results.contains("m_mark")
|| !results.contains("m_medalType")) {
- throw invalid_argument("Results object of competitor is incomplete.");
+ return false;
}
this->m_mark = results["m_mark"].toString();
@@ -44,3 +44,18 @@ bool CompetitorWithResults::compare(CompetitorWithResults lComp, CompetitorWithR
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);
+}