Adding PageStack support in qml
authorYves Marcoz <yves@marcoz.org>
Tue, 25 Oct 2011 05:01:38 +0000 (22:01 -0700)
committerYves Marcoz <yves@marcoz.org>
Tue, 25 Oct 2011 05:01:38 +0000 (22:01 -0700)
psa_harmattan/feedingit/deploy.sh [deleted file]
psa_harmattan/feedingit/pysrc/rss_sqlite.py
psa_harmattan/feedingit/pysrc/wc.py
psa_harmattan/feedingit/qml/Categories.qml
psa_harmattan/feedingit/qml/Feeds.qml
psa_harmattan/feedingit/qml/main.qml
psa_harmattan/feedingit/qml/qml.qmlproject [new file with mode: 0644]

diff --git a/psa_harmattan/feedingit/deploy.sh b/psa_harmattan/feedingit/deploy.sh
deleted file mode 100644 (file)
index 23fc3a7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-psa build-deb
-#scp /scratchbox/users/ymarcoz/home/ymarcoz/workspace/feedingit_harmattan/feedingit/deb_dist/feedingit_0.1.0-1_all.deb root@192.168.1.136:
-scp /scratchbox/users/ymarcoz/home/ymarcoz/workspace/feedingit-pyside/psa/feedingit/deb_dist/feedingit_0.1.0-1_all.deb root@192.168.1.136:
-ssh root@192.168.1.136 "dpkg -i --force-depends-version feedingit_0.1.0-1_all.deb"
index 77849df..4b4d276 100644 (file)
@@ -522,6 +522,9 @@ class Feed(BaseObject):
                        self.serial_execution_lock.release ()
                        have_serial_execution_lock = False
                        for img in images:
+                           if not 'src' in img:
+                               continue
+
                            filename = self.addImage(
                                configdir, self.key, baseurl, img['src'],
                                opener=opener)
@@ -969,36 +972,39 @@ class Listing(BaseObject):
 
         # Check that Woodchuck's state is up to date with respect our
         # state.
-        updater = os.path.basename(sys.argv[0]) == 'update_feeds.py'
-        wc_init (self, True if updater else False)
-        if wc().available() and updater:
-            # The list of known streams.
-            streams = wc().streams_list ()
-            stream_ids = [s.identifier for s in streams]
-
-            # Register any unknown streams.  Remove known streams from
-            # STREAMS_IDS.
-            for key in self.getListOfFeeds():
-                title = self.getFeedTitle(key)
-                # XXX: We should also check whether the list of
-                # articles/objects in each feed/stream is up to date.
-                if key not in stream_ids:
-                    logger.debug(
-                        "Registering previously unknown channel: %s (%s)"
-                        % (key, title,))
-                    # Use a default refresh interval of 6 hours.
-                    wc().stream_register (key, title, 6 * 60 * 60)
-                else:
-                    # Make sure the human readable name is up to date.
-                    if wc()[key].human_readable_name != title:
-                        wc()[key].human_readable_name = title
-                    stream_ids.remove (key)
-                    
-
-            # Unregister any streams that are no longer subscribed to.
-            for id in stream_ids:
-                logger.debug("Unregistering %s" % (id,))
-                w.stream_unregister (id)
+        try:
+            updater = os.path.basename(sys.argv[0]) == 'update_feeds.py'
+            wc_init (self, True if updater else False)
+            if wc().available() and updater:
+                # The list of known streams.
+                streams = wc().streams_list ()
+                stream_ids = [s.identifier for s in streams]
+    
+                # Register any unknown streams.  Remove known streams from
+                # STREAMS_IDS.
+                for key in self.getListOfFeeds():
+                    title = self.getFeedTitle(key)
+                    # XXX: We should also check whether the list of
+                    # articles/objects in each feed/stream is up to date.
+                    if key not in stream_ids:
+                        logger.debug(
+                            "Registering previously unknown channel: %s (%s)"
+                            % (key, title,))
+                        # Use a default refresh interval of 6 hours.
+                        wc().stream_register (key, title, 6 * 60 * 60)
+                    else:
+                        # Make sure the human readable name is up to date.
+                        if wc()[key].human_readable_name != title:
+                            wc()[key].human_readable_name = title
+                        stream_ids.remove (key)
+                        
+    
+                # Unregister any streams that are no longer subscribed to.
+                for id in stream_ids:
+                    logger.debug("Unregistering %s" % (id,))
+                    w.stream_unregister (id)
+        except Exception:
+            logger.exception("Registering streams with Woodchuck")
 
     def importOldFormatFeeds(self):
         """This function loads feeds that are saved in an outdated format, and converts them to sqlite"""
@@ -1207,7 +1213,7 @@ class Listing(BaseObject):
         return self.lookup('categories', 'title', id)
     
     def getSortedListOfKeys(self, order, onlyUnread=False, category=1):
-        if order == "Most unread":
+        if   order == "Most unread":
             tmp = "ORDER BY unread DESC"
             #keyorder = sorted(feedInfo, key = lambda k: feedInfo[k][1], reverse=True)
         elif order == "Least unread":
index c8fd987..c28d1d7 100644 (file)
@@ -58,7 +58,7 @@ class mywoodchuck (PyWoodchuck):
         return False
 
     # Woodchuck upcalls.
-    def stream_update_cb(self, stream):
+    def stream_update_cb(self, stream, *args, **kwargs):
         logger.debug("stream update called on %s (%s)"
                      % (stream.human_readable_name, stream.identifier,))
 
