psa: added progress bar for updates
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / qml / Feeds.qml
1 import Qt 4.7
2 import com.nokia.meego 1.0
3
4 Item {
5     property string catid : parent.catid
6     property bool inEditMode: false
7     width: parent.width; height: parent.height;
8
9     signal feedClicked(string feedid)
10
11     function reload() {
12         feeds.xml = catid == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : controller.getFeedsXml(catid);
13         //feeds.reload()
14         //console.log(feeds.xml)
15     }
16
17     //Component.onCompleted: { console.log(catid + "/" + parent.catid); console.log(feeds.xml) }
18
19     //onCatidChanged: console.log("catid changed: "+catid)
20
21     ListView {
22         id: feedList; model: feeds; delegate: feedDelegate; z: 6
23         width: parent.width; height: updateBarFeeds.visible? parent.height-updateBarFeeds.height : parent.height; /*x: 0;*/
24         cacheBuffer: 100;
25         flickDeceleration: 1500
26         clip: true
27     }
28
29     ProgressBar {
30         id: updateBarFeeds
31         minimumValue: 0
32         maximumValue: 100
33         value: window.updateProgressValue
34         visible: window.isUpdateInProgress
35         anchors.bottom: parent.bottom
36         z: 8
37         width: parent.width
38     }
39
40     XmlListModel {
41
42         id: feeds
43
44         //source: catid == "" ? "" : "http://localhost:8000/feeds/" + catid //+ "?onlyUnread=" + parent.hideReadArticles
45         xml: catid == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : controller.getFeedsXml(catid)
46         query: "/xml/feed"
47
48         XmlRole { name: "title"; query: "feedname/string()" }
49         XmlRole { name: "feedid"; query: "feedid/string()"; isKey: true }
50         XmlRole { name: "unread"; query: "unread/string()"; isKey: true }
51         XmlRole { name: "updatedDate"; query: "updatedDate/string()" }
52         XmlRole { name: "icon"; query: "icon/string()" }
53         XmlRole { name: "updating"; query: "updating/string()"; isKey: true }
54         //XmlRole { name: "url"; query: "url/string()"; }
55     }
56
57     Component {
58         id: feedDelegate
59
60         Item {
61
62             //Component.onCompleted: console.log("item:"+feedid + " "+ visible + " "+ height + " " + width)
63             id: wrapper;
64             //width: wrapper.ListView.view.width;
65             visible: (unread == "0" && settings.hideReadFeeds) ? false : true
66             //visible: true
67             height: (visible) ? 86 : 0
68             width: parent.width
69
70             Item {
71                 id: moveMe
72                 Rectangle { color: settings.backColour; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
73                 Rectangle {
74                     x: 3; y: 4; width: 77; height: 77;
75                     color: "#000000"; smooth: true
76                     Image { width:32; height: 32; anchors.verticalCenter: parent.verticalCenter;
77                         anchors.horizontalCenter: parent.horizontalCenter;
78                         source: (icon == "False") ? "common/images/feedingit.png" : icon
79                             // (updating=="True")? "common/images/loading.png" : (icon == "False") ? "common/images/feedingit.png" : icon;
80 //                        NumberAnimation on rotation {
81 //                            from: 0; to: 360; running: (updating=="True"); loops: Animation.Infinite; duration: 900
82 //                        }
83                     }
84                 }
85
86                 Column {
87                     x: 92; width: wrapper.ListView.view.width - 95; y: 5; spacing: 2
88                     Text { text: title; color: settings.mainTextColour;
89                         width: parent.width;
90                         font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: settings.mainShadowColour;
91                         font.pointSize: settings.mainTextSize
92                     }
93                     Text {
94                         text: updatedDate + " / " + qsTr("%1 unread items").arg(unread);
95                         color: (unread=="0") ? settings.mainTextColour : settings.secondaryTextColour;
96                         width: parent.width; font.bold: false; elide: Text.ElideRight;
97                         //style: Text.Raised; styleColor: settings.mainShadowColour;
98                         font.pointSize: settings.secondaryTextSize
99                     }
100                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
101                 }
102 ////                Item {
103 ////                    x: wrapper.ListView.view.width - 128; y: 12
104 ////                    height: 58; width: 58;
105 ////                    //anchors.horizontalCenter: parent.horizontalCenter;
106 ////                    Image { source: "common/images/wmEditIcon.png" }
107 ////                    MouseArea {
108 ////                        anchors.fill: parent; onClicked: { container.feedEdit(feedname, feedid, url); }
109 ////                    }
110 ////                    visible: inEditMode
111 ////                }
112 //                Item {
113 //                    x: wrapper.ListView.view.width - 64; y: 12
114 //                    height: 58; width: 58;
115 //                    //anchors.horizontalCenter: parent.horizontalCenter;
116 //                    Image { source: "common/images/delete.png" }
117 //                    MouseArea {
118 //                        anchors.fill: parent; onClicked: { container.feedDeleted(feedid); }
119 //                    }
120 //                    visible: inEditMode
121 //                }
122             }
123             MouseArea { 
124                 anchors.fill: wrapper; 
125                 onClicked: { 
126                     //controller.feedClicked(model.feed)
127                     feedClicked(feedid)
128                     
129                 }
130                 onPressAndHold: {
131                     window.longPressFeed(feedid)
132                 }
133             }
134
135         }
136     }
137
138 }