Allow testing if a number column is set or not set in coloring/icon/emblem rules. Fixes #1888456 [Enhancement Request: "if column is set/not set" for int columns](https://bugs.launchpad.net/calibre/+bug/1888456)

Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
Kovid Goyal 2020-07-22 15:16:49 +05:30
commit b4036b1c44
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 1 deletions

View File

@ -61,7 +61,9 @@ class ConditionEditor(QWidget): # {{{
'int' : (
(_('is equal to'), 'eq'),
(_('is less than'), 'lt'),
(_('is greater than'), 'gt')
(_('is greater than'), 'gt'),
(_('is set'), 'is set'),
(_('is not set'), 'is not set')
),
'datetime' : (
(_('is equal to'), 'eq'),

View File

@ -129,6 +129,10 @@ class Rule(object): # {{{
return "check_yes_no('%s', %s)"%(col, test)
def number_condition(self, col, action, val):
if action == 'is set':
return "test(field('%s'), '1', '')"%col
if action == 'is not set':
return "test(field('%s'), '', '1')"%col
lt, eq, gt = {
'eq': ('', '1', ''),
'lt': ('1', '', ''),