itat_challenge/src/model/CompetitorWithResults.h
2024-08-16 15:48:53 +02:00

51 lines
1.3 KiB
C++

#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)
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);
QString getMark() { return this->mark; }
QString getMedalType() { return this->medalType; }
static bool compare(CompetitorWithResults lComp, CompetitorWithResults rComp);
private:
QString mark;
QString medalType;
};
#endif //ITAT_CHALLANGE_OLYMPICS_COMPETITORWITHRESULTS_H