mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix caching of icons and translate operations back to plain text.
This commit is contained in:
parent
845b90e865
commit
aa3f6e1211
@ -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,
|
||||
|
@ -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): # {{{
|
||||
<pre>%(rule)s</pre>
|
||||
''')%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 _('''\
|
||||
<p>Set the <b>%(kind)s</b> of <b>%(col)s</b> to <b>%(color)s</b> if the following
|
||||
conditions are met:</p>
|
||||
<ul>%(rule)s</ul>
|
||||
''') % 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user