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/MedalWinner.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/model/MedalWinner.h') diff --git a/src/model/MedalWinner.h b/src/model/MedalWinner.h index 45d1ee8..10d08bd 100644 --- a/src/model/MedalWinner.h +++ b/src/model/MedalWinner.h @@ -4,7 +4,6 @@ #include "Competitor.h" #include #include -#include #include @@ -17,16 +16,17 @@ class MedalWinner : public Competitor { Q_PROPERTY(int bronze READ m_bronze NOTIFY nBronze) public: - MedalWinner() : Competitor(), m_gold(0), m_silver(0), m_bronze(0) {} - MedalWinner(const MedalWinner &medalWinner) : Competitor(medalWinner), - m_gold(medalWinner.m_gold), m_silver(medalWinner.m_silver), m_bronze(medalWinner.m_bronze) {} - MedalWinner(const QJsonObject &competitor) : Competitor(competitor) { - if (!competitor.contains("medals")) throw invalid_argument("Competitor has no medals."); - QJsonObject medals = competitor["medals"].toObject(); - setMedals(medals); - } + explicit MedalWinner(Competitor *parent) : Competitor(parent) {} + + bool setMedalWinner(const QJsonObject &competitor); + void setMedalWinner(const MedalWinner &competitor); bool setMedals(const QJsonObject &medals); + + void setGold(int gold) { this->m_gold = gold; } + void setSilver(int silver) { this->m_silver = silver; } + void setBronze(int bronze) { this->m_bronze = bronze; } + int getGold() { return m_gold; } int getSilver() { return m_silver; } int getBronze() { return m_bronze; } -- cgit v1.2.3