diff --git a/JSONListModel.qml b/JSONListModel.qml index edb9de2..fd6e3e9 100644 --- a/JSONListModel.qml +++ b/JSONListModel.qml @@ -15,7 +15,11 @@ Item { property ListModel model : ListModel { id: jsonModel } property alias count: jsonModel.count - onSourceChanged: { + onSourceChanged: fetchJSONModel() + onJsonChanged: updateJSONModel() + onQueryChanged: updateJSONModel() + + function fetchJSONModel() { var xhr = new XMLHttpRequest; xhr.open("GET", source); xhr.onreadystatechange = function() { @@ -25,9 +29,6 @@ Item { xhr.send(); } - onJsonChanged: updateJSONModel() - onQueryChanged: updateJSONModel() - function updateJSONModel() { jsonModel.clear(); diff --git a/TaskWarrior.qml b/TaskWarrior.qml index d48aac6..49c2aeb 100644 --- a/TaskWarrior.qml +++ b/TaskWarrior.qml @@ -14,16 +14,20 @@ Rectangle { id: root color: "black" - property string fileName: "jsondata.txt" + property string fileName: "/home/oan/Projects/private/QmlMirror/QmlMirror/jsondata.txt" JSONListModel { id: jsonModel - source: fileName + source: root.fileName } TaskWarrior { id: taskwarrior jsonFile: fileName + + onJsonFileChanged: { + jsonModel.fetchJSONModel() + } } Timer {