Mercurial > hg > Feedworm
changeset 61:db35ab7753f0
add a preference to hide read feed entries
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sat, 24 Jul 2010 03:11:06 +0200 |
parents | d063e4814357 |
children | abc0516a1c0c |
files | .settings/org.eclipse.core.resources.prefs Feed.py MainWindow.py Preferences.py PreferencesDialog.py Ui_Preferences.ui |
diffstat | 6 files changed, 75 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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:
--- 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)
--- 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)
--- 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 @@ <string>Start maximized</string> </property> </widget> + <widget class="QCheckBox" name="hideReadFeedEntries"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>171</width> + <height>22</height> + </rect> + </property> + <property name="text"> + <string>Hide read feed entries</string> + </property> + </widget> </widget> <resources> <include location="Feedworm.qrc"/> @@ -99,8 +112,25 @@ </hint> </hints> </connection> + <connection> + <sender>hideReadFeedEntries</sender> + <signal>stateChanged(int)</signal> + <receiver>Preferences</receiver> + <slot>hideReadFeedEntriesChanged()</slot> + <hints> + <hint type="sourcelabel"> + <x>95</x> + <y>50</y> + </hint> + <hint type="destinationlabel"> + <x>199</x> + <y>149</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>startMaximizedChanged()</slot> + <slot>hideReadFeedEntriesChanged()</slot> </slots> </ui>