comparison MainWindow.py @ 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 228da10cc98b
comparison
equal deleted inserted replaced
60:d063e4814357 61:db35ab7753f0
3 from DisplayModel import DisplayModel 3 from DisplayModel import DisplayModel
4 from Feed import Feed 4 from Feed import Feed
5 from FeedEntry import FeedEntry 5 from FeedEntry import FeedEntry
6 from FeedEntryItemDelegate import FeedEntryItemDelegate 6 from FeedEntryItemDelegate import FeedEntryItemDelegate
7 from FeedSettings import FeedSettings 7 from FeedSettings import FeedSettings
8 from Preferences import Preferences
8 from PreferencesDialog import PreferencesDialog 9 from PreferencesDialog import PreferencesDialog
9 from PyQt4 import QtGui 10 from PyQt4 import QtGui
10 from PyQt4.QtCore import QUrl 11 from PyQt4.QtCore import QUrl
11 from Ui_MainWindow import Ui_MainWindow 12 from Ui_MainWindow import Ui_MainWindow
12 import subprocess 13 import subprocess
15 16
16 class MainWindow(QtGui.QMainWindow): 17 class MainWindow(QtGui.QMainWindow):
17 def __init__(self, session=None): 18 def __init__(self, session=None):
18 QtGui.QWidget.__init__(self, None) 19 QtGui.QWidget.__init__(self, None)
19 self.session = session 20 self.session = session
21 self.preferences = Preferences(session)
20 self.ui = Ui_MainWindow() 22 self.ui = Ui_MainWindow()
21 self.ui.setupUi(self) 23 self.ui.setupUi(self)
22 self.updateFeedList() 24 self.updateFeedList()
23 self.initFeedEntryList() 25 self.initFeedEntryList()
24 26
31 def initFeedEntryList(self): 33 def initFeedEntryList(self):
32 self.ui.feedEntryList.setItemDelegate(FeedEntryItemDelegate()) 34 self.ui.feedEntryList.setItemDelegate(FeedEntryItemDelegate())
33 35
34 def feedSelected(self, index): 36 def feedSelected(self, index):
35 self.selectedFeed = self.allFeeds[index.row()] 37 self.selectedFeed = self.allFeeds[index.row()]
38 self.enableFeedRelatedWidgets()
39 self.setupFeedEntries()
36 40
41 def enableFeedRelatedWidgets(self):
37 self.ui.actionFeedSettings.setEnabled(True) 42 self.ui.actionFeedSettings.setEnabled(True)
38 self.ui.actionMarkFeedRead.setEnabled(True) 43 self.ui.actionMarkFeedRead.setEnabled(True)
44
45 def setupFeedEntries(self):
46 hideReadEntries = self.preferences.hideReadFeedEntries()
47 self.feedEntries = self.selectedFeed.entriesSortedByUpdateDate(hideReadEntries)
48 self.initFeedDisplayModel()
39 49
40 self.sortedEntries = self.selectedFeed.entriesSortedByUpdateDate() 50 def initFeedDisplayModel(self):
41 model = DisplayModel(self, self.sortedEntries, FeedEntry.userPresentableString) 51 model = DisplayModel(self, self.feedEntries, FeedEntry.userPresentableString)
42 self.ui.feedEntryList.setModel(model) 52 self.ui.feedEntryList.setModel(model)
43 self.ui.feedEntryList.itemDelegate().entries = self.sortedEntries 53 self.ui.feedEntryList.itemDelegate().entries = self.feedEntries
44 self.ui.feedEntryList.update() 54 self.ui.feedEntryList.update()
45 55
46 def feedEntrySelected(self, index): 56 def feedEntrySelected(self, index):
47 self.ui.menuArticle.setEnabled(True) 57 self.ui.menuArticle.setEnabled(True)
48 58
49 row = index.row() 59 row = index.row()
50 self.selectedEntry = self.sortedEntries[row] 60 self.selectedEntry = self.feedEntries[row]
51 self.selectedEntry.markRead() 61 self.selectedEntry.markRead()
52 62
53 if self.selectedEntry.feed.auto_load_entry_link: 63 if self.selectedEntry.feed.auto_load_entry_link:
54 self.openLinkFromSelectedEntry() 64 self.openLinkFromSelectedEntry()
55 else: 65 else: