0.9.1-2 for extras-devel
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / qml / main.qml
index dad5f3a..68edc8c 100644 (file)
@@ -1,15 +1,30 @@
 import QtQuick 1.0
 import com.nokia.meego 1.0
-
+import com.nokia.extras 1.0
 
 PageStackWindow {
     id: window
     initialPage: categoryPage
 
-    signal articleClosed()
+    signal longPressCategory(string catid)
+    signal longPressFeed(string key)
+    signal categoryReloadRequest()
+    signal feedReloadRequest()
     property string feedid
     property string catid
 
+    Component.onCompleted: theme.inverted= true
+
+    onLongPressFeed: {
+        unsubscribeFeedMenu.key = key
+        unsubscribeFeedMenu.open()
+    }
+
+    onLongPressCategory: {
+        unsubscribeCategoryMenu.catid = catid
+        unsubscribeCategoryMenu.open()
+    }
+
     ToolBarLayout {
         id: commonTools
         visible: false
@@ -27,8 +42,10 @@ PageStackWindow {
         visualParent: pageStack
         MenuLayout {
             MenuItem { text: qsTr("Settings"); onClicked: {}  }
+            MenuItem { text: qsTr("Export Feeds"); onClicked: { var file=controller.exportOpml(); banner.text=qsTr("Feeds exported as "+file); banner.open() }  }
+            MenuItem { text: qsTr("Invert Theme"); onClicked: { theme.inverted = !theme.inverted }  }
             MenuItem { text: qsTr("Add Feeds"); onClicked: { pageStack.push(addFeedPage)  } }
-            MenuItem { text: qsTr("Update All Categories"); visible: pageStack.depth==3; onClicked: controller.updateAll(); }
+            MenuItem { text: qsTr("Update All Categories"); onClicked: controller.updateAll(); }
             MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
         }
     }
@@ -37,8 +54,8 @@ PageStackWindow {
         id: myFeedsMenu
         visualParent: pageStack
         MenuLayout {
-            MenuItem { text: qsTr("Update All Feeds"); onClicked: controller.updateAll(); }
-            MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
+            MenuItem { text: qsTr("Update All Feeds"); onClicked: controller.updateCategory(catid); }
+            //MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
         }
     }
 
@@ -48,7 +65,61 @@ PageStackWindow {
         MenuLayout {
             MenuItem { text: qsTr("Mark All As Read"); onClicked: controller.markAllAsRead(feedid); }
             MenuItem { text: qsTr("Update Feed"); onClicked: controller.updateFeed(feedid); }
-            MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
+            //MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
+        }
+    }
+
+    Menu {
+        id: unsubscribeFeedMenu
+        visualParent: pageStack
+        property string key
+        MenuLayout {
+            //MenuItem { text: qsTr("Update"); onClicked: controller.updateFeed(parent.feedid); }
+            MenuItem { text: qsTr("Delete");
+                onClicked: {
+                    feedConfirm.open()
+                    unsubscribeFeedMenu.close()
+                }
+            }
+        }
+        QueryDialog {
+            id: feedConfirm
+            //icon: "common/images/feedingit.png"
+            //titleText: "Delete Feed?"
+            message: "Delete this feed?"
+            acceptButtonText: "OK"
+            rejectButtonText: "Cancel"
+            onAccepted: {
+                controller.removeFeed(unsubscribeFeedMenu.key);
+                window.feedReloadRequest()
+            }
+        }
+    }
+
+    Menu {
+        id: unsubscribeCategoryMenu
+        visualParent: pageStack
+        property string catid
+        MenuLayout {
+            //MenuItem { text: qsTr("Update"); onClicked: controller.updateFeed(parent.feedid); }
+            MenuItem { text: qsTr("Delete");
+                onClicked: {
+                    categoryConfirm.open()
+                    unsubscribeFeedMenu.close()
+                }
+            }
+        }
+        QueryDialog {
+            id: categoryConfirm
+            //icon: "common/images/feedingit.png"
+            //titleText: "Delete Feed?"
+            message: "Delete this category?"
+            acceptButtonText: "OK"
+            rejectButtonText: "Cancel"
+            onAccepted: {
+                controller.removeCategory(unsubscribeCategoryMenu.catid);
+                window.categoryReloadRequest()
+            }
         }
     }
 
@@ -63,23 +134,24 @@ PageStackWindow {
         acceptButtonText: "OK"
     }
 
-//    Page{
-//        id: mainPage
-//        Component.onCompleted: {
-//            var main = Qt.createComponent("FeedingIt.qml");
-//            main.createObject(mainPage);
-//        }
-//    }
-
     Component {
         id: categoryPage
         Page {
             tools: commonTools
             Categories {
+                id: categoriesItem
                 onCategoryClicked: {
                     window.catid = cat
                     pageStack.push(feedsPage)
                 }
+
+            }
+            Connections {
+                target: window
+                onCategoryReloadRequest: {
+                    console.log("category reloaded")
+                    categoriesItem.reload()
+                }
             }
         }
     }
@@ -97,6 +169,7 @@ PageStackWindow {
                     window.feedid = feedid
                     pageStack.push(articlesPage)
                 }
+
             }
             ToolBarLayout {
                 id: feedsTools
@@ -104,6 +177,7 @@ PageStackWindow {
                 ToolIcon { iconId: "toolbar-back";
                     onClicked: {
                         myArticlesMenu.close();
+                        window.categoryReloadRequest()
                         pageStack.pop();
                     }
                 }
@@ -115,7 +189,7 @@ PageStackWindow {
             }
             Connections {
                  target: window
-                 onArticleClosed: feedsItem.reload()
+                 onFeedReloadRequest: feedsItem.reload()
              }
         }
     }
@@ -139,20 +213,22 @@ PageStackWindow {
                             flipper.articleShown = false;
                             flipper.reload()
                         } else {
-                            window.articleClosed();
+                            window.feedReloadRequest();
                             pageStack.pop();
                         }
                     }
                 }
 
                 ToolIcon {
-                    platformIconId: "toolbar-prev"
+                    platformIconId: "toolbar-previous"
+                    visible: flipper.articleShown
                     //anchors.right: (parent === undefined) ? undefined : parent.right
                     onClicked: flipper.prev();
                 }
 
                 ToolIcon {
                     platformIconId: "toolbar-next"
+                    visible: flipper.articleShown
                     //anchors.right: (parent === undefined) ? undefined : parent.right
                     onClicked: flipper.next()
                 }
@@ -170,4 +246,13 @@ PageStackWindow {
         id: addFeedPage
         AddFeed {}
     }
+
+    Settings {
+        id: settings
+    }
+
+    InfoBanner {
+        id: banner
+        //text: "This is an info banner with no icon"
+    }
 }