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 15:59:22 +0200
commit66d5d8685f7dcd45b2e9581315c101e69646cd6f (patch)
tree09376bc9c548ab086118f888653222860098000f /src/model/MedalWinner.h
parentb49c066bd5ef8d543a842249881b57eb771ffc94 (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;
};