changeset 150:babe14449162

the entries for the selected feeds had to be set onto the item delegate so had access to the selected feed entry. Keep the list in one place only (the model) and access it from the item delegate.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 27 Aug 2011 06:43:28 +0200
parents 92194216f70d
children bca9341dc67f
files FeedEntryItemDelegate.py MainWindow.py
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/FeedEntryItemDelegate.py	Fri Aug 26 06:14:42 2011 +0200
+++ b/FeedEntryItemDelegate.py	Sat Aug 27 06:43:28 2011 +0200
@@ -5,10 +5,13 @@
 class FeedEntryItemDelegate(QtGui.QStyledItemDelegate):
     def __init__(self):
         QtGui.QStyledItemDelegate.__init__(self, None)
-    
+
     def paint(self, painter, style, index):
+        feedEntryTableModel = index.model()
         row = index.row()
-        entry = self.entries[row]
+        # this makes assumptions about the type and the properties of the model but there's no
+        # way to get to the feedEntry using proper Qt API
+        entry = feedEntryTableModel.feedEntries[row]
         if entry.read:
             style.font.setWeight(QFont.Normal)
         else:
--- a/MainWindow.py	Fri Aug 26 06:14:42 2011 +0200
+++ b/MainWindow.py	Sat Aug 27 06:43:28 2011 +0200
@@ -62,7 +62,6 @@
     def setupFeedTableModel(self):
         model = FeedEntryTableModel(self.feedEntries)
         self.ui.feedEntryList.setModel(model)
-        self.ui.feedEntryList.itemDelegate().entries = self.feedEntries
 
     def setupFeedTableHeaderWidths(self):
         width = self.ui.feedEntryList.width()