blob: e27b5379922e467d90659aa99ee7ea4ef879550b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#pragma once
#include <QString>
#include <QMap>
#include <QJsonObject>
#include <QObject>
#include <qqml.h>
using namespace std;
class Competitor : public QObject {
Q_OBJECT
Q_PROPERTY(int code READ code NOTIFY codeChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString noc READ noc NOTIFY nocChanged)
// results in a certain event/category
Q_PROPERTY(QString mark READ mark NOTIFY markChanged)
Q_PROPERTY(QString medalType READ medalType NOTIFY medalTypeChanged)
Q_PROPERTY(QString statistic READ statistic NOTIFY statisticChanged)
// medal amounts in the whole discipline
Q_PROPERTY(int gold READ gold NOTIFY goldChanged)
Q_PROPERTY(int silver READ silver NOTIFY silverChanged)
Q_PROPERTY(int bronze READ bronze NOTIFY bronzeChanged)
public:
explicit Competitor(QObject *parent) : QObject(parent) {}
// getter
int code() const { return this->m_code; }
QString name() const { return this->m_name; }
QString noc() const { return this->m_noc; }
QString mark() const { return this->m_mark; }
QString medalType() const { return this->m_medalType; }
QString statistic() const { return this->m_statistic; }
int gold() const { return this->m_gold; }
int silver() const { return this->m_silver; }
int bronze() const { return this->m_bronze; }
// setter
void setCode(int code) { this->m_code = code; }
void setName(QString name) { this->m_name = name; }
void setNOC(QString noc) { this->m_noc = noc; }
void setMark(QString mark) { this->m_mark = mark; }
void setMedalType(QString medalType) { this->m_medalType = medalType; }
void setStatistic(QString stat) { this->m_statistic = stat; }
void setGold(int gold) { this->m_gold = gold; }
void setSilver(int silver) { this->m_silver = silver; }
void setBronze(int bronze) { this->m_bronze = bronze; }
bool setResults(const QJsonObject &results);
bool setMedals(const map<QString, int> &medals);
bool setCompetitor(const QJsonObject &competitor);
void setCompetitor(const Competitor &competitor);
static bool compareName(Competitor lComp, Competitor rComp) {
return lComp.m_name.compare(rComp.m_name) < 0;
}
static bool compareNOC(Competitor lComp, Competitor rComp) {
return lComp.m_noc.compare(rComp.m_noc) < 0;
}
static bool compareMark(Competitor lComp, Competitor rComp);
static bool compareMedals(Competitor lComp, Competitor rComp);
signals:
void codeChanged();
void nameChanged();
void nocChanged();
void markChanged();
void medalTypeChanged();
void statisticChanged();
void goldChanged();
void silverChanged();
void bronzeChanged();
private:
int m_code;
QString m_name;
QString m_noc;
QString m_mark;
QString m_medalType;
QString m_statistic;
int m_gold;
int m_silver;
int m_bronze;
};
|