-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMergedXmlListModel.qml
60 lines (54 loc) · 2.17 KB
/
MergedXmlListModel.qml
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
import QtQuick 2.2
import QtQuick.XmlListModel 2.0
ListModel {
function rebuildListModel() {
for (var i = 0; i < feeds.length; i++) {
if (feeds[i].status === XmlListModel.Loading)
return
}
clear()
for (var i = 0; i < feeds.length; i++) {
for (var j = 0; j < feeds[i].count; j++) {
append(feeds[i].get(j))
}
}
console.log("Rebuild")
}
property list<XmlListModel> feeds: [
/*
XmlListModel {
source: "http://feeds.bbci.co.uk/news/business/rss.xml"
query: "/rss/channel/item"
namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
XmlRole { name: "title"; query: "title/string()" }
// Remove any links from the description
XmlRole { name: "description"; query: "fn:replace(description/string(), '\<a href=.*\/a\>', '')" }
XmlRole { name: "image"; query: "media:thumbnail/@url/string()" }
XmlRole { name: "link"; query: "link/string()" }
XmlRole { name: "pubDate"; query: "pubDate/string()" }
onStatusChanged: {
rebuildListModel()
}
},
*/
XmlListModel {
source: Qt.application.arguments[1]
query: "/rss/channel/item"
namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
XmlRole { name: "title"; query: "title/string()" }
// Remove any links from the description
XmlRole { name: "description"; query: "fn:replace(description/string(), '\<a href=.*\/a\>', '')" }
XmlRole { name: "image"; query: "media:thumbnail/@url/string()" }
XmlRole { name: "link"; query: "link/string()" }
XmlRole { name: "pubDate"; query: "pubDate/string()" }
onStatusChanged: {
rebuildListModel()
}
}
]
function reload() {
for (var i = 0; i < feeds.length; i++) {
feeds[i].reload()
}
}
}