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:
Charles Haley 2011-06-04 12:09:19 +01:00
parent fc2e4a3767
commit da9aef6c58
2 changed files with 17 additions and 4 deletions

View File

@ -159,6 +159,9 @@ class ConditionEditor(QWidget): # {{{
self.action_box.clear() self.action_box.clear()
self.action_box.addItem('', '') self.action_box.addItem('', '')
col = self.current_col col = self.current_col
if not col:
self.init_value_box()
return
m = self.fm[col] m = self.fm[col]
dt = m['datatype'] dt = m['datatype']
if dt in self.action_map: if dt in self.action_map:
@ -184,11 +187,11 @@ class ConditionEditor(QWidget): # {{{
self.value_box.setInputMask('') self.value_box.setInputMask('')
self.value_box.setValidator(None) self.value_box.setValidator(None)
col = self.current_col col = self.current_col
m = self.fm[col]
dt = m['datatype']
action = self.current_action action = self.current_action
if not col or not action: if not col or not action:
return return
m = self.fm[col]
dt = m['datatype']
tt = '' tt = ''
if col == 'identifiers': if col == 'identifiers':
tt = _('Enter either an identifier type or an ' tt = _('Enter either an identifier type or an '

View File

@ -79,9 +79,12 @@ class Rule(object): # {{{
if dt == 'bool': if dt == 'bool':
return self.bool_condition(col, action, val) 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) return self.number_condition(col, action, val)
if dt == 'rating':
return self.rating_condition(col, action, val)
if dt == 'datetime': if dt == 'datetime':
return self.date_condition(col, action, val) return self.date_condition(col, action, val)
@ -114,9 +117,16 @@ class Rule(object): # {{{
'lt': ('1', '', ''), 'lt': ('1', '', ''),
'gt': ('', '', '1') 'gt': ('', '', '1')
}[action] }[action]
lt, eq, gt = '', '1', ''
return "cmp(raw_field('%s'), %s, '%s', '%s', '%s')" % (col, val, lt, eq, gt) 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): def date_condition(self, col, action, val):
lt, eq, gt = { lt, eq, gt = {
'eq': ('', '1', ''), 'eq': ('', '1', ''),