#pragma once #include #include #include #include #include #include #include #include #include "EventInfo.h" using namespace std; class SportModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(QString discipline READ discipline WRITE setDiscipline NOTIFY disciplineChanged); public: enum Role { EventName = Qt::UserRole + 1, Competitors }; explicit SportModel(QObject *parent = nullptr); void setDiscipline(QJsonObject discipline) { this->o_discipline = QJsonObject(discipline); } virtual int rowCount(const QModelIndex &parent) const override; virtual QVariant data(const QModelIndex &index, int role) const override; virtual QHash roleNames() const override; set getCategories(); map> getMedalsOfCompetitors(); // filter to change the current competitor list void lastName(QList &competitors); void filterByName(QList &competitors, QString name); void filterByCountry(QList &competitors, QString nocShort); // sort functions to change the order of the current competitor list // void sortByName(QList &competitors); // void sortByCountry(QList &competitors); // void sortByResult(QList &competitors); // void sortByMedals(QList &competitors); void reverseOrder(QList &competitors); // statistic function void addRelativeToFirst(QList &competitors); QString discipline() const; void setDiscipline(const QString &discipline); public slots: void request(QString discipline); void parseData(); signals: void disciplineChanged(); private: QList m_sportList; QString m_discipline; QNetworkAccessManager m_networkManager; QNetworkReply *m_reply = nullptr; // data from api QJsonObject o_discipline; bool validateDiscipline(); void filterCompetitors(QList &competitors, QString filter); // TODO ref instead of obj // function for statistic calculation float calcRelativeStat(QString ref, QString val); };