annotate FeedEntryItemDelegate.py @ 259:304917762618 default tip

implementation of feed updates
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:41:22 +0100
parents 3ce39af93e77
children
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 -*-
251
3ce39af93e77 Update to PyQt5
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 228
diff changeset
2 from PyQt5.QtGui import QFont
3ce39af93e77 Update to PyQt5
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 228
diff changeset
3 from PyQt5.QtWidgets import QStyledItemDelegate
55
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
5 class FeedEntryItemDelegate(QStyledItemDelegate):
55
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
6 def __init__(self):
218
699d8f1cebd4 unify imports, especially Qt imports. Use consistent super syntax
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 217
diff changeset
7 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
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):
228
94a902de5266 use GenericTableModel instead of FeedEntryTableModel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 218
diff changeset
10 entry = index.internalPointer()
55
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 if entry.read:
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12 style.font.setWeight(QFont.Normal)
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 else:
0f9b3e57cff0 pull out FeedEntryItemDelegate into its own file
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
14 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
15 super(FeedEntryItemDelegate, self).paint(painter, style, index)