From f5838785d996cf892f6029a1de8cfb3994903db6 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Wed, 22 Jul 2020 10:04:02 +0100 Subject: [PATCH] Enhancement #1888456: Request: "if column is set/not set" for int columns --- src/calibre/gui2/preferences/coloring.py | 4 +++- src/calibre/library/coloring.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index 162070d051..ae0c7ff315 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -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'), diff --git a/src/calibre/library/coloring.py b/src/calibre/library/coloring.py index e877db474b..e2a24eb739 100644 --- a/src/calibre/library/coloring.py +++ b/src/calibre/library/coloring.py @@ -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', '', ''),