blob: b35c31d5133821412fcfbe6aad4444d7d33d2562 (
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
60
61
62
63
|
import QtQuick 2.0
Item {
id: root
property int whichCount: 0
property bool success: false
SequentialAnimation {
id: anim
PauseAnimation { duration: 1000 } // 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++) {
var pair = components[i].split(";")
if (pair.length == 2) {
// Trim any unwanted whitespace
var name = pair[0].replace(/^\s+|\s+$/g, "")
var url = pair[1].replace(/^\s+|\s+$/g, "")
componentlist.append({"Name" : name, "url" : url})
}
}
}
}
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 }
}
|