summaryrefslogtreecommitdiffstats
path: root/examples/declarative/xmldata/daringfireball.qml
blob: b14dfbfd004494efbbba8581969649804c985e6f (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
Rect {
    color: "white"
    width: 600
    height: 600
    resources: [
        XmlListModel {
            id: feedModel
            source: "http://daringfireball.net/index.xml"
            query: "doc($src)/feed/entry"
            namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
            Role {
                name: "title"
                query: "title/string()"
            }
            Role {
                name: "tagline"
                query: "author/name/string()"
            }
            Role {
                name: "content"
                query: "content/string()"
            }
        },
        Component {
            id: feedDelegate
            Item {
                height: contents.height + 20
                Text {
                    x: 10
                    id: TitleText
                    text: title
                    font.bold: true
                }
                Text {
                    text: 'by ' + tagline
                    anchors.left: TitleText.right
                    anchors.leftMargin: 10
                    font.italic: true
                }
                Text {
                    x: 10
                    text: content
                    anchors.top: TitleText.bottom
                    width: 580
                    wrap: true
                    onLinkActivated: { print('link clicked: ' + link) }
                }
            }
        }
    ]
    ListView {
        id: list
        anchors.fill: parent
        clip: true
        model: feedModel
        delegate: feedDelegate
    }
}