Mercurial > hg > Feedworm
comparison FeedEntryItemDelegate.py @ 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 | 0f9b3e57cff0 |
children | bb3c851b18b1 |
comparison
equal
deleted
inserted
replaced
149:92194216f70d | 150:babe14449162 |
---|---|
3 from PyQt4.QtGui import QFont | 3 from PyQt4.QtGui import QFont |
4 | 4 |
5 class FeedEntryItemDelegate(QtGui.QStyledItemDelegate): | 5 class FeedEntryItemDelegate(QtGui.QStyledItemDelegate): |
6 def __init__(self): | 6 def __init__(self): |
7 QtGui.QStyledItemDelegate.__init__(self, None) | 7 QtGui.QStyledItemDelegate.__init__(self, None) |
8 | 8 |
9 def paint(self, painter, style, index): | 9 def paint(self, painter, style, index): |
10 feedEntryTableModel = index.model() | |
10 row = index.row() | 11 row = index.row() |
11 entry = self.entries[row] | 12 # this makes assumptions about the type and the properties of the model but there's no |
13 # way to get to the feedEntry using proper Qt API | |
14 entry = feedEntryTableModel.feedEntries[row] | |
12 if entry.read: | 15 if entry.read: |
13 style.font.setWeight(QFont.Normal) | 16 style.font.setWeight(QFont.Normal) |
14 else: | 17 else: |
15 style.font.setWeight(QFont.Bold) | 18 style.font.setWeight(QFont.Bold) |
16 QtGui.QStyledItemDelegate.paint(self, painter, style, index) | 19 QtGui.QStyledItemDelegate.paint(self, painter, style, index) |