Adding wip version for meego harmattan
[feedingit] / psa_harmattan / feedingit / qml / Categories.qml
1 import Qt 4.7
2
3 Item {
4 //    anchors.fill: parent;
5     width: parent.width; height: parent.height;
6     //anchors.top: parent.top; anchors.bottom: parent.bottom
7     property bool inEditMode: true
8
9     function reload() {
10         categories.reload();
11     }
12
13     ListView {
14         id: categoryList; model: categories; delegate: categoryDelegate; z: 6;
15         cacheBuffer: 100; width: parent.width; height: parent.height;
16     }
17
18     XmlListModel {
19
20         id: categories
21
22         xml: controller.getCategoryXml()
23         query: "/xml/category"
24
25         XmlRole { name: "title"; query: "catname/string()" }
26         XmlRole { name: "catid"; query: "catid/string()"; isKey: true }
27     }
28
29     Component {
30         id: categoryDelegate
31
32         Item {
33
34             id: wrapper; width: wrapper.ListView.view.width; height: 86
35             Item {
36                 id: moveMe
37                 height: parent.height
38                 Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
39                 Rectangle {
40                     x: 6; y: 4; width: 77; height: parent.height - 9; color: "white"; smooth: true
41
42                 }
43                 Column {
44                     x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2
45                     Text { text: title; color: "white"; width: parent.width; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
46                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
47                 }
48                 Item {
49                     x: wrapper.ListView.view.width - 128; y: 12
50                     height: 58; width: 58;
51                     //anchors.horizontalCenter: parent.horizontalCenter;
52                     Image { source: "common/images/wmEditIcon.png" }
53                     MouseArea {
54                         anchors.fill: parent; onClicked: { container.categoryEdit(catname, catid); }
55                     }
56                     visible: inEditMode
57                 }
58                 Item {
59                     x: wrapper.ListView.view.width - 64; y: 12
60                     height: 58; width: 58;
61                     //anchors.horizontalCenter: parent.horizontalCenter;
62                     Image { source: "common/images/delete.png" }
63                     MouseArea {
64                         anchors.fill: parent; onClicked: { container.categoryDeleted(catid); }
65                     }
66                     visible: inEditMode
67                 }
68             }
69             MouseArea { enabled: !inEditMode; anchors.fill: wrapper; onClicked: { container.categoryClicked(catid); } }
70         }
71     }
72 }