# HG changeset patch # User Dirk Olmes # Date 1279933866 -7200 # Node ID db35ab7753f02e040e53f6e9e2465d78d197794f # Parent d063e48143575af22cf2f96e2f9b7d5415b8fe90 add a preference to hide read feed entries diff -r d063e4814357 -r db35ab7753f0 .settings/org.eclipse.core.resources.prefs --- a/.settings/org.eclipse.core.resources.prefs Fri Jul 23 17:41:05 2010 +0200 +++ b/.settings/org.eclipse.core.resources.prefs Sat Jul 24 03:11:06 2010 +0200 @@ -1,5 +1,6 @@ -#Sun May 16 08:17:30 CEST 2010 +#Sat Jul 24 02:23:01 CEST 2010 eclipse.preferences.version=1 encoding/Ui_AddFeed.py=utf-8 encoding/Ui_FeedSettings.py=utf-8 encoding/Ui_MainWindow.py=utf-8 +encoding/Ui_Preferences.py=utf-8 diff -r d063e4814357 -r db35ab7753f0 Feed.py --- a/Feed.py Fri Jul 23 17:41:05 2010 +0200 +++ b/Feed.py Sat Jul 24 03:11:06 2010 +0200 @@ -21,11 +21,20 @@ def userPresentableString(self): return self.title - def entriesSortedByUpdateDate(self): + def entriesSortedByUpdateDate(self, hideReadEntries=False): sortedEntries = list(self.entries) sortedEntries.sort(FeedEntry.compareByUpdateDate) + if hideReadEntries: + return self._filterReadEntries(sortedEntries) return sortedEntries + def _filterReadEntries(self, entries): + retValue = [] + for entry in entries: + if not entry.read: + retValue.append(entry) + return retValue + def incrementNextUpdateDate(self): delta = timedelta(minutes=self.update_interval) self.next_update = datetime.now() + delta diff -r d063e4814357 -r db35ab7753f0 MainWindow.py --- a/MainWindow.py Fri Jul 23 17:41:05 2010 +0200 +++ b/MainWindow.py Sat Jul 24 03:11:06 2010 +0200 @@ -5,6 +5,7 @@ from FeedEntry import FeedEntry from FeedEntryItemDelegate import FeedEntryItemDelegate from FeedSettings import FeedSettings +from Preferences import Preferences from PreferencesDialog import PreferencesDialog from PyQt4 import QtGui from PyQt4.QtCore import QUrl @@ -17,6 +18,7 @@ def __init__(self, session=None): QtGui.QWidget.__init__(self, None) self.session = session + self.preferences = Preferences(session) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.updateFeedList() @@ -33,21 +35,29 @@ def feedSelected(self, index): self.selectedFeed = self.allFeeds[index.row()] + self.enableFeedRelatedWidgets() + self.setupFeedEntries() + def enableFeedRelatedWidgets(self): self.ui.actionFeedSettings.setEnabled(True) self.ui.actionMarkFeedRead.setEnabled(True) + + def setupFeedEntries(self): + hideReadEntries = self.preferences.hideReadFeedEntries() + self.feedEntries = self.selectedFeed.entriesSortedByUpdateDate(hideReadEntries) + self.initFeedDisplayModel() - self.sortedEntries = self.selectedFeed.entriesSortedByUpdateDate() - model = DisplayModel(self, self.sortedEntries, FeedEntry.userPresentableString) + def initFeedDisplayModel(self): + model = DisplayModel(self, self.feedEntries, FeedEntry.userPresentableString) self.ui.feedEntryList.setModel(model) - self.ui.feedEntryList.itemDelegate().entries = self.sortedEntries + self.ui.feedEntryList.itemDelegate().entries = self.feedEntries self.ui.feedEntryList.update() - + def feedEntrySelected(self, index): self.ui.menuArticle.setEnabled(True) row = index.row() - self.selectedEntry = self.sortedEntries[row] + self.selectedEntry = self.feedEntries[row] self.selectedEntry.markRead() if self.selectedEntry.feed.auto_load_entry_link: diff -r d063e4814357 -r db35ab7753f0 Preferences.py --- a/Preferences.py Fri Jul 23 17:41:05 2010 +0200 +++ b/Preferences.py Sat Jul 24 03:11:06 2010 +0200 @@ -3,6 +3,7 @@ import util START_MAXIMIZED = "START_MAXIMIZED" +HIDE_READ_ENTRIES = "HIDE_READ_FEED_ENTRIES" class Preferences(object): def __init__(self, session): @@ -27,3 +28,11 @@ def setStartMaximized(self, flag): pref = self._cachedPreference(START_MAXIMIZED) pref.value = util.bool2str(flag) + + def hideReadFeedEntries(self): + pref = self._cachedPreference(HIDE_READ_ENTRIES, False) + return util.str2bool(pref.value) + + def setHideReadFeedEntries(self, flag): + pref = self._cachedPreference(HIDE_READ_ENTRIES) + pref.value = util.bool2str(flag) diff -r d063e4814357 -r db35ab7753f0 PreferencesDialog.py --- a/PreferencesDialog.py Fri Jul 23 17:41:05 2010 +0200 +++ b/PreferencesDialog.py Sat Jul 24 03:11:06 2010 +0200 @@ -15,6 +15,9 @@ def fillUi(self): maximized = self.preferences.startMaximized() self.ui.startMaximized.setChecked(maximized) + + hideRead = self.preferences.hideReadFeedEntries() + self.ui.hideReadFeedEntries.setChecked(hideRead) def startMaximizedChanged(self, change): if change: @@ -22,6 +25,12 @@ else: self.preferences.setStartMaximized(False) + def hideReadFeedEntriesChanged(self, change): + if change: + self.preferences.setHideReadFeedEntries(True) + else: + self.preferences.setHideReadFeedEntries(False) + def accept(self): self.session.commit() QtGui.QDialog.accept(self) diff -r d063e4814357 -r db35ab7753f0 Ui_Preferences.ui --- a/Ui_Preferences.ui Fri Jul 23 17:41:05 2010 +0200 +++ b/Ui_Preferences.ui Sat Jul 24 03:11:06 2010 +0200 @@ -46,6 +46,19 @@ Start maximized + + + + 10 + 40 + 171 + 22 + + + + Hide read feed entries + + @@ -99,8 +112,25 @@ + + hideReadFeedEntries + stateChanged(int) + Preferences + hideReadFeedEntriesChanged() + + + 95 + 50 + + + 199 + 149 + + + startMaximizedChanged() + hideReadFeedEntriesChanged()