annotate FeedEntryItemDelegate.py @ 230:9faa1f84e8c9

display the number of feeds and articles above the table
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 07 Aug 2014 04:46:57 +0200
parents 94a902de5266
children 3ce39af93e77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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):
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 218
diff changeset
9 entry = index.internalPointer()
55
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10 if entry.read:
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 style.font.setWeight(QFont.Normal)
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 else:
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 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
14 super(FeedEntryItemDelegate, self).paint(painter, style, index)