0.9beta
[feedingit] / src / qml / Articles.qml
1 import Qt 4.7
2
3 Item {
4     //anchors.fill: parent;
5     width: parent.width;
6     property string feedid : ""
7     property alias count: articles.count
8     property alias url: articles.source
9     x: parent.width; height: parent.height;
10     anchors.top: parent.top; anchors.bottom: parent.bottom
11
12     function getArticleid(index) {
13         return articles.get(index).articleid
14     }
15
16     function reload() {
17         articles.reload()
18     }
19
20     ListView {
21         id: articleList; model: articles; delegate: articleDelegate; z: 6
22         width: parent.width; height: parent.height; /*x: 0;*/
23         cacheBuffer: 100;
24         flickDeceleration: 1500
25     }
26
27     XmlListModel {
28         id: articles
29
30         source: feedid == "" ? "" : "http://localhost:8000/articles/" + feedid + "?onlyUnread=" + hideReadArticles
31         query: "/xml/article"
32
33         XmlRole { name: "title"; query: "title/string()" }
34         XmlRole { name: "articleid"; query: "articleid/string()"; isKey: true }
35         XmlRole { name: "path"; query: "path/string()" }
36         XmlRole { name: "unread"; query: "unread/string()"; isKey: true}
37     }
38
39     Component {
40         id: articleDelegate
41
42         Item {
43             id: wrapper; width: wrapper.ListView.view.width; height: 86
44             Item {
45                 id: moveMe
46                 Rectangle { id: backRect; color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
47                 Text {
48                     anchors.fill: backRect
49                     anchors.margins: 5
50                     verticalAlignment: Text.AlignVCenter; text: title; color: (unread=="True") ? "white" : "#7b97fd";
51                     width: wrapper.width; wrapMode: Text.WordWrap; font.bold: false;
52                 }
53 //                Rectangle {
54 //                    x: 3; y: 4; width: 77; height: 77; color: "#ff0000"; smooth: true
55
56 //                }
57
58 //                Column {
59 //                    x: 3;
60
61 //                    width: wrapper.width - 3; y: 5; spacing: 2
62 //                    height: parent.height;
63 //                    Text { Rectangle {anchors.fill: parent; color: "white"; opacity: 0.5;}
64 //                         verticalAlignment: Text.AlignVCenter; text: title; color: (unread=="True") ? "white" : "#7b97fd"; width: parent.width; wrapMode: Text.WordWrap; font.bold: false; /*elide: Text.ElideRight;*/ /*style: Text.Raised;*/ styleColor: "black"; }
65 //                    //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
66 //                }
67             }
68             MouseArea { anchors.fill: wrapper; onClicked: { container.articleClicked(articleid, index) } }
69         }
70
71     }
72
73 }