Mercurial > hg > Feedworm
annotate FeedEntryItemDelegate.py @ 224:218c2b376169
ignore eric5 project files
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Thu, 22 May 2014 05:49:14 +0200 |
parents | 699d8f1cebd4 |
children | 94a902de5266 |
rev | line source |
---|---|
217
bb3c851b18b1
add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
150
diff
changeset
|
1 # -*- coding: utf-8 -*- |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
2 from PyQt4.QtGui import QFont, QStyledItemDelegate |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
3 |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
4 class FeedEntryItemDelegate(QStyledItemDelegate): |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
5 def __init__(self): |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
6 super(FeedEntryItemDelegate, self).__init__(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
|
7 |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
8 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
|
9 feedEntryTableModel = index.model() |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
10 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
|
11 # 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
|
12 # 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
|
13 entry = feedEntryTableModel.feedEntries[row] |
55
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
14 if entry.read: |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
15 style.font.setWeight(QFont.Normal) |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
16 else: |
0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
17 style.font.setWeight(QFont.Bold) |
218
699d8f1cebd4
unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
217
diff
changeset
|
18 super(FeedEntryItemDelegate, self).paint(painter, style, index) |