psa: improved add feed/categories dialog
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / debian / feedingit / usr / share / 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); console.log(feeds.xml) }
17
18     //onCatidChanged: console.log("catid changed: "+catid)
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 == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : 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
49             //Component.onCompleted: console.log("item:"+feedid + " "+ visible + " "+ height + " " + width)
50             id: wrapper;
51             //width: wrapper.ListView.view.width;
52             visible: (unread == "0" && feedsItem.hideReadFeeds=="True") ? false : true
53             //visible: true
54             height: (visible) ? 86 : 0
55             width: parent.width
56
57             Item {
58                 id: moveMe
59                 Rectangle { color: settings.backColour; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
60                 Rectangle {
61                     x: 3; y: 4; width: 77; height: 77;
62                     color: "#000000"; smooth: true
63                     Image { width:32; height: 32; anchors.verticalCenter: parent.verticalCenter;
64                         anchors.horizontalCenter: parent.horizontalCenter;
65                         source: (icon == "False") ? "common/images/feedingit.png" : icon
66                             // (updating=="True")? "common/images/loading.png" : (icon == "False") ? "common/images/feedingit.png" : icon;
67 //                        NumberAnimation on rotation {
68 //                            from: 0; to: 360; running: (updating=="True"); loops: Animation.Infinite; duration: 900
69 //                        }
70                     }
71                 }
72
73                 Column {
74                     x: 92; width: wrapper.ListView.view.width - 95; y: 5; spacing: 2
75                     Text { text: title; color: settings.mainTextColour;
76                         width: parent.width;
77                         font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: settings.mainShadowColour;
78                         font.pointSize: settings.mainTextSize
79                     }
80                     Text {
81                         text: updatedDate + " / " + qsTr("%1 unread items").arg(unread);
82                         color: (unread=="0") ? settings.mainTextColour : settings.secondaryTextColour;
83                         width: parent.width; font.bold: false; elide: Text.ElideRight;
84                         //style: Text.Raised; styleColor: settings.mainShadowColour;
85                         font.pointSize: settings.secondaryTextSize
86                     }
87                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
88                 }
89 ////                Item {
90 ////                    x: wrapper.ListView.view.width - 128; y: 12
91 ////                    height: 58; width: 58;
92 ////                    //anchors.horizontalCenter: parent.horizontalCenter;
93 ////                    Image { source: "common/images/wmEditIcon.png" }
94 ////                    MouseArea {
95 ////                        anchors.fill: parent; onClicked: { container.feedEdit(feedname, feedid, url); }
96 ////                    }
97 ////                    visible: inEditMode
98 ////                }
99 //                Item {
100 //                    x: wrapper.ListView.view.width - 64; y: 12
101 //                    height: 58; width: 58;
102 //                    //anchors.horizontalCenter: parent.horizontalCenter;
103 //                    Image { source: "common/images/delete.png" }
104 //                    MouseArea {
105 //                        anchors.fill: parent; onClicked: { container.feedDeleted(feedid); }
106 //                    }
107 //                    visible: inEditMode
108 //                }
109             }
110             MouseArea { 
111                 anchors.fill: wrapper; 
112                 onClicked: { 
113                     //controller.feedClicked(model.feed)
114                     feedClicked(feedid)
115                     
116                 }
117                 onPressAndHold: {
118                     window.longPressFeed(feedid)
119                 }
120             }
121
122         }
123     }
124
125 }