psa: fix feeds not showing up in some cases
[feedingit] / psa_harmattan / feedingit / qml / Feeds.qml
1 import Qt 4.7
2
3 Item {
4     property string catid : parent.catid
5     property bool inEditMode: false
6     width: parent.width; height: parent.height;
7
8     signal feedClicked(string feedid)
9
10     function reload() {
11         feeds.xml = catid == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : controller.getFeedsXml(catid);
12         //feeds.reload()
13         console.log(feeds.xml)
14     }
15
16     Component.onCompleted: { console.log(catid + "/" + parent.catid) }
17
18     ListView {
19         id: feedList; model: feeds; delegate: feedDelegate; z: 6
20         width: parent.width; height: parent.height; /*x: 0;*/
21         cacheBuffer: 100;
22         flickDeceleration: 1500
23     }
24
25     XmlListModel {
26
27         id: feeds
28
29         //source: catid == "" ? "" : "http://localhost:8000/feeds/" + catid //+ "?onlyUnread=" + parent.hideReadArticles
30         xml: catid == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : controller.getFeedsXml(catid)
31         query: "/xml/feed"
32
33         XmlRole { name: "title"; query: "feedname/string()" }
34         XmlRole { name: "feedid"; query: "feedid/string()"; isKey: true }
35         XmlRole { name: "unread"; query: "unread/string()"; isKey: true }
36         XmlRole { name: "updatedDate"; query: "updatedDate/string()" }
37         XmlRole { name: "icon"; query: "icon/string()" }
38         XmlRole { name: "updating"; query: "updating/string()"; isKey: true }
39         //XmlRole { name: "url"; query: "url/string()"; }
40     }
41
42     Component {
43         id: feedDelegate
44
45         Item {
46
47             Component.onCompleted: console.log("item:"+feedid)
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 }