5a973703dbc844dfa1d641a9698115dac1bc9eff
[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: "#eeeeee"; 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: 15;
46                     width: wrapper.ListView.view.width /*- 95; y: 15*/; spacing: 2
47                     anchors.margins: 5
48                     height: parent.height
49
50                     Text { text: title; color: "white"; width: parent.width; font.bold: true;
51                         height: parent.height
52                         elide: Text.ElideRight; style: Text.Raised; styleColor: "black"; font.pointSize: 20
53                         verticalAlignment: Text.AlignVCenter;
54                     }
55                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
56                 }
57                 Item {
58                     x: wrapper.ListView.view.width - 128; y: 12
59                     height: 58; width: 58;
60                     //anchors.horizontalCenter: parent.horizontalCenter;
61                     Image { source: "common/images/wmEditIcon.png" }
62                     MouseArea {
63                         anchors.fill: parent; onClicked: { container.categoryEdit(catname, catid); }
64                     }
65                     visible: inEditMode
66                 }
67                 Item {
68                     x: wrapper.ListView.view.width - 64; y: 12
69                     height: 58; width: 58;
70                     //anchors.horizontalCenter: parent.horizontalCenter;
71                     Image { source: "common/images/delete.png" }
72                     MouseArea {
73                         anchors.fill: parent; onClicked: { container.categoryDeleted(catid); }
74                     }
75                     visible: inEditMode
76                 }
77             }
78             MouseArea { enabled: !inEditMode; anchors.fill: wrapper; onClicked: { categoryClicked(catid); } }
79         }
80     }
81 }