psa: improved add feed/categories dialog
[feedingit] / psa_harmattan / feedingit / qml / Feeds.qml
index 3aadc56..5131cbc 100644 (file)
@@ -1,19 +1,21 @@
 import Qt 4.7
 
 Item {
-    //anchors.fill: parent;
-    width: parent.width;
-    property string catid : ""
-    property bool inEditMode: true
-    x: parent.width; height: parent.height;
-    anchors.top: parent.top; anchors.bottom: parent.bottom
+    property string catid : parent.catid
+    property bool inEditMode: false
+    width: parent.width; height: parent.height;
+
+    signal feedClicked(string feedid)
 
     function reload() {
-       feeds.xml = catid == "" ? "" : controller.getFeedsXml(catid);
+       feeds.xml = catid == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : controller.getFeedsXml(catid);
         //feeds.reload()
+        //console.log(feeds.xml)
     }
 
-    //Component.onCompleted: { console.log(x + " /") }
+    //Component.onCompleted: { console.log(catid + "/" + parent.catid); console.log(feeds.xml) }
+
+    //onCatidChanged: console.log("catid changed: "+catid)
 
     ListView {
         id: feedList; model: feeds; delegate: feedDelegate; z: 6
@@ -27,7 +29,7 @@ Item {
         id: feeds
 
         //source: catid == "" ? "" : "http://localhost:8000/feeds/" + catid //+ "?onlyUnread=" + parent.hideReadArticles
-        //xml: catid == "" ? "" : controller.getFeedsXml(catid)
+        xml: catid == "" ? "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml></xml>" : controller.getFeedsXml(catid)
         query: "/xml/feed"
 
         XmlRole { name: "title"; query: "feedname/string()" }
@@ -43,60 +45,81 @@ Item {
         id: feedDelegate
 
         Item {
-            id: wrapper; width: wrapper.ListView.view.width;
+
+            //Component.onCompleted: console.log("item:"+feedid + " "+ visible + " "+ height + " " + width)
+            id: wrapper;
+            //width: wrapper.ListView.view.width;
             visible: (unread == "0" && feedsItem.hideReadFeeds=="True") ? false : true
+            //visible: true
             height: (visible) ? 86 : 0
+            width: parent.width
 
             Item {
                 id: moveMe
-                Rectangle { color: "black"; 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: 3; y: 4; width: 77; height: 77; color: "#000000"; smooth: true
-                    Image { width:32; height: 32; anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter;
-                        source: (updating=="True")? "common/images/loading.png" : (icon == "False") ? "common/images/feedingit.png" : icon;
-                        NumberAnimation on rotation {
-                            from: 0; to: 360; running: (updating=="True"); loops: Animation.Infinite; duration: 900
-                        }
+                    x: 3; y: 4; width: 77; height: 77;
+                    color: "#000000"; smooth: true
+                    Image { width:32; height: 32; anchors.verticalCenter: parent.verticalCenter;
+                        anchors.horizontalCenter: parent.horizontalCenter;
+                        source: (icon == "False") ? "common/images/feedingit.png" : icon
+                            // (updating=="True")? "common/images/loading.png" : (icon == "False") ? "common/images/feedingit.png" : icon;
+//                        NumberAnimation on rotation {
+//                            from: 0; to: 360; running: (updating=="True"); loops: Animation.Infinite; duration: 900
+//                        }
                     }
                 }
 
                 Column {
                     x: 92; width: wrapper.ListView.view.width - 95; y: 5; spacing: 2
-                    Text { text: title; color: "white"; width: parent.width; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
-                    Text { text: updatedDate + " / " + qsTr("%1 unread items").arg(unread); color: (unread=="0") ? "white" : "#7b97fd"; width: parent.width; font.bold: false; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
+                    Text { text: title; color: settings.mainTextColour;
+                        width: parent.width;
+                        font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: settings.mainShadowColour;
+                        font.pointSize: settings.mainTextSize
+                    }
+                    Text {
+                        text: updatedDate + " / " + 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.feedEdit(feedname, feedid, url); }
+////                    }
+////                    visible: inEditMode
+////                }
 //                Item {
-//                    x: wrapper.ListView.view.width - 128; y: 12
+//                    x: wrapper.ListView.view.width - 64; y: 12
 //                    height: 58; width: 58;
 //                    //anchors.horizontalCenter: parent.horizontalCenter;
-//                    Image { source: "common/images/wmEditIcon.png" }
+//                    Image { source: "common/images/delete.png" }
 //                    MouseArea {
-//                        anchors.fill: parent; onClicked: { container.feedEdit(feedname, feedid, url); }
+//                        anchors.fill: parent; onClicked: { container.feedDeleted(feedid); }
 //                    }
 //                    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.feedDeleted(feedid); }
-                    }
-                    visible: inEditMode
-                }
             }
             MouseArea { 
                 anchors.fill: wrapper; 
                 onClicked: { 
-                    controller.feedClicked(model.feed)
-                    container.feedClicked(feedid, updating=="True") 
+                    //controller.feedClicked(model.feed)
+                    feedClicked(feedid)
                     
                 }
+                onPressAndHold: {
+                    window.longPressFeed(feedid)
+                }
             }
-        }
 
+        }
     }
 
 }