Mercurial > hg > Feedworm
diff 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 |
line wrap: on
line diff
--- a/MainWindow.py Wed Jul 02 18:20:56 2014 +0200 +++ b/MainWindow.py Thu Aug 07 04:46:57 2014 +0200 @@ -27,7 +27,15 @@ feedModel = GenericListModel(self, allFeeds, 'title') self.ui.feedList.setModel(feedModel) self.ui.feedList.update() - + self.__updateFeedCountLabel(allFeeds) + + def __updateFeedCountLabel(self, feeds): + feedCount = len(feeds) + text = '%d feed' % feedCount + if feedCount > 1: + text = text + 's' + self.ui.feedCountLabel.setText(text) + def initFeedEntryTable(self): # setup the default row height. This must be called before a table model is set self.ui.feedEntryTable.verticalHeader().setDefaultSectionSize(20) @@ -57,13 +65,14 @@ self.ui.actionDeleteFeed.setEnabled(True) def setupFeedEntries(self): - self.setupFeedEntriesTableModel() + feedEntries = self.backend.entriesForSelectedFeed() + self.setupFeedEntriesTableModel(feedEntries) self.ui.feedEntryTable.update() self.setupFeedEntriesTableHeaderWidths() self.scrollFirstRowInFeedEntriesTableToVisible() + self.__updateFeedEntryCountLabel(feedEntries) - def setupFeedEntriesTableModel(self): - feedEntries = self.backend.entriesForSelectedFeed() + def setupFeedEntriesTableModel(self, feedEntries): model = self.ui.feedEntryTable.model() model.setDisplayedObjects(feedEntries) @@ -77,6 +86,13 @@ visibleIndex = model.createIndex(0, 0) self.ui.feedEntryTable.scrollTo(visibleIndex) + def __updateFeedEntryCountLabel(self, feedEntries): + count = len(feedEntries) + text = '%d Article' % count + if count > 1: + text = text + 's' + self.ui.feedEntryCountLabel.setText(text) + def feedEntrySelected(self, index): self.ui.webView.setZoomFactor(1.0) self.ui.menuArticle.setEnabled(True)