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