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