diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-06-21 05:37:41 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-06-22 01:22:35 (GMT) |
commit | c8968fd143e079d4d2b79c88132caaffbefedd7d (patch) | |
tree | b16577cba1077738e8095c0ddb8faca20a17b1fb /examples/declarative/xml | |
parent | d9e49c4399e506c878ce5125d4edcf384b867b26 (diff) | |
download | Qt-c8968fd143e079d4d2b79c88132caaffbefedd7d.zip Qt-c8968fd143e079d4d2b79c88132caaffbefedd7d.tar.gz Qt-c8968fd143e079d4d2b79c88132caaffbefedd7d.tar.bz2 |
Clean up some examples
Diffstat (limited to 'examples/declarative/xml')
-rw-r--r-- | examples/declarative/xml/xmlhttprequest/data.xml (renamed from examples/declarative/xml/xmlhttprequest/test.xml) | 0 | ||||
-rw-r--r-- | examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml (renamed from examples/declarative/xml/xmlhttprequest/test.qml) | 67 |
2 files changed, 43 insertions, 24 deletions
diff --git a/examples/declarative/xml/xmlhttprequest/test.xml b/examples/declarative/xml/xmlhttprequest/data.xml index 8b7f1e1..8b7f1e1 100644 --- a/examples/declarative/xml/xmlhttprequest/test.xml +++ b/examples/declarative/xml/xmlhttprequest/data.xml diff --git a/examples/declarative/xml/xmlhttprequest/test.qml b/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml index e5f0875..b302729 100644 --- a/examples/declarative/xml/xmlhttprequest/test.qml +++ b/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml @@ -41,36 +41,55 @@ import Qt 4.7 Rectangle { - width: 800; height: 600 + width: 350; height: 400 - MouseArea { - anchors.fill: parent + function showRequestInfo(text) { + log.text = log.text + "\n" + text + console.log(text) + } - onClicked: { - var doc = new XMLHttpRequest(); - doc.onreadystatechange = function() { - if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - console.log("Headers -->"); - console.log(doc.getAllResponseHeaders ()); - console.log("Last modified -->"); - console.log(doc.getResponseHeader ("Last-Modified")); - } - else if (doc.readyState == XMLHttpRequest.DONE) { + Text { id: log; anchors.fill: parent; anchors.margins: 10 } - var a = doc.responseXML.documentElement; - for (var ii = 0; ii < a.childNodes.length; ++ii) { - console.log(a.childNodes[ii].nodeName); - } - console.log("Headers -->"); - console.log(doc.getAllResponseHeaders ()); - console.log("Last modified -->"); - console.log(doc.getResponseHeader ("Last-Modified")); + Rectangle { + id: button + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10 + width: buttonText.width + 10; height: buttonText.height + 10 + border.width: mouseArea.pressed ? 2 : 1 + radius : 5; smooth: true + + Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + log.text = "" + console.log("\n") + var doc = new XMLHttpRequest(); + doc.onreadystatechange = function() { + if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + + } else if (doc.readyState == XMLHttpRequest.DONE) { + var a = doc.responseXML.documentElement; + for (var ii = 0; ii < a.childNodes.length; ++ii) { + showRequestInfo(a.childNodes[ii].nodeName); + } + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + } } - } - doc.open("GET", "test.xml"); - doc.send(); + doc.open("GET", "data.xml"); + doc.send(); + } } } } + |