psa: added progress bar for updates
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / qml / Categories.qml
1 import Qt 4.7
2 import com.nokia.meego 1.0
3
4 Item {
5 //    anchors.fill: parent;
6     width: parent.width; height: parent.height;
7     //anchors.top: parent.top; anchors.bottom: parent.bottom
8     property bool inEditMode: false
9     signal categoryClicked(string cat)
10
11     function reload() {
12         //categories.reload();
13         categories.xml = controller.getCategoryXml()
14         //console.log(controller.getCategoryXml())
15     }
16
17     ListView {
18         id: categoryList; model: categories; delegate: categoryDelegate; z: 6;
19         cacheBuffer: 100; width: parent.width;
20         height: updateBarFeeds.visible? parent.height-updateBarFeeds.height : parent.height;
21         clip: true
22         /*height: parent.height;*/
23     }
24
25     ProgressBar {
26         id: updateBar
27         minimumValue: 0
28         maximumValue: 100
29         value: window.updateProgressValue
30         visible: window.isUpdateInProgress
31         anchors.bottom: parent.bottom
32         width: parent.width
33     }
34
35     XmlListModel {
36
37         id: categories
38
39         xml: controller.getCategoryXml()
40         query: "/xml/category"
41
42         XmlRole { name: "title"; query: "catname/string()" }
43         XmlRole { name: "catid"; query: "catid/string()"; isKey: true }
44         XmlRole { name: "unread"; query: "unread/string()" }
45     }
46
47     Component {
48         id: categoryDelegate
49
50         Item {
51
52             id: wrapper; width: wrapper.ListView.view.width; height: 86
53             Item {
54                 id: moveMe
55                 height: parent.height
56                 Rectangle { color: settings.backColour; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
57 //                Rectangle {
58 //                    x: 6; y: 4; width: 77; height: parent.height - 9; color: "white"; smooth: true
59
60 //                }
61                 Column {
62                     x: 15;
63                     width: wrapper.ListView.view.width /*- 95;*/
64                     y: 15; spacing: 2
65                     anchors.margins: 5
66                     height: parent.height
67
68                     Text { text: title; color: settings.mainTextColour; width: parent.width; font.bold: true;
69                         //height: parent.height
70                         elide: Text.ElideRight; style: Text.Raised;
71                         styleColor: settings.mainShadowColour;
72                         font.pointSize: settings.mainTextSize
73                         verticalAlignment: Text.AlignVCenter;
74                     }
75                     Text {
76                         text: qsTr("%1 unread items").arg(unread);
77                         color: (unread=="0") ? settings.mainTextColour : settings.secondaryTextColour;
78                         width: parent.width; font.bold: false;
79                         elide: Text.ElideRight;
80                         //style: Text.Raised; styleColor: settings.mainShadowColour;
81                         font.pointSize: settings.secondaryTextSize
82                     }
83                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
84                 }
85 //                Item {
86 //                    x: wrapper.ListView.view.width - 128; y: 12
87 //                    height: 58; width: 58;
88 //                    //anchors.horizontalCenter: parent.horizontalCenter;
89 //                    Image { source: "common/images/wmEditIcon.png" }
90 //                    MouseArea {
91 //                        anchors.fill: parent; onClicked: { container.categoryEdit(catname, catid); }
92 //                    }
93 //                    visible: inEditMode
94 //                }
95 //                Item {
96 //                    x: wrapper.ListView.view.width - 64; y: 12
97 //                    height: 58; width: 58;
98 //                    //anchors.horizontalCenter: parent.horizontalCenter;
99 //                    Image { source: "common/images/delete.png" }
100 //                    MouseArea {
101 //                        anchors.fill: parent; onClicked: { container.categoryDeleted(catid); }
102 //                    }
103 //                    visible: inEditMode
104 //                }
105             }
106             MouseArea {
107                 enabled: !inEditMode; anchors.fill: wrapper;
108                 onClicked: { categoryClicked(catid); }
109                 onPressAndHold: {
110                     window.longPressCategory(catid)
111                 }
112             }
113             Component.onCompleted: {
114                 if (categories.count == 1) {
115                     categoryClicked(catid)
116                 }
117             }
118         }
119     }
120 }