comparison MainWindow.py @ 230:9faa1f84e8c9

display the number of feeds and articles above the table
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 07 Aug 2014 04:46:57 +0200
parents 94a902de5266
children e0e7459556bc
comparison
equal deleted inserted replaced
229:f0b5bdce1189 230:9faa1f84e8c9
25 def updateFeedList(self): 25 def updateFeedList(self):
26 allFeeds = self.backend.getFeeds() 26 allFeeds = self.backend.getFeeds()
27 feedModel = GenericListModel(self, allFeeds, 'title') 27 feedModel = GenericListModel(self, allFeeds, 'title')
28 self.ui.feedList.setModel(feedModel) 28 self.ui.feedList.setModel(feedModel)
29 self.ui.feedList.update() 29 self.ui.feedList.update()
30 30 self.__updateFeedCountLabel(allFeeds)
31
32 def __updateFeedCountLabel(self, feeds):
33 feedCount = len(feeds)
34 text = '%d feed' % feedCount
35 if feedCount > 1:
36 text = text + 's'
37 self.ui.feedCountLabel.setText(text)
38
31 def initFeedEntryTable(self): 39 def initFeedEntryTable(self):
32 # setup the default row height. This must be called before a table model is set 40 # setup the default row height. This must be called before a table model is set
33 self.ui.feedEntryTable.verticalHeader().setDefaultSectionSize(20) 41 self.ui.feedEntryTable.verticalHeader().setDefaultSectionSize(20)
34 42
35 self.ui.feedEntryTable.setItemDelegate(FeedEntryItemDelegate()) 43 self.ui.feedEntryTable.setItemDelegate(FeedEntryItemDelegate())
55 self.ui.actionMarkFeedRead.setEnabled(True) 63 self.ui.actionMarkFeedRead.setEnabled(True)
56 self.ui.actionMarkSelectedEntriesRead.setEnabled(True) 64 self.ui.actionMarkSelectedEntriesRead.setEnabled(True)
57 self.ui.actionDeleteFeed.setEnabled(True) 65 self.ui.actionDeleteFeed.setEnabled(True)
58 66
59 def setupFeedEntries(self): 67 def setupFeedEntries(self):
60 self.setupFeedEntriesTableModel() 68 feedEntries = self.backend.entriesForSelectedFeed()
69 self.setupFeedEntriesTableModel(feedEntries)
61 self.ui.feedEntryTable.update() 70 self.ui.feedEntryTable.update()
62 self.setupFeedEntriesTableHeaderWidths() 71 self.setupFeedEntriesTableHeaderWidths()
63 self.scrollFirstRowInFeedEntriesTableToVisible() 72 self.scrollFirstRowInFeedEntriesTableToVisible()
64 73 self.__updateFeedEntryCountLabel(feedEntries)
65 def setupFeedEntriesTableModel(self): 74
66 feedEntries = self.backend.entriesForSelectedFeed() 75 def setupFeedEntriesTableModel(self, feedEntries):
67 model = self.ui.feedEntryTable.model() 76 model = self.ui.feedEntryTable.model()
68 model.setDisplayedObjects(feedEntries) 77 model.setDisplayedObjects(feedEntries)
69 78
70 def setupFeedEntriesTableHeaderWidths(self): 79 def setupFeedEntriesTableHeaderWidths(self):
71 width = self.ui.feedEntryTable.width() 80 width = self.ui.feedEntryTable.width()
75 def scrollFirstRowInFeedEntriesTableToVisible(self): 84 def scrollFirstRowInFeedEntriesTableToVisible(self):
76 model = self.ui.feedEntryTable.model() 85 model = self.ui.feedEntryTable.model()
77 visibleIndex = model.createIndex(0, 0) 86 visibleIndex = model.createIndex(0, 0)
78 self.ui.feedEntryTable.scrollTo(visibleIndex) 87 self.ui.feedEntryTable.scrollTo(visibleIndex)
79 88
89 def __updateFeedEntryCountLabel(self, feedEntries):
90 count = len(feedEntries)
91 text = '%d Article' % count
92 if count > 1:
93 text = text + 's'
94 self.ui.feedEntryCountLabel.setText(text)
95
80 def feedEntrySelected(self, index): 96 def feedEntrySelected(self, index):
81 self.ui.webView.setZoomFactor(1.0) 97 self.ui.webView.setZoomFactor(1.0)
82 self.ui.menuArticle.setEnabled(True) 98 self.ui.menuArticle.setEnabled(True)
83 self.ui.actionOpenLink.setEnabled(True) 99 self.ui.actionOpenLink.setEnabled(True)
84 100