summaryrefslogtreecommitdiff
path: root/src/model/CompetitorWithResults.cpp
diff options
context:
space:
mode:
authorSteru <jerrydream111@gmail.com>2024-08-16 15:39:05 +0200
committerSteru <jerrydream111@gmail.com>2024-08-16 15:59:22 +0200
commit3918de89ce74bea2f18f814edc9accad4af9d818 (patch)
treeb86013c6be31e0f2caec6e00dd9cc82cfa194ad1 /src/model/CompetitorWithResults.cpp
parent66d5d8685f7dcd45b2e9581315c101e69646cd6f (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);
+}