diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 2cb14812fe..219c0be9ff 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -786,10 +786,11 @@ class BooksModel(QAbstractTableModel): # {{{ self.column_icon.mi = None for kind, k, fmt in self.db.prefs['column_color_rules']: if k == key and kind == 'icon_only': - ccicon = self.column_icon(id_, key, fmt, kind, self.db, + ccicon = self.column_icon(id_, key, fmt, 'icon_only', self.db, self.formatter, self.icon_cache) if ccicon is not None: return NONE + self.icon_cache[id_][key+'icon_only'] = None return self.column_to_dc_map[col](index.row()) elif role in (Qt.EditRole, Qt.ToolTipRole): return self.column_to_dc_map[col](index.row()) @@ -848,13 +849,16 @@ class BooksModel(QAbstractTableModel): # {{{ need_icon_with_text = False for kind, k, fmt in self.db.prefs['column_color_rules']: if k == key and kind in ('icon', 'icon_only'): - need_icon_with_text = True - ccicon = self.column_icon(id_, key, fmt, kind, self.db, + if kind == 'icon': + need_icon_with_text = True + ccicon = self.column_icon(id_, key, fmt, 'icon', self.db, self.formatter, self.icon_cache) if ccicon is not None: return ccicon if need_icon_with_text: + self.icon_cache[id_][key+'icon'] = self.bool_blank_icon return self.bool_blank_icon + self.icon_cache[id_][key+'icon'] = None elif role == Qt.TextAlignmentRole: cname = self.column_map[index.column()] ans = Qt.AlignVCenter | ALIGNMENT_MAP[self.alignment_map.get(cname, diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index a2441f7d0f..1ee9b15e10 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -28,6 +28,10 @@ from calibre.utils.icu import lower all_columns_string = _('All Columns') +rule_kinds = [(_('color'), 'color'), + (_('icon with text'), 'icon'), + (_('icon with no text'), 'icon_only') ] + class ConditionEditor(QWidget): # {{{ ACTION_MAP = { @@ -270,9 +274,8 @@ class RuleEditor(QDialog): # {{{ l.addWidget(l2, 2, 0) self.kind_box = QComboBox(self) - self.kind_box.addItem(_('color'), 'color') - self.kind_box.addItem(_('icon'), 'icon') - self.kind_box.addItem(_('icon with no text'), 'icon_only') + for tt, t in rule_kinds: + self.kind_box.addItem(tt, t) l.addWidget(self.kind_box, 2, 1) self.l3 = l3 = QLabel(_('of the column:')) @@ -569,11 +572,18 @@ class RulesModel(QAbstractListModel): # {{{
%(rule)s
''')%dict(col=col, rule=prepare_string_for_xml(rule)) conditions = [self.condition_to_html(c) for c in rule.conditions] + + trans_kind = 'not found' + for tt, t in rule_kinds: + if kind == t: + trans_kind = tt + break + return _('''\

Set the %(kind)s of %(col)s to %(color)s if the following conditions are met:

- ''') % dict(kind=kind, col=col, color=rule.color, rule=''.join(conditions)) + ''') % dict(kind=trans_kind, col=col, color=rule.color, rule=''.join(conditions)) def condition_to_html(self, condition): c, a, v = condition