changeset 47:a8442c3487b5

add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sun, 16 May 2010 08:13:07 +0200
parents 03358c113170
children 6e5219e05625
files Feed.py MainWindow.py Mapping.py
diffstat 3 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Feed.py	Sun May 16 07:54:24 2010 +0200
+++ b/Feed.py	Sun May 16 08:13:07 2010 +0200
@@ -13,6 +13,7 @@
         # default: update every 60 minutes
         self.update_interval = 60
         self.incrementNextUpdateDate()
+        self.auto_load_entry_link = False
 
     def __repr__(self):
         return "<Feed (%d) %s>" % (self.pk, self.title)
--- a/MainWindow.py	Sun May 16 07:54:24 2010 +0200
+++ b/MainWindow.py	Sun May 16 08:13:07 2010 +0200
@@ -39,10 +39,24 @@
         
     def feedEntrySelected(self, index):
         self.ui.menuArticle.setEnabled(True)
+        
         row = index.row()
         self.selectedEntry = self.sortedEntries[row]
-        baseUrl = QUrl(self.selectedEntry.link) # TODO this is the wrong base url, figure out the correct one
+        
+        if self.selectedEntry.feed.auto_load_entry_link:
+            self.openLinkFromSelectedEntry()
+        else:
+            self.openSummaryFromSelectedEntry()
+            
+    def openSummaryFromSelectedEntry(self):
+        # TODO this is the wrong base url, figure out the correct one
+        baseUrl = QUrl(self.selectedEntry.link)
         self.ui.webView.setHtml(self.selectedEntry.summary, baseUrl)
+
+    def openLinkFromSelectedEntry(self):
+        url = QUrl(self.selectedEntry.link)
+        self.ui.webView.load(url)
+        self.ui.webView.show()
     
     def toggleReadOnSelectedEntry(self):
         self.selectedEntry.toggleRead()
@@ -62,12 +76,7 @@
         # TODO make browser configurable
         browser = "/usr/local/bin/opera"
         subprocess.Popen([browser, self.selectedEntry.link])
-        
-    def openLinkFromSelectedEntry(self):
-        url = QUrl(self.selectedEntry.link)
-        self.ui.webView.load(url)
-        self.ui.webView.show()
-        
+                
     def showPreferences(self):
         preferences = PreferencesDialog(self.session)
         preferences.exec_()
--- a/Mapping.py	Sun May 16 07:54:24 2010 +0200
+++ b/Mapping.py	Sun May 16 08:13:07 2010 +0200
@@ -2,6 +2,7 @@
 from Feed import Feed
 from FeedEntry import FeedEntry
 from Preference import Preference
+from sqlalchemy import Boolean
 from sqlalchemy import Column
 from sqlalchemy import DateTime
 from sqlalchemy import ForeignKey
@@ -31,7 +32,10 @@
         Column("title", String(255), nullable=False),
         Column("rss_url", String(255), nullable=False),
         Column("update_interval", Integer, nullable=False),
-        Column("next_update", DateTime, nullable=False)
+        Column("next_update", DateTime, nullable=False),
+        # when displaying an entry of this feed, do not display the summary but rather load 
+        # the link directly
+        Column("auto_load_entry_link", Boolean, nullable=False)
     )
     
     feedEntryTable = Table("feed_entry", metadata,