mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix three bugs in coloring:
1) Ratings were no longer being divided by 2 because of the raw_field change. 2) exceptions when clearing the column in the rule to '' 3) removed code that forced numeric tests to equal.
This commit is contained in:
parent
fc2e4a3767
commit
da9aef6c58
@ -159,6 +159,9 @@ class ConditionEditor(QWidget): # {{{
|
||||
self.action_box.clear()
|
||||
self.action_box.addItem('', '')
|
||||
col = self.current_col
|
||||
if not col:
|
||||
self.init_value_box()
|
||||
return
|
||||
m = self.fm[col]
|
||||
dt = m['datatype']
|
||||
if dt in self.action_map:
|
||||
@ -184,11 +187,11 @@ class ConditionEditor(QWidget): # {{{
|
||||
self.value_box.setInputMask('')
|
||||
self.value_box.setValidator(None)
|
||||
col = self.current_col
|
||||
m = self.fm[col]
|
||||
dt = m['datatype']
|
||||
action = self.current_action
|
||||
if not col or not action:
|
||||
return
|
||||
m = self.fm[col]
|
||||
dt = m['datatype']
|
||||
tt = ''
|
||||
if col == 'identifiers':
|
||||
tt = _('Enter either an identifier type or an '
|
||||
|
@ -79,9 +79,12 @@ class Rule(object): # {{{
|
||||
if dt == 'bool':
|
||||
return self.bool_condition(col, action, val)
|
||||
|
||||
if dt in ('int', 'float', 'rating'):
|
||||
if dt in ('int', 'float'):
|
||||
return self.number_condition(col, action, val)
|
||||
|
||||
if dt == 'rating':
|
||||
return self.rating_condition(col, action, val)
|
||||
|
||||
if dt == 'datetime':
|
||||
return self.date_condition(col, action, val)
|
||||
|
||||
@ -114,9 +117,16 @@ class Rule(object): # {{{
|
||||
'lt': ('1', '', ''),
|
||||
'gt': ('', '', '1')
|
||||
}[action]
|
||||
lt, eq, gt = '', '1', ''
|
||||
return "cmp(raw_field('%s'), %s, '%s', '%s', '%s')" % (col, val, lt, eq, gt)
|
||||
|
||||
def rating_condition(self, col, action, val):
|
||||
lt, eq, gt = {
|
||||
'eq': ('', '1', ''),
|
||||
'lt': ('1', '', ''),
|
||||
'gt': ('', '', '1')
|
||||
}[action]
|
||||
return "cmp(field('%s'), %s, '%s', '%s', '%s')" % (col, val, lt, eq, gt)
|
||||
|
||||
def date_condition(self, col, action, val):
|
||||
lt, eq, gt = {
|
||||
'eq': ('', '1', ''),
|
||||
|
Loading…
x
Reference in New Issue
Block a user