import QtQml.Models 2.1 ListModel { id: root readonly property var httpClient: HttpClient { id: httpClient onError: { root.error(text) root.isLoading = false } onReply: { root.populateModel(data) root.isLoading = false } } property string serviceUrl: undefined property bool isLoading: false signal error(string text) onServiceUrlChanged: reload() function reload() { root.httpClient.get(root.serviceUrl + '/static/channels.js') root.isLoading = true } function populateModel(data) { data.groups.forEach(function (group) { root.append(group) }) } }