diff options
author | Steru <jerrydream111@gmail.com> | 2024-08-15 23:27:54 +0200 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2024-08-26 11:19:38 +0200 |
commit | b6c86f02ff7ecb74cc96af61d8216b232bcecb3e (patch) | |
tree | 26def991cecebcaf8704a5194ae84d4bfe137951 /src/model/MedalWinner.h | |
parent | db2d0c21c48698d336ac6e60c42cc2533648b51d (diff) |
Made Competitor a QObject and tidied up some code.
Diffstat (limited to 'src/model/MedalWinner.h')
-rw-r--r-- | src/model/MedalWinner.h | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/model/MedalWinner.h b/src/model/MedalWinner.h index 7f17449..45d1ee8 100644 --- a/src/model/MedalWinner.h +++ b/src/model/MedalWinner.h @@ -9,25 +9,17 @@ #include <QAbstractListModel> class MedalWinner : public Competitor { - Q_OBJECT - Q_PROPERTY(int gold READ gold NOTIFY nGold) - Q_PROPERTY(int silver READ silver NOTIFY nSilver) - Q_PROPERTY(int bronze READ bronze NOTIFY nBronze) + Q_OBJECT -public: - MedalWinner() : Competitor() { - this->gold = 0; - this->silver = 0; - this->bronze = 0; - } - - MedalWinner(const MedalWinner &medalWinner) : Competitor(medalWinner) { - this->gold = medalWinner.gold; - this->silver = medalWinner.silver; - this->bronze = medalWinner.bronze; - } + Q_PROPERTY(int gold READ m_gold NOTIFY nGold) + Q_PROPERTY(int silver READ m_silver NOTIFY nSilver) + 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(); @@ -35,13 +27,13 @@ public: } bool setMedals(const QJsonObject &medals); - int getGold() { return gold; } - int getSilver() { return silver; } - int getBronze() { return bronze; } + int getGold() { return m_gold; } + int getSilver() { return m_silver; } + int getBronze() { return m_bronze; } static bool compare(MedalWinner lComp, MedalWinner rComp); private: - int gold, silver, bronze; + int m_gold, m_silver, m_bronze; }; |