summaryrefslogtreecommitdiffstats
path: root/examples/declarative/xml/xmldata
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-05-17 03:19:13 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-05-17 03:19:13 (GMT)
commit414edec537821711e22a3bb2729e189aa501bfbb (patch)
treecaa1c3b4a3aa22c5670466a570f380bc3bd29355 /examples/declarative/xml/xmldata
parentcef452a2792cc15705f677c9b9c689496eeb500f (diff)
parent029f98ee0176b34279e7cc944cca17f027fe5a0a (diff)
downloadQt-414edec537821711e22a3bb2729e189aa501bfbb.zip
Qt-414edec537821711e22a3bb2729e189aa501bfbb.tar.gz
Qt-414edec537821711e22a3bb2729e189aa501bfbb.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'examples/declarative/xml/xmldata')
-rw-r--r--examples/declarative/xml/xmldata/daringfireball.qml47
-rw-r--r--examples/declarative/xml/xmldata/xmldata.qmlproject16
-rw-r--r--examples/declarative/xml/xmldata/yahoonews.qml83
3 files changed, 146 insertions, 0 deletions
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
+ }
+}