From 3d19fd72716561a0322ba0acc5c94aac9f161e9d Mon Sep 17 00:00:00 2001 From: Orangerot Date: Fri, 16 Aug 2024 15:40:37 +0200 Subject: feat(Sport): select Discipline --- src/main/main.cpp | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'src/main') diff --git a/src/main/main.cpp b/src/main/main.cpp index 9f175ac..7f4e9f7 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -30,49 +30,11 @@ int main(int argc, char *argv[]) QQmlContext *objectContext = new QQmlContext(engine.rootContext()); SportModel model; - model.request(); + model.request("ARC"); objectContext->setContextProperty("sports", &model); QQmlComponent component(&engine, "qrc:/qt/qml/itat/res/gui/application.qml"); QObject *object = component.create(objectContext); - // ... delete object and objectContext when necessary - - - // create custom temporary event loop on stack - QEventLoop eventLoop; - - // "quit()" the event-loop, when the network request "finished()" - QNetworkAccessManager mgr; - QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit())); - - QString endpoint { "https://sph-s-api.olympics.com/summer/schedules/api/ENG/schedule/discipline/ARC" }; - - // the HTTP request - QNetworkRequest req( (QUrl( endpoint )) ); - QNetworkReply *reply = mgr.get(req); - eventLoop.exec(); // blocks stack until "finished()" has been called - - if (reply->error() == QNetworkReply::NoError) { - //success - - QString strReply = (QString)reply->readAll(); - - //parse json - // qDebug() << "Response:" << strReply; - QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8()); - - QJsonObject jsonObj = jsonResponse.object(); - - qDebug() << "Competitor:" << jsonObj["units"][0]["competitors"][0]["name"].toString(); - - delete reply; - } - else { - //failure - qDebug() << "Failure" <errorString(); - delete reply; - } - return app.exec(); } -- cgit v1.2.3