From a5126cf76febbb5359e976a6904c1f76993d99b2 Mon Sep 17 00:00:00 2001 From: Yves Marcoz Date: Mon, 24 Oct 2011 22:01:38 -0700 Subject: [PATCH] Adding PageStack support in qml --- psa_harmattan/feedingit/deploy.sh | 4 -- psa_harmattan/feedingit/pysrc/rss_sqlite.py | 68 +++++++++++++----------- psa_harmattan/feedingit/pysrc/wc.py | 18 +++++-- psa_harmattan/feedingit/qml/Categories.qml | 3 +- psa_harmattan/feedingit/qml/Feeds.qml | 6 ++- psa_harmattan/feedingit/qml/main.qml | 75 ++++++++++++++++++++++++--- psa_harmattan/feedingit/qml/qml.qmlproject | 20 +++++++ 7 files changed, 145 insertions(+), 49 deletions(-) delete mode 100644 psa_harmattan/feedingit/deploy.sh create mode 100644 psa_harmattan/feedingit/qml/qml.qmlproject diff --git a/psa_harmattan/feedingit/deploy.sh b/psa_harmattan/feedingit/deploy.sh deleted file mode 100644 index 23fc3a7..0000000 --- a/psa_harmattan/feedingit/deploy.sh +++ /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" diff --git a/psa_harmattan/feedingit/pysrc/rss_sqlite.py b/psa_harmattan/feedingit/pysrc/rss_sqlite.py index 77849df..4b4d276 100644 --- a/psa_harmattan/feedingit/pysrc/rss_sqlite.py +++ b/psa_harmattan/feedingit/pysrc/rss_sqlite.py @@ -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": diff --git a/psa_harmattan/feedingit/pysrc/wc.py b/psa_harmattan/feedingit/pysrc/wc.py index c8fd987..c28d1d7 100644 --- a/psa_harmattan/feedingit/pysrc/wc.py +++ b/psa_harmattan/feedingit/pysrc/wc.py @@ -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): diff --git a/psa_harmattan/feedingit/qml/Categories.qml b/psa_harmattan/feedingit/qml/Categories.qml index 6af2f1e..6f95bfe 100644 --- a/psa_harmattan/feedingit/qml/Categories.qml +++ b/psa_harmattan/feedingit/qml/Categories.qml @@ -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); } } } } } diff --git a/psa_harmattan/feedingit/qml/Feeds.qml b/psa_harmattan/feedingit/qml/Feeds.qml index 3aadc56..874f426 100644 --- a/psa_harmattan/feedingit/qml/Feeds.qml +++ b/psa_harmattan/feedingit/qml/Feeds.qml @@ -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) } } diff --git a/psa_harmattan/feedingit/qml/main.qml b/psa_harmattan/feedingit/qml/main.qml index a88ebfc..28b4205 100644 --- a/psa_harmattan/feedingit/qml/main.qml +++ b/psa_harmattan/feedingit/qml/main.qml @@ -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" + +"

FeedingIt RSS Reader.
" + +"
© 2011 feedingit.marcoz.org" + +"
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 index 0000000..8f554f8 --- /dev/null +++ b/psa_harmattan/feedingit/qml/qml.qmlproject @@ -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" ] +} -- 1.7.9.5