# HG changeset patch # User Dirk Olmes # Date 1281489782 -7200 # Node ID e8c2730eb444ccfebb7bf225001114af3b7c5b9e # Parent 228da10cc98b1717510a38bdb47b8b8f4b2a1d1f control the display of unread feeds/all feeds via Preferences diff -r 228da10cc98b -r e8c2730eb444 FeedList.py --- a/FeedList.py Wed Aug 11 03:10:32 2010 +0200 +++ b/FeedList.py Wed Aug 11 03:23:02 2010 +0200 @@ -1,11 +1,15 @@ from Feed import Feed from FeedEntry import FeedEntry +from Preferences import Preferences from sqlalchemy.orm import joinedload def getFeeds(session): -# return AllFeeds(session).getFeeds() - return UnreadFeeds(session).getFeeds() + preferences = Preferences(session) + if preferences.showOnlyUnreadFeeds(): + return UnreadFeeds(session).getFeeds() + else: + return AllFeeds(session).getFeeds() class AllFeeds(object): '''A simple feed list that returns all feeds stored in the database''' diff -r 228da10cc98b -r e8c2730eb444 Preferences.py --- a/Preferences.py Wed Aug 11 03:10:32 2010 +0200 +++ b/Preferences.py Wed Aug 11 03:23:02 2010 +0200 @@ -4,6 +4,7 @@ START_MAXIMIZED = "START_MAXIMIZED" HIDE_READ_ENTRIES = "HIDE_READ_FEED_ENTRIES" +SHOW_ONLY_UNREAD_FEEDS = "SHOW_ONLY_UNREAD_FEEDS" class Preferences(object): def __init__(self, session): @@ -36,3 +37,11 @@ def setHideReadFeedEntries(self, flag): pref = self._cachedPreference(HIDE_READ_ENTRIES) pref.value = util.bool2str(flag) + + def showOnlyUnreadFeeds(self): + pref = self._cachedPreference(SHOW_ONLY_UNREAD_FEEDS, False) + return util.str2bool(pref.value) + + def setShowOnlyUnreadFeeds(self, flag): + pref = self._cachedPreference(SHOW_ONLY_UNREAD_FEEDS) + pref.value = util.bool2str(flag) diff -r 228da10cc98b -r e8c2730eb444 PreferencesDialog.py --- a/PreferencesDialog.py Wed Aug 11 03:10:32 2010 +0200 +++ b/PreferencesDialog.py Wed Aug 11 03:23:02 2010 +0200 @@ -18,6 +18,9 @@ hideRead = self.preferences.hideReadFeedEntries() self.ui.hideReadFeedEntries.setChecked(hideRead) + + showOnlyUnreadFeeds = self.preferences.showOnlyUnreadFeeds() + self.ui.showOnlyUnreadFeeds.setChecked(showOnlyUnreadFeeds) def startMaximizedChanged(self, change): if change: @@ -31,6 +34,12 @@ else: self.preferences.setHideReadFeedEntries(False) + def showOnlyFeedsWithUnreadEntries(self, change): + if change: + self.preferences.setShowOnlyUnreadFeeds(True) + else: + self.preferences.setShowOnlyUnreadFeeds(False) + def accept(self): self.session.commit() QtGui.QDialog.accept(self) diff -r 228da10cc98b -r e8c2730eb444 Ui_Preferences.ui --- a/Ui_Preferences.ui Wed Aug 11 03:10:32 2010 +0200 +++ b/Ui_Preferences.ui Wed Aug 11 03:23:02 2010 +0200 @@ -7,7 +7,7 @@ 0 0 400 - 300 + 152 @@ -21,7 +21,7 @@ 30 - 240 + 110 341 32 @@ -50,7 +50,7 @@ 10 - 40 + 70 171 22 @@ -59,6 +59,19 @@ Hide read feed entries + + + + 10 + 40 + 301 + 22 + + + + Show only feeds that have unread entries + + @@ -128,9 +141,26 @@ + + showOnlyUnreadFeeds + stateChanged(int) + Preferences + showOnlyFeedsWithUnreadEntries() + + + 160 + 50 + + + 199 + 75 + + + startMaximizedChanged() hideReadFeedEntriesChanged() + showOnlyFeedsWithUnreadEntries()