summaryrefslogtreecommitdiff
path: root/src/model/MedalWinner.h
diff options
context:
space:
mode:
authorSteru <jerrydream111@gmail.com>2024-08-15 19:21:02 +0200
committerSteru <jerrydream111@gmail.com>2024-08-16 23:50:34 +0200
commit70d5f014e50b9255dcb5c36122a109cc049c8936 (patch)
treef14ab291bec1a27457166ab1c4e0e70920b2ffa9 /src/model/MedalWinner.h
parent173ce00cf29822294137d3ebacc5b33ad01a3d25 (diff)
Added Q Object macros.
Diffstat (limited to 'src/model/MedalWinner.h')
-rw-r--r--src/model/MedalWinner.h30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/model/MedalWinner.h b/src/model/MedalWinner.h
index e771185..99ca1a3 100644
--- a/src/model/MedalWinner.h
+++ b/src/model/MedalWinner.h
@@ -7,27 +7,43 @@
#include <QJsonObject>
#include <stdexcept>
+#include <QAbstractListModel>
+
class MedalWinner : public Competitor {
+ Q_OBJECT
+
+ Q_PROPERTY(int gold READ gold)
+ Q_PROPERTY(int silver READ silver)
+ Q_PROPERTY(int bronze READ bronze)
public:
+ MedalWinner() : Competitor() {
+ this->gold = 0;
+ this->silver = 0;
+ this->bronze = 0;
+ }
+
MedalWinner(const MedalWinner &medalWinner) : Competitor(medalWinner) {
- this->wonMedals = {
- {QString("ME_GOLD"), medalWinner.wonMedals.value("ME_GOLD")},
- {QString("ME_SILVER"), medalWinner.wonMedals.value("ME_SILVER")},
- {QString("ME_BRONZE"), medalWinner.wonMedals.value("ME_BRONZE")}
- };
+ this->gold = medalWinner.gold;
+ this->silver = medalWinner.silver;
+ this->bronze = medalWinner.bronze;
}
MedalWinner(const QJsonObject &competitor) : Competitor(competitor) {
- if (competitor.contains("medals")) throw invalid_argument("Competitor has no medals.");
+ if (!competitor.contains("medals")) throw invalid_argument("Competitor has no medals.");
QJsonObject medals = competitor["medals"].toObject();
setMedals(medals);
}
bool setMedals(const QJsonObject &medals);
+ int getGold() { return gold; }
+ int getSilver() { return silver; }
+ int getBronze() { return bronze; }
+
+ static bool compare(MedalWinner lComp, MedalWinner rComp);
private:
- QMap<QString, QString> wonMedals;
+ int gold, silver, bronze;
};