#pragma once #include #include #include #include #include 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 &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; };