blob: 1f679d829abf3d0dbc127abb2850e3065eb126fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
import QtQuick 2.0
Item {
id: root
property int whichCount: 0
property bool success: false
SequentialAnimation {
id: anim
PauseAnimation { duration: 525 } // delay mode is 500 msec.
ScriptAction { script: loadcomponent(0) }
PauseAnimation { duration: 525 } // delay mode is 500 msec.
ScriptAction { script: loadcomponent(1) }
PauseAnimation { duration: 525 } // delay mode is 500 msec.
ScriptAction { script: if (whichCount == 2) root.success = true; else console.log("failed to load testlist"); }
}
Component.onCompleted: {
updateList();
anim.start();
}
function updateList() {
var xhr = new XMLHttpRequest();
xhr.open("GET","http://127.0.0.1:14445/testlist"); // list of components
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
var components = xhr.responseText.split('\n');
var i;
for (i=0; i<components.length; i++) {
if (components[i].split(";").length == 2) {
componentlist.append({"Name" : components[i].split(";")[0], "url" : components[i].split(";")[1]})
}
}
}
}
xhr.send()
}
function loadcomponent(which) {
if (componentlist.count > which) {
loader.source = componentlist.get(which).url;
whichCount += 1;
}
}
Loader {
id: loader
signal finished
anchors.fill: parent
onStatusChanged: {
if (status == Loader.Error) { finished(); next(); }
}
}
ListModel { id: componentlist }
}
|