Taskwarrior.qml: workaround handling of files in qml.
This commit is contained in:
parent
325d4638cc
commit
ab969a10c8
2 changed files with 11 additions and 6 deletions
|
@ -15,7 +15,11 @@ Item {
|
||||||
property ListModel model : ListModel { id: jsonModel }
|
property ListModel model : ListModel { id: jsonModel }
|
||||||
property alias count: jsonModel.count
|
property alias count: jsonModel.count
|
||||||
|
|
||||||
onSourceChanged: {
|
onSourceChanged: fetchJSONModel()
|
||||||
|
onJsonChanged: updateJSONModel()
|
||||||
|
onQueryChanged: updateJSONModel()
|
||||||
|
|
||||||
|
function fetchJSONModel() {
|
||||||
var xhr = new XMLHttpRequest;
|
var xhr = new XMLHttpRequest;
|
||||||
xhr.open("GET", source);
|
xhr.open("GET", source);
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
|
@ -25,9 +29,6 @@ Item {
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
onJsonChanged: updateJSONModel()
|
|
||||||
onQueryChanged: updateJSONModel()
|
|
||||||
|
|
||||||
function updateJSONModel() {
|
function updateJSONModel() {
|
||||||
jsonModel.clear();
|
jsonModel.clear();
|
||||||
|
|
||||||
|
|
|
@ -14,16 +14,20 @@ Rectangle {
|
||||||
id: root
|
id: root
|
||||||
color: "black"
|
color: "black"
|
||||||
|
|
||||||
property string fileName: "jsondata.txt"
|
property string fileName: "/home/oan/Projects/private/QmlMirror/QmlMirror/jsondata.txt"
|
||||||
|
|
||||||
JSONListModel {
|
JSONListModel {
|
||||||
id: jsonModel
|
id: jsonModel
|
||||||
source: fileName
|
source: root.fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskWarrior {
|
TaskWarrior {
|
||||||
id: taskwarrior
|
id: taskwarrior
|
||||||
jsonFile: fileName
|
jsonFile: fileName
|
||||||
|
|
||||||
|
onJsonFileChanged: {
|
||||||
|
jsonModel.fetchJSONModel()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue