summaryrefslogtreecommitdiff
path: root/src/model/CompetitorWithResults.cpp
diff options
context:
space:
mode:
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);
+}