summaryrefslogtreecommitdiff
path: root/src/model/Sport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/Sport.cpp')
-rw-r--r--src/model/Sport.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/model/Sport.cpp b/src/model/Sport.cpp
index 8c4902b..a21e21d 100644
--- a/src/model/Sport.cpp
+++ b/src/model/Sport.cpp
@@ -22,7 +22,7 @@
#include <QString>
namespace {
- const QString &k_requestUrl = "https://sph-s-api.olympics.com/summer/schedules/api/ENG/schedule/discipline/ARC";
+ const QString &k_requestUrl = "https://sph-s-api.olympics.com/summer/schedules/api/ENG/schedule/discipline/";
}
SportModel::SportModel(QObject *parent) : QAbstractListModel(parent) {
@@ -58,8 +58,18 @@ QHash<int, QByteArray> SportModel::roleNames() const {
return names;
}
-void SportModel::request() {
- m_reply = m_networkManager.get(QNetworkRequest( k_requestUrl ));
+QString SportModel::discipline() const {
+ return m_discipline;
+}
+
+void SportModel::setDiscipline(const QString &discipline) {
+ m_discipline = discipline;
+}
+
+
+void SportModel::request(QString discipline) {
+ m_discipline = discipline;
+ m_reply = m_networkManager.get(QNetworkRequest( k_requestUrl + m_discipline));
qDebug() << m_reply;
connect(m_reply, &QNetworkReply::finished, this, &SportModel::parseData);
}
@@ -68,8 +78,8 @@ void SportModel::parseData() {
if (m_reply->error() == QNetworkReply::NoError) {
beginResetModel();
- // qDeleteAll(m_sportList);
- // m_sportList.clear();
+ qDeleteAll(m_sportList);
+ m_sportList.clear();