Mercurial > hg > Feedworm
changeset 33:f371d02fa09d
mark unread feed entries bold. Add a menu item to toggle between read/unread
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Fri, 30 Apr 2010 06:22:33 +0200 |
parents | 500ba01e7f7a |
children | 5813e3c10f14 |
files | .hgignore FeedEntry.py MainWindow.py TODO.txt Ui_MainWindow.ui |
diffstat | 5 files changed, 64 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Fri Apr 30 06:02:06 2010 +0200 +++ b/.hgignore Fri Apr 30 06:22:33 2010 +0200 @@ -3,3 +3,6 @@ Ui_*.py syntax: regexp + +syntax: regexp +^feedworm\.sqlite$ \ No newline at end of file
--- a/FeedEntry.py Fri Apr 30 06:02:06 2010 +0200 +++ b/FeedEntry.py Fri Apr 30 06:22:33 2010 +0200 @@ -18,4 +18,10 @@ return "<FeedEntry (%d) %s>" % (self.pk, self.title) def userPresentableString(self): - return self.title \ No newline at end of file + return self.title + + def toggleRead(self): + if self.read: + self.read = 0 + else: + self.read = 1
--- a/MainWindow.py Fri Apr 30 06:02:06 2010 +0200 +++ b/MainWindow.py Fri Apr 30 06:22:33 2010 +0200 @@ -25,22 +25,26 @@ self.ui.feedList.update() def initFeedEntryList(self): - pass -# self.ui.feedEntryList.setItemDelegate() - # self.ui.feedList.setItemDelegate(CustomItemDelegate(self)) + self.ui.feedEntryList.setItemDelegate(FeedEntryItemDelegate()) def feedSelected(self, index): self.selectedFeed = self.allFeeds[index.row()] - sortedEntries = self.selectedFeed.entriesSortedByUpdateDate() - model = DisplayModel(self, sortedEntries, FeedEntry.userPresentableString) + self.sortedEntries = self.selectedFeed.entriesSortedByUpdateDate() + model = DisplayModel(self, self.sortedEntries, FeedEntry.userPresentableString) self.ui.feedEntryList.setModel(model) + self.ui.feedEntryList.itemDelegate().entries = self.sortedEntries self.ui.feedEntryList.update() def feedEntrySelected(self, index): row = index.row() - entry = self.selectedFeed.entries[row] - baseUrl = QUrl(entry.link) # TODO this is the wrong base url, figure out the correct one - self.ui.webView.setHtml(entry.summary, baseUrl) + self.selectedEntry = self.sortedEntries[row] + baseUrl = QUrl(self.selectedEntry.link) # TODO this is the wrong base url, figure out the correct one + self.ui.webView.setHtml(self.selectedEntry.summary, baseUrl) + + def toggleReadOnSelectedEntry(self): + self.selectedEntry.toggleRead() + self.session.commit() + self.ui.feedList.update() def addFeed(self): addFeed = AddFeed(self.session) @@ -51,11 +55,15 @@ # TODO get status from feedUpdater and display in status area of the main window self.updateFeedList() -class CustomItemDelegate(QtGui.QStyledItemDelegate): - def __init__(self, parent): - print("init") - QtGui.QStyledItemDelegate.__init__(self, parent) +class FeedEntryItemDelegate(QtGui.QStyledItemDelegate): + def __init__(self): + QtGui.QStyledItemDelegate.__init__(self, None) def paint(self, painter, style, index): - style.font.setWeight(QFont.Bold) + row = index.row() + entry = self.entries[row] + if entry.read: + style.font.setWeight(QFont.Normal) + else: + style.font.setWeight(QFont.Bold) QtGui.QStyledItemDelegate.paint(self, painter, style, index)
--- a/TODO.txt Fri Apr 30 06:02:06 2010 +0200 +++ b/TODO.txt Fri Apr 30 06:22:33 2010 +0200 @@ -2,3 +2,4 @@ FeedEntry Liste als Tabelle darstellen, zusaetzliche Spalte z.B. das updated Datum +Beim Aktualisieren aller Feeds die Anzahl der neuen Artikel angeben
--- a/Ui_MainWindow.ui Fri Apr 30 06:02:06 2010 +0200 +++ b/Ui_MainWindow.ui Fri Apr 30 06:22:33 2010 +0200 @@ -66,7 +66,14 @@ <addaction name="separator"/> <addaction name="actionQuit"/> </widget> + <widget class="QMenu" name="menuArticle"> + <property name="title"> + <string>Article</string> + </property> + <addaction name="actionMarkSelectedRead"/> + </widget> <addaction name="menuFeed"/> + <addaction name="menuArticle"/> </widget> <widget class="QStatusBar" name="statusbar"/> <action name="actionQuit"> @@ -90,6 +97,14 @@ <string>xxx</string> </property> </action> + <action name="actionMarkSelectedRead"> + <property name="text"> + <string>Mark selected read</string> + </property> + <property name="shortcut"> + <string>M</string> + </property> + </action> </widget> <customwidgets> <customwidget> @@ -164,10 +179,27 @@ </hint> </hints> </connection> + <connection> + <sender>actionMarkSelectedRead</sender> + <signal>activated()</signal> + <receiver>MainWindow</receiver> + <slot>toggleReadOnSelectedEntry()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>495</x> + <y>374</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>addFeed()</slot> <slot>feedSelected(QModelIndex)</slot> <slot>feedEntrySelected(QModelIndex)</slot> + <slot>toggleReadOnSelectedEntry()</slot> </slots> </ui>