From c1fa9da1cf8888c1a7b20e3b2667cf74bf1a3e63 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 24 Dec 2012 21:26:08 +0530 Subject: [PATCH] Fix multiple 'All column' coloring rules not being applied --- src/calibre/gui2/library/models.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 063149c62e..8cd84bdafc 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -52,10 +52,9 @@ class ColumnColor(object): self.mi = None def __call__(self, id_, key, fmt, db, formatter, color_cache, colors): - if id_ in color_cache: - if key in color_cache[id_]: - self.mi = None - return color_cache[id_][key] + if id_ in color_cache and key in color_cache[id_]: + self.mi = None + return color_cache[id_][key] try: if self.mi is None: self.mi = db.get_metadata(id_, index_is_id=True) @@ -763,9 +762,8 @@ class BooksModel(QAbstractTableModel): # {{{ self.column_color.mi = None if self.color_row_fmt_cache is None: - d = dict(self.db.prefs['column_color_rules']) - self.color_row_fmt_cache = d.get(color_row_key, '') - + self.color_row_fmt_cache = tuple(fmt for key, fmt in + self.db.prefs['column_color_rules'] if key == color_row_key) for k, fmt in self.db.prefs['column_color_rules']: if k == key: @@ -789,10 +787,9 @@ class BooksModel(QAbstractTableModel): # {{{ except: pass - if self.color_row_fmt_cache: - key = color_row_key - ccol = self.column_color(id_, key, self.color_row_fmt_cache, - self.db, self.formatter, self.color_cache, self.colors) + for fmt in self.color_row_fmt_cache: + ccol = self.column_color(id_, color_row_key, fmt, self.db, + self.formatter, self.color_cache, self.colors) if ccol is not None: return ccol