blob: f57b773aca55d857ab5651edb3776e10ae26569a (
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
|
#ifndef ITAT_CHALLANGE_OLYMPICS_COMPETITORWITHRESULTS_H
#define ITAT_CHALLANGE_OLYMPICS_COMPETITORWITHRESULTS_H
#include "Competitor.h"
#include <QString>
#include <QMap>
#include <QJsonObject>
#include <QAbstractListModel>
#include <stdexcept>
class CompetitorWithResults : public Competitor {
Q_OBJECT
Q_PROPERTY(QString mark READ mark)
Q_PROPERTY(QString medalType READ medalType)
Q_PROPERTY(QString statistic READ statistic WRITE setStatistic)
public:
CompetitorWithResults() : Competitor() {
this->mark = "-";
this->medalType = "-";
}
CompetitorWithResults(const CompetitorWithResults &competitor) : Competitor(competitor) {
this->mark = competitor.mark;
this->medalType = competitor.medalType;
}
CompetitorWithResults(const QJsonObject &competitor) : Competitor(competitor) {
if (!competitor.contains("results")) throw invalid_argument("Competitor does not contain results.");
QJsonObject results = competitor["results"].toObject();
setResults(results);
}
bool setResults(const QJsonObject &results);
void setStatistic(QString stat) { this->statistic = stat; }
QString getMark() { return this->mark; }
QString getMedalType() { return this->medalType; }
QString getStatistic() { return this->statistic; }
static bool compare(CompetitorWithResults lComp, CompetitorWithResults rComp);
private:
QString mark;
QString medalType;
QString statistic;
};
#endif //ITAT_CHALLANGE_OLYMPICS_COMPETITORWITHRESULTS_H
|