From b825a98d95dd9fa432a161d95eb6454536e01af4 Mon Sep 17 00:00:00 2001 From: Steru Date: Fri, 16 Aug 2024 15:39:05 +0200 Subject: Fixed constructors. --- src/model/CompetitorWithResults.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/model/CompetitorWithResults.cpp') 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); +} -- cgit v1.2.3