# HG changeset patch # User Dirk Olmes # Date 1272601353 -7200 # Node ID f371d02fa09d8f1e8ccdc4a30c51b59fd6058138 # Parent 500ba01e7f7a6c323cd897c30b93f316ca751041 mark unread feed entries bold. Add a menu item to toggle between read/unread diff -r 500ba01e7f7a -r f371d02fa09d .hgignore --- 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 diff -r 500ba01e7f7a -r f371d02fa09d FeedEntry.py --- 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 "" % (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 diff -r 500ba01e7f7a -r f371d02fa09d MainWindow.py --- 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) diff -r 500ba01e7f7a -r f371d02fa09d TODO.txt --- 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 diff -r 500ba01e7f7a -r f371d02fa09d Ui_MainWindow.ui --- 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 @@ + + + Article + + + + @@ -90,6 +97,14 @@ xxx + + + Mark selected read + + + M + + @@ -164,10 +179,27 @@ + + actionMarkSelectedRead + activated() + MainWindow + toggleReadOnSelectedEntry() + + + -1 + -1 + + + 495 + 374 + + + addFeed() feedSelected(QModelIndex) feedEntrySelected(QModelIndex) + toggleReadOnSelectedEntry()