@@ -71,10 +71,18 @@ class mywoodchuck (PyWoodchuck):
                          % (stream.identifier, traceback.format_exc ()))
 
     def object_transfer_cb(self, stream, object,
-                           version, filename, quality):
-        log ("object transfer called on %s (%s) in stream %s (%s)"
-             % (object.human_readable_name, object.identifier,
-                stream.human_readable_name, stream.identifier))
+                           version, filename, quality,
+                           *args, **kwargs):
+        logger.debug ("object transfer called on %s (%s) in stream %s (%s)"
+                      % (object.human_readable_name, object.identifier,
+                         stream.human_readable_name, stream.identifier))
+        try:
+            self[stream.identifier][object.identifier].dont_transfer = True
+        except Exception, e:
+            logger.warn("Setting '%s'(%s).'%s'(%s).DontTransfer: %s"
+                        % (stream.human_readable_name, stream.identifier,
+                           object.human_readable_name, object.identifier,
+                           str(e)))
 
 _w = None
 def wc_init(listing, request_feedback=False):
index 6af2f1e..6f95bfe 100644 (file)
@@ -5,6 +5,7 @@ Item {
     width: parent.width; height: parent.height;
     //anchors.top: parent.top; anchors.bottom: parent.bottom
     property bool inEditMode: true
+    signal categoryClicked(string cat)
 
     function reload() {
         categories.reload();
@@ -66,7 +67,7 @@ Item {
                     visible: inEditMode
                 }
             }
-            MouseArea { enabled: !inEditMode; anchors.fill: wrapper; onClicked: { container.categoryClicked(catid); } }
+            MouseArea { enabled: !inEditMode; anchors.fill: wrapper; onClicked: { categoryClicked(catid); } }
         }
     }
 }
index 3aadc56..874f426 100644 (file)
@@ -8,6 +8,8 @@ Item {
     x: parent.width; height: parent.height;
     anchors.top: parent.top; anchors.bottom: parent.bottom
 
+    signal feedClicked(string feedid)
+
     function reload() {
        feeds.xml = catid == "" ? "" : controller.getFeedsXml(catid);
         //feeds.reload()
@@ -90,8 +92,8 @@ Item {
             MouseArea { 
                 anchors.fill: wrapper; 
                 onClicked: { 
-                    controller.feedClicked(model.feed)
-                    container.feedClicked(feedid, updating=="True") 
+                    //controller.feedClicked(model.feed)
+                    feedClicked(feedid)
                     
                 }
             }
index a88ebfc..28b4205 100644 (file)
@@ -3,13 +3,76 @@ import com.nokia.meego 1.0
 
 
 PageStackWindow {
-    initialPage: mainPage
+    initialPage: categoryPage
 
-    Page{
-        id: mainPage
-        Component.onCompleted: {
-            var main = Qt.createComponent("FeedingIt.qml");
-            main.createObject(mainPage);
+    ToolBarLayout {
+        id: commonTools
+        visible: false
+        ToolIcon { iconId: "toolbar-back"; onClicked: { myMenu.close(); pageStack.pop(); }
+            visible: pageStack.depth>1 }
+        ToolIcon {
+            platformIconId: "toolbar-view-menu"
+            anchors.right: (parent === undefined) ? undefined : parent.right
+            onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
+        }
+    }
+
+    Menu {
+        id: myMenu
+        visualParent: pageStack
+        MenuLayout {
+            MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
+        }
+    }
+
+    QueryDialog {
+        id: query
+        icon: "common/images/feedingit.png"
+        titleText: "Feedingit RSS Reader"
+        message: "Version: 0.0.9"
+        +"<br><br>FeedingIt RSS Reader.<br>"
+        +"<br>&copy; 2011 feedingit.marcoz.org"
+        +"<br>http://feedingit.marcoz.org"
+        acceptButtonText: "OK"
+    }
+
+//    Page{
+//        id: mainPage
+//        Component.onCompleted: {
+//            var main = Qt.createComponent("FeedingIt.qml");
+//            main.createObject(mainPage);
+//        }
+//    }
+
+    Component {
+        id: categoryPage
+        Page {
+            tools: commonTools
+            Categories {
+                onCategoryClicked: pageStack.push(feedsPage, {catid: catid})
+            }
+        }
+    }
+
+    Component {
+        id: feedsPage
+        Page {
+            tools: commonTools
+            Feeds {
+                id: feedsItem
+
+                onFeedClicked: pageStack.push(articlesPage, {feedid: feedid})
+            }
+        }
+    }
+
+    Component {
+        id: articlesPage
+        Page {
+            tools: commonTools
+            ArticleViewer {
+                id: flipper
+            }
         }
     }
 }
diff --git a/psa_harmattan/feedingit/qml/qml.qmlproject b/psa_harmattan/feedingit/qml/qml.qmlproject
new file mode 100644 (file)
index 0000000..8f554f8
--- /dev/null
@@ -0,0 +1,20 @@
+/* File generated by Qt Creator, version 2.2.1 */
+
+import QmlProject 1.1
+
+Project {
+    mainFile: "main.qml"
+
+    /* Include .qml, .js, and image files from current directory and subdirectories */
+    QmlFiles {
+        directory: "."
+    }
+    JavaScriptFiles {
+        directory: "."
+    }
+    ImageFiles {
+        directory: "."
+    }
+    /* List of plugin directories passed to QML runtime */
+    // importPaths: [ "../exampleplugin" ]
+}