Adding wip version for meego harmattan
[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     function reload() {
12         feeds.xml = catid == "" ? "" : controller.getFeedsXml(catid);
13         //feeds.reload()
14     }
15
16     //Component.onCompleted: { console.log(x + " /") }
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 == "" ? "" : 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             id: wrapper; width: wrapper.ListView.view.width;
47             visible: (unread == "0" && feedsItem.hideReadFeeds=="True") ? false : true
48             height: (visible) ? 86 : 0
49
50             Item {
51                 id: moveMe
52                 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
53                 Rectangle {
54                     x: 3; y: 4; width: 77; height: 77; color: "#000000"; smooth: true
55                     Image { width:32; height: 32; anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter;
56                         source: (updating=="True")? "common/images/loading.png" : (icon == "False") ? "common/images/feedingit.png" : icon;
57                         NumberAnimation on rotation {
58                             from: 0; to: 360; running: (updating=="True"); loops: Animation.Infinite; duration: 900
59                         }
60                     }
61                 }
62
63                 Column {
64                     x: 92; width: wrapper.ListView.view.width - 95; y: 5; spacing: 2
65                     Text { text: title; color: "white"; width: parent.width; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
66                     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" }
67                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
68                 }
69 //                Item {
70 //                    x: wrapper.ListView.view.width - 128; y: 12
71 //                    height: 58; width: 58;
72 //                    //anchors.horizontalCenter: parent.horizontalCenter;
73 //                    Image { source: "common/images/wmEditIcon.png" }
74 //                    MouseArea {
75 //                        anchors.fill: parent; onClicked: { container.feedEdit(feedname, feedid, url); }
76 //                    }
77 //                    visible: inEditMode
78 //                }
79                 Item {
80                     x: wrapper.ListView.view.width - 64; y: 12
81                     height: 58; width: 58;
82                     //anchors.horizontalCenter: parent.horizontalCenter;
83                     Image { source: "common/images/delete.png" }
84                     MouseArea {
85                         anchors.fill: parent; onClicked: { container.feedDeleted(feedid); }
86                     }
87                     visible: inEditMode
88                 }
89             }
90             MouseArea { 
91                 anchors.fill: wrapper; 
92                 onClicked: { 
93                     controller.feedClicked(model.feed)
94                     container.feedClicked(feedid, updating=="True") 
95                     
96                 }
97             }
98         }
99
100     }
101
102 }