psa: improved add feed/categories dialog
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / debian / feedingit / usr / share / feedingit / qml / Categories.qml
index 5a97370..4469ba1 100644 (file)
@@ -8,7 +8,9 @@ Item {
     signal categoryClicked(string cat)
 
     function reload() {
-        categories.reload();
+        //categories.reload();
+        categories.xml = controller.getCategoryXml()
+        //console.log(controller.getCategoryXml())
     }
 
     ListView {
@@ -25,6 +27,7 @@ Item {
 
         XmlRole { name: "title"; query: "catname/string()" }
         XmlRole { name: "catid"; query: "catid/string()"; isKey: true }
+        XmlRole { name: "unread"; query: "unread/string()" }
     }
 
     Component {
@@ -36,46 +39,68 @@ Item {
             Item {
                 id: moveMe
                 height: parent.height
-                Rectangle { color: "#eeeeee"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
+                Rectangle { color: settings.backColour; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
 //                Rectangle {
 //                    x: 6; y: 4; width: 77; height: parent.height - 9; color: "white"; smooth: true
 
 //                }
                 Column {
                     x: 15;
-                    width: wrapper.ListView.view.width /*- 95; y: 15*/; spacing: 2
+                    width: wrapper.ListView.view.width /*- 95;*/
+                    y: 15; spacing: 2
                     anchors.margins: 5
                     height: parent.height
 
-                    Text { text: title; color: "white"; width: parent.width; font.bold: true;
-                        height: parent.height
-                        elide: Text.ElideRight; style: Text.Raised; styleColor: "black"; font.pointSize: 20
+                    Text { text: title; color: settings.mainTextColour; width: parent.width; font.bold: true;
+                        //height: parent.height
+                        elide: Text.ElideRight; style: Text.Raised;
+                        styleColor: settings.mainShadowColour;
+                        font.pointSize: settings.mainTextSize
                         verticalAlignment: Text.AlignVCenter;
                     }
+                    Text {
+                        text: qsTr("%1 unread items").arg(unread);
+                        color: (unread=="0") ? settings.mainTextColour : settings.secondaryTextColour;
+                        width: parent.width; font.bold: false;
+                        elide: Text.ElideRight;
+                        //style: Text.Raised; styleColor: settings.mainShadowColour;
+                        font.pointSize: settings.secondaryTextSize
+                    }
                     //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
                 }
-                Item {
-                    x: wrapper.ListView.view.width - 128; y: 12
-                    height: 58; width: 58;
-                    //anchors.horizontalCenter: parent.horizontalCenter;
-                    Image { source: "common/images/wmEditIcon.png" }
-                    MouseArea {
-                        anchors.fill: parent; onClicked: { container.categoryEdit(catname, catid); }
-                    }
-                    visible: inEditMode
+//                Item {
+//                    x: wrapper.ListView.view.width - 128; y: 12
+//                    height: 58; width: 58;
+//                    //anchors.horizontalCenter: parent.horizontalCenter;
+//                    Image { source: "common/images/wmEditIcon.png" }
+//                    MouseArea {
+//                        anchors.fill: parent; onClicked: { container.categoryEdit(catname, catid); }
+//                    }
+//                    visible: inEditMode
+//                }
+//                Item {
+//                    x: wrapper.ListView.view.width - 64; y: 12
+//                    height: 58; width: 58;
+//                    //anchors.horizontalCenter: parent.horizontalCenter;
+//                    Image { source: "common/images/delete.png" }
+//                    MouseArea {
+//                        anchors.fill: parent; onClicked: { container.categoryDeleted(catid); }
+//                    }
+//                    visible: inEditMode
+//                }
+            }
+            MouseArea {
+                enabled: !inEditMode; anchors.fill: wrapper;
+                onClicked: { categoryClicked(catid); }
+                onPressAndHold: {
+                    window.longPressCategory(catid)
                 }
-                Item {
-                    x: wrapper.ListView.view.width - 64; y: 12
-                    height: 58; width: 58;
-                    //anchors.horizontalCenter: parent.horizontalCenter;
-                    Image { source: "common/images/delete.png" }
-                    MouseArea {
-                        anchors.fill: parent; onClicked: { container.categoryDeleted(catid); }
-                    }
-                    visible: inEditMode
+            }
+            Component.onCompleted: {
+                if (categories.count == 1) {
+                    categoryClicked(catid)
                 }
             }
-            MouseArea { enabled: !inEditMode; anchors.fill: wrapper; onClicked: { categoryClicked(catid); } }
         }
     }
 }