diff options
author | Orangerot <purple@orangerot.dev> | 2024-08-15 21:24:28 +0200 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2024-08-15 21:24:28 +0200 |
commit | c09350b7c9adf6327f0a0475c897a71dd23b6cae (patch) | |
tree | aa40a8f5c3aabc28360a0851a5f1220611d888bf /src/model/Sport.h | |
parent | f17c2a73e17bb0a2309ae2aba76761f480206656 (diff) |
feat(SportModel): request API, parse and display Model
Diffstat (limited to 'src/model/Sport.h')
-rw-r--r-- | src/model/Sport.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/model/Sport.h b/src/model/Sport.h index 147f6e8..0f183b7 100644 --- a/src/model/Sport.h +++ b/src/model/Sport.h @@ -1,8 +1,8 @@ - #ifndef ITAT_CHALLANGE_OLYMPICS_SPORT_H #define ITAT_CHALLANGE_OLYMPICS_SPORT_H - +#include <QAbstractListModel> +#include <QNetworkAccessManager> #include <set> #include <QJsonObject> @@ -11,6 +11,28 @@ using namespace std; +class SportModel : public QAbstractListModel { + Q_OBJECT + + public: + enum Role { + SportName = Qt::UserRole + 1 + }; + + explicit SportModel(QObject *parent = nullptr); + + virtual int rowCount(const QModelIndex &parent) const override; + virtual QVariant data(const QModelIndex &index, int role) const override; + virtual QHash<int, QByteArray> roleNames() const override; + public slots: + void request(); + void parseData(); + + private: + QList<QString> m_sportList; + QNetworkAccessManager m_networkManager; + QNetworkReply *m_reply = nullptr; +}; class Sport { |