Fix multiple 'All column' coloring rules not being applied

This commit is contained in:
Kovid Goyal 2012-12-24 21:26:08 +05:30
parent a34799a284
commit c1fa9da1cf

View File

@ -52,8 +52,7 @@ 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_]:
if id_ in color_cache and key in color_cache[id_]:
self.mi = None
return color_cache[id_][key]
try:
@ -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