summaryrefslogtreecommitdiff
path: root/src/model/MedalWinner.h
diff options
context:
space:
mode:
authorSteru <jerrydream111@gmail.com>2024-08-15 23:27:54 +0200
committerSteru <jerrydream111@gmail.com>2024-08-16 23:53:31 +0200
commitb869b8983656b12f9dee59439acfb6b3db647b72 (patch)
tree9bbb90ed4bfd6c9937beb3f5871ce2a6fbaa7059 /src/model/MedalWinner.h
parent4f12d941f949bb8b8c1d043ac34772c5c80f1b89 (diff)
Made Competitor a QObject and tidied up some code.
Diffstat (limited to 'src/model/MedalWinner.h')
-rw-r--r--src/model/MedalWinner.h32
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;
};