From 6eec4fa410eddb376b62d064549460ee754031bb Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 21 May 2011 19:40:27 +0100 Subject: [PATCH] More robust coloring code in the CC Enum Delegate --- src/calibre/gui2/library/delegates.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index ae01081736..1af0482a31 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -289,11 +289,14 @@ class CcEnumDelegate(QStyledItemDelegate): # {{{ elif option.state & QStyle.State_Selected: painter.fillRect(option.rect, option.palette.highlight()) m = index.model() - col = m.column_map[index.column()] - colors = m.custom_columns[col]['display'].get('enum_colors', []) - values = m.custom_columns[col]['display']['enum_values'] + cc = m.custom_columns[m.column_map[index.column()]]['display'] + colors = cc.get('enum_colors', []) + values = cc.get('enum_values', []) if len(colors) > 0 and txt in values: - painter.fillRect(option.rect, QColor(colors[values.index(txt)])) + try: + painter.fillRect(option.rect, QColor(colors[values.index(txt)])) + except: + pass painter.setClipRect(option.rect) painter.translate(option.rect.topLeft()) self.document.drawContents(painter)