diff options
Diffstat (limited to 'examples/declarative/xml')
-rw-r--r-- | examples/declarative/xml/xml.qmlproject | 16 | ||||
-rw-r--r-- | examples/declarative/xml/xmldata/daringfireball.qml | 47 | ||||
-rw-r--r-- | examples/declarative/xml/xmldata/xmldata.qmlproject | 16 | ||||
-rw-r--r-- | examples/declarative/xml/xmldata/yahoonews.qml | 83 | ||||
-rw-r--r-- | examples/declarative/xml/xmlhttprequest/test.qml | 36 | ||||
-rw-r--r-- | examples/declarative/xml/xmlhttprequest/test.xml | 5 | ||||
-rw-r--r-- | examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject | 16 |
7 files changed, 219 insertions, 0 deletions
diff --git a/examples/declarative/xml/xml.qmlproject b/examples/declarative/xml/xml.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xml.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xml/xmldata/daringfireball.qml b/examples/declarative/xml/xmldata/daringfireball.qml new file mode 100644 index 0000000..480b13c --- /dev/null +++ b/examples/declarative/xml/xmldata/daringfireball.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 600 + + XmlListModel { + id: feedModel + source: "http://daringfireball.net/index.xml" + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "tagline"; query: "author/name/string()" } + XmlRole { name: "content"; query: "content/string()" } + } + + Component { + id: feedDelegate + Item { + height: childrenRect.height + 20 + Text { + id: titleText + x: 10 + text: title; font.bold: true + } + Text { + anchors { left: titleText.right; leftMargin: 10 } + text: 'by ' + tagline + font.italic: true + } + Text { + x: 10 + width: 580 + anchors.top: titleText.bottom + text: content + wrapMode: Text.WordWrap + + onLinkActivated: { console.log('link clicked: ' + link) } + } + } + } + + ListView { + anchors.fill: parent + model: feedModel + delegate: feedDelegate + } +} diff --git a/examples/declarative/xml/xmldata/xmldata.qmlproject b/examples/declarative/xml/xmldata/xmldata.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xmldata/xmldata.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xml/xmldata/yahoonews.qml b/examples/declarative/xml/xmldata/yahoonews.qml new file mode 100644 index 0000000..5bab463 --- /dev/null +++ b/examples/declarative/xml/xmldata/yahoonews.qml @@ -0,0 +1,83 @@ +import Qt 4.7 + +Rectangle { + width: 600; height: 600 + + gradient: Gradient { + GradientStop { position: 0; color: "black" } + GradientStop { position: 1.0; color: "#AAAAAA" } + } + + XmlListModel { + id: feedModel + source: "http://rss.news.yahoo.com/rss/oceania" + query: "/rss/channel/item" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + Component { + id: feedDelegate + + Item { + id: delegate + height: wrapper.height + 10 + + MouseArea { + anchors.fill: wrapper + onPressed: delegate.ListView.view.currentIndex = index; + onClicked: if (wrapper.state == 'Details') wrapper.state = ''; else wrapper.state = 'Details'; + } + + Rectangle { + id: wrapper + + width: 580; y: 5; height: titleText.height + 10 + color: "#F0F0F0" + radius: 5 + + Text { + id: titleText + x: 10; y: 5 + text: '<a href=\'' + link + '\'>' + title + '</a>' + font { bold: true; family: "Helvetica"; pointSize: 14 } + + onLinkActivated: { console.log('link clicked: ' + link) } + } + + Text { + id: descriptionText + x: 10; width: 560 + anchors.top: titleText.bottom; anchors.topMargin: 5 + text: description + wrapMode: Text.WordWrap + font.family: "Helvetica" + opacity: 0 + } + + states: State { + name: "Details" + PropertyChanges { target: wrapper; height: childrenRect.height + 10 } + PropertyChanges { target: descriptionText; opacity: 1 } + } + + transitions: Transition { + from: "*"; to: "Details"; reversible: true + SequentialAnimation { + NumberAnimation { duration: 200; properties: "height"; easing.type: Easing.OutQuad } + NumberAnimation { duration: 200; properties: "opacity" } + } + } + } + } + } + + ListView { + id: list + x: 10; y: 10 + width: parent.width - 20; height: parent.height - 20 + model: feedModel + delegate: feedDelegate + } +} diff --git a/examples/declarative/xml/xmlhttprequest/test.qml b/examples/declarative/xml/xmlhttprequest/test.qml new file mode 100644 index 0000000..c7e7e6d --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/test.qml @@ -0,0 +1,36 @@ +import Qt 4.7 + +Rectangle { + width: 800; height: 600 + + MouseArea { + anchors.fill: parent + + 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) { + + 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")); + + } + } + + doc.open("GET", "test.xml"); + doc.send(); + } + } +} diff --git a/examples/declarative/xml/xmlhttprequest/test.xml b/examples/declarative/xml/xmlhttprequest/test.xml new file mode 100644 index 0000000..8b7f1e1 --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/test.xml @@ -0,0 +1,5 @@ +<data> + <element1 /> + <element2 /> +</data> + diff --git a/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject b/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xml/xmlhttprequest/xmlhttprequest.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} |