Qt World Summit Conference App
import Felgo
import QtQuick
QtObject {
id: _
readonly property string fallbackScheduleUrl: Qt.resolvedUrl("../../assets/data/data.json")
property bool loading: false
Component.onCompleted: {
HttpNetworkActivityIndicator.activationDelay = 0
}
signal eventDataLoaded(var eventData)
function sendGetRequest(url, successHandler, errorHandler) {
HttpRequest
.get(url)
.set("Accept", 'application/json')
.then(function(res) {
loading = false
successHandler(JSON.parse(res.text))
})
.catch(function(err) {
loading = false
console.warn(JSON.stringify(err))
console.error("Error: Failed to load data from "+url+", error = "+err.message)
if(errorHandler !== undefined)
errorHandler()
else
dataModel.loadingFailed()
})
loading = true
}
function loadData() {
_.sendGetRequest(_.fallbackScheduleUrl , function(eventData) {
dataModel.eventData = eventData
localStorage.setValue("eventData", dataModel.eventData)
eventDataLoaded(eventData)
}, function() {
dataModel.loadingFailed()