mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More robust coloring code in the CC Enum Delegate
This commit is contained in:
parent
45fcacf2ec
commit
6eec4fa410
@ -289,11 +289,14 @@ class CcEnumDelegate(QStyledItemDelegate): # {{{
|
|||||||
elif option.state & QStyle.State_Selected:
|
elif option.state & QStyle.State_Selected:
|
||||||
painter.fillRect(option.rect, option.palette.highlight())
|
painter.fillRect(option.rect, option.palette.highlight())
|
||||||
m = index.model()
|
m = index.model()
|
||||||
col = m.column_map[index.column()]
|
cc = m.custom_columns[m.column_map[index.column()]]['display']
|
||||||
colors = m.custom_columns[col]['display'].get('enum_colors', [])
|
colors = cc.get('enum_colors', [])
|
||||||
values = m.custom_columns[col]['display']['enum_values']
|
values = cc.get('enum_values', [])
|
||||||
if len(colors) > 0 and txt in values:
|
if len(colors) > 0 and txt in values:
|
||||||
|
try:
|
||||||
painter.fillRect(option.rect, QColor(colors[values.index(txt)]))
|
painter.fillRect(option.rect, QColor(colors[values.index(txt)]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
painter.setClipRect(option.rect)
|
painter.setClipRect(option.rect)
|
||||||
painter.translate(option.rect.topLeft())
|
painter.translate(option.rect.topLeft())
|
||||||
self.document.drawContents(painter)
|
self.document.drawContents(painter)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user