Mercurial > hg > Feedworm
annotate FeedEntryItemDelegate.py @ 163:e284a37df1d9
re-enable finding a FeedEntry by its link
author | dirk |
---|---|
date | Mon, 29 Aug 2011 03:17:09 +0200 |
parents | babe14449162 |
children | bb3c851b18b1 |
rev | line source |
---|---|
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
1 |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
2 from PyQt4 import QtGui |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
3 from PyQt4.QtGui import QFont |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
4 |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
5 class FeedEntryItemDelegate(QtGui.QStyledItemDelegate): |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
6 def __init__(self): |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
7 QtGui.QStyledItemDelegate.__init__(self, None) |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
55
diff
changeset
|
8 |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
9 def paint(self, painter, style, index): |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
55
diff
changeset
|
10 feedEntryTableModel = index.model() |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
11 row = index.row() |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
55
diff
changeset
|
12 # this makes assumptions about the type and the properties of the model but there's no |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
55
diff
changeset
|
13 # way to get to the feedEntry using proper Qt API |
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.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
55
diff
changeset
|
14 entry = feedEntryTableModel.feedEntries[row] |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
15 if entry.read: |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
16 style.font.setWeight(QFont.Normal) |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
17 else: |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
18 style.font.setWeight(QFont.Bold) |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
19 QtGui.QStyledItemDelegate.paint(self, painter, style, index) |