Mercurial > hg > Feedworm
changeset 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 | f0b5bdce1189 |
children | 16fa9f090c36 |
files | MainWindow.py Ui_MainWindow.ui |
diffstat | 2 files changed, 88 insertions(+), 24 deletions(-) [+] |
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)
--- a/Ui_MainWindow.ui Wed Jul 02 18:20:56 2014 +0200 +++ b/Ui_MainWindow.ui Thu Aug 07 04:46:57 2014 +0200 @@ -24,31 +24,79 @@ <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <widget class="QListView" name="feedList"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="resizeMode"> - <enum>QListView::Fixed</enum> - </property> + <widget class="QWidget" name=""> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="feedCountLabel"> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="textInteractionFlags"> + <set>Qt::NoTextInteraction</set> + </property> + </widget> + </item> + <item> + <widget class="QListView" name="feedList"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="resizeMode"> + <enum>QListView::Fixed</enum> + </property> + </widget> + </item> + </layout> </widget> <widget class="QSplitter" name="splitter"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <widget class="QTableView" name="feedEntryTable"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - <property name="showGrid"> - <bool>false</bool> - </property> - <attribute name="verticalHeaderVisible"> - <bool>false</bool> - </attribute> + <widget class="QWidget" name=""> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="feedEntryCountLabel"> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="textInteractionFlags"> + <set>Qt::NoTextInteraction</set> + </property> + </widget> + </item> + <item> + <widget class="QTableView" name="feedEntryTable"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectRows</enum> + </property> + <property name="showGrid"> + <bool>false</bool> + </property> + <attribute name="verticalHeaderVisible"> + <bool>false</bool> + </attribute> + </widget> + </item> + </layout> </widget> <widget class="QWebView" name="webView" native="true"> <property name="url" stdset="0">