mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Show the user a specific message if a condition for an color/icon rule has been made invalid because of column type changes. This is related to http://www.mobileread.com/forums/showthread.php?p=3089981
This commit is contained in:
parent
5f12139615
commit
19a780d385
@ -836,6 +836,10 @@ class RulesModel(QAbstractListModel): # {{{
|
||||
else:
|
||||
continue
|
||||
break
|
||||
if action_name == Rule.INVALID_CONDITION:
|
||||
return (
|
||||
_('<li>The condition using column <b>%(col)s</b> is <b>invalid</b>')
|
||||
% dict(col=c))
|
||||
return (
|
||||
_('<li>If the <b>%(col)s</b> column <b>%(action)s</b> value: <b>%(val)s</b>') % dict(
|
||||
col=c, action=action_name, val=prepare_string_for_xml(v)))
|
||||
|
@ -17,6 +17,8 @@ class Rule(object): # {{{
|
||||
|
||||
SIGNATURE = '# BasicColorRule():'
|
||||
|
||||
INVALID_CONDITION = _('INVALID CONDITION')
|
||||
|
||||
def __init__(self, fm, color=None):
|
||||
self.color = color
|
||||
self.fm = fm
|
||||
@ -28,6 +30,8 @@ class Rule(object): # {{{
|
||||
v = self.validate_condition(col, action, val)
|
||||
if v:
|
||||
raise ValueError(v)
|
||||
if self.apply_condition((col, action, val)) is None:
|
||||
action = self.INVALID_CONDITION
|
||||
self.conditions.append((col, action, val))
|
||||
|
||||
def validate_condition(self, col, action, val):
|
||||
|
Loading…
x
Reference in New Issue
Block a user