Adding PageStack support in qml
[feedingit] / psa_harmattan / feedingit / qml / Feeds.qml
1 import Qt 4.7
2
3 Item {
4     //anchors.fill: parent;
5     width: parent.width;
6     property string catid : ""
7     property bool inEditMode: true
8     x: parent.width; height: parent.height;
9     anchors.top: parent.top; anchors.bottom: parent.bottom
10
11     signal feedClicked(string feedid)
12
13     function reload() {
14         feeds.xml = catid == "" ? "" : controller.getFeedsXml(catid);
15         //feeds.reload()
16     }
17
18     //Component.onCompleted: { console.log(x + " /") }
19
20     ListView {
21         id: feedList; model: feeds; delegate: feedDelegate; z: 6
22         width: parent.width; height: parent.height; /*x: 0;*/
23         cacheBuffer: 100;
24         flickDeceleration: 1500
25     }
26
27     XmlListModel {
28
29         id: feeds
30
31         //source: catid == "" ? "" : "http://localhost:8000/feeds/" + catid //+ "?onlyUnread=" + parent.hideReadArticles
32         //xml: catid == "" ? "" : controller.getFeedsXml(catid)
33         query: "/xml/feed"
34
35         XmlRole { name: "title"; query: "feedname/string()" }
36         XmlRole { name: "feedid"; query: "feedid/string()"; isKey: true }
37         XmlRole { name: "unread"; query: "unread/string()"; isKey: true }
38         XmlRole { name: "updatedDate"; query: "updatedDate/string()" }
39         XmlRole { name: "icon"; query: "icon/string()" }
40         XmlRole { name: "updating"; query: "updating/string()"; isKey: true }
41         //XmlRole { name: "url"; query: "url/string()"; }
42     }
43
44     Component {
45         id: feedDelegate
46
47         Item {
48             id: wrapper; width: wrapper.ListView.view.width;
49             visible: (unread == "0" && feedsItem.hideReadFeeds=="True") ? false : true
50             height: (visible) ? 86 : 0
51
52             Item {
53                 id: moveMe
54                 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
55                 Rectangle {
56                     x: 3; y: 4; width: 77; height: 77; color: "#000000"; smooth: true
57                     Image { width:32; height: 32; anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter;
58                         source: (updating=="True")? "common/images/loading.png" : (icon == "False") ? "common/images/feedingit.png" : icon;
59                         NumberAnimation on rotation {
60                             from: 0; to: 360; running: (updating=="True"); loops: Animation.Infinite; duration: 900
61                         }
62                     }
63                 }
64
65                 Column {
66                     x: 92; width: wrapper.ListView.view.width - 95; y: 5; spacing: 2
67                     Text { text: title; color: "white"; width: parent.width; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
68                     Text { text: updatedDate + " / " + qsTr("%1 unread items").arg(unread); color: (unread=="0") ? "white" : "#7b97fd"; width: parent.width; font.bold: false; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
69                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
70                 }
71 //                Item {
72 //                    x: wrapper.ListView.view.width - 128; y: 12
73 //                    height: 58; width: 58;
74 //                    //anchors.horizontalCenter: parent.horizontalCenter;
75 //                    Image { source: "common/images/wmEditIcon.png" }
76 //                    MouseArea {
77 //                        anchors.fill: parent; onClicked: { container.feedEdit(feedname, feedid, url); }
78 //                    }
79 //                    visible: inEditMode
80 //                }
81                 Item {
82                     x: wrapper.ListView.view.width - 64; y: 12
83                     height: 58; width: 58;
84                     //anchors.horizontalCenter: parent.horizontalCenter;
85                     Image { source: "common/images/delete.png" }
86                     MouseArea {
87                         anchors.fill: parent; onClicked: { container.feedDeleted(feedid); }
88                     }
89                     visible: inEditMode
90                 }
91             }
92             MouseArea { 
93                 anchors.fill: wrapper; 
94                 onClicked: { 
95                     //controller.feedClicked(model.feed)
96                     feedClicked(feedid)
97                     
98                 }
99             }
100         }
101
102     }
103
104 }