itat_challenge/src/model/CompetitorWithResults.h

51 lines
1.3 KiB
C
Raw Normal View History

2024-08-12 22:09:50 +02:00
#ifndef ITAT_CHALLANGE_OLYMPICS_COMPETITORWITHRESULTS_H
#define ITAT_CHALLANGE_OLYMPICS_COMPETITORWITHRESULTS_H
#include "Competitor.h"
#include <QString>
#include <QMap>
#include <QJsonObject>
2024-08-15 19:21:02 +02:00
#include <QAbstractListModel>
2024-08-12 22:09:50 +02:00
#include <stdexcept>
class CompetitorWithResults : public Competitor {
2024-08-15 19:21:02 +02:00
Q_OBJECT
Q_PROPERTY(QString mark READ mark)
Q_PROPERTY(QString medalType READ medalType)
2024-08-12 22:09:50 +02:00
public:
2024-08-15 19:21:02 +02:00
CompetitorWithResults() : Competitor() {
this->mark = "-";
this->medalType = "-";
}
CompetitorWithResults(const CompetitorWithResults &competitor) : Competitor(competitor) {
this->mark = competitor.mark;
this->medalType = competitor.medalType;
}
2024-08-12 22:09:50 +02:00
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);
2024-08-15 19:21:02 +02:00
QString getMark() { return this->mark; }
QString getMedalType() { return this->medalType; }
static bool compare(CompetitorWithResults lComp, CompetitorWithResults rComp);
2024-08-12 22:09:50 +02:00
private:
2024-08-15 19:21:02 +02:00
QString mark;
QString medalType;
2024-08-12 22:09:50 +02:00
};
#endif //ITAT_CHALLANGE_OLYMPICS_COMPETITORWITHRESULTS_H