psa: improved add feed/categories dialog
[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         categories.xml = controller.getCategoryXml()
13         //console.log(controller.getCategoryXml())
14     }
15
16     ListView {
17         id: categoryList; model: categories; delegate: categoryDelegate; z: 6;
18         cacheBuffer: 100; width: parent.width; height: parent.height;
19     }
20
21     XmlListModel {
22
23         id: categories
24
25         xml: controller.getCategoryXml()
26         query: "/xml/category"
27
28         XmlRole { name: "title"; query: "catname/string()" }
29         XmlRole { name: "catid"; query: "catid/string()"; isKey: true }
30         XmlRole { name: "unread"; query: "unread/string()" }
31     }
32
33     Component {
34         id: categoryDelegate
35
36         Item {
37
38             id: wrapper; width: wrapper.ListView.view.width; height: 86
39             Item {
40                 id: moveMe
41                 height: parent.height
42                 Rectangle { color: settings.backColour; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
43 //                Rectangle {
44 //                    x: 6; y: 4; width: 77; height: parent.height - 9; color: "white"; smooth: true
45
46 //                }
47                 Column {
48                     x: 15;
49                     width: wrapper.ListView.view.width /*- 95;*/
50                     y: 15; spacing: 2
51                     anchors.margins: 5
52                     height: parent.height
53
54                     Text { text: title; color: settings.mainTextColour; width: parent.width; font.bold: true;
55                         //height: parent.height
56                         elide: Text.ElideRight; style: Text.Raised;
57                         styleColor: settings.mainShadowColour;
58                         font.pointSize: settings.mainTextSize
59                         verticalAlignment: Text.AlignVCenter;
60                     }
61                     Text {
62                         text: qsTr("%1 unread items").arg(unread);
63                         color: (unread=="0") ? settings.mainTextColour : settings.secondaryTextColour;
64                         width: parent.width; font.bold: false;
65                         elide: Text.ElideRight;
66                         //style: Text.Raised; styleColor: settings.mainShadowColour;
67                         font.pointSize: settings.secondaryTextSize
68                     }
69                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
70                 }
71 //                Item {
72 //                    x: wrapper.ListView.view.width - 128; y: 12
73 //                    height: 58; width: 58;
74 //                    //anchors.horizontalCenter: parent.horizontalCenter;
75 //                    Image { source: "common/images/wmEditIcon.png" }
76 //                    MouseArea {
77 //                        anchors.fill: parent; onClicked: { container.categoryEdit(catname, catid); }
78 //                    }
79 //                    visible: inEditMode
80 //                }
81 //                Item {
82 //                    x: wrapper.ListView.view.width - 64; y: 12
83 //                    height: 58; width: 58;
84 //                    //anchors.horizontalCenter: parent.horizontalCenter;
85 //                    Image { source: "common/images/delete.png" }
86 //                    MouseArea {
87 //                        anchors.fill: parent; onClicked: { container.categoryDeleted(catid); }
88 //                    }
89 //                    visible: inEditMode
90 //                }
91             }
92             MouseArea {
93                 enabled: !inEditMode; anchors.fill: wrapper;
94                 onClicked: { categoryClicked(catid); }
95                 onPressAndHold: {
96                     window.longPressCategory(catid)
97                 }
98             }
99             Component.onCompleted: {
100                 if (categories.count == 1) {
101                     categoryClicked(catid)
102                 }
103             }
104         }
105     }
106 }