mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Column coloring/icons: Treat entries with no date as infinite days ago. ALso fix a regression that broke using the template editor
This commit is contained in:
commit
041a56204c
@ -197,8 +197,7 @@ class TemplateHighlighter(QSyntaxHighlighter):
|
||||
|
||||
class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||
|
||||
def __init__(self, parent, text, mi=None, fm=None, color_field=None,
|
||||
rule_kind='color'):
|
||||
def __init__(self, parent, text, mi=None, fm=None, color_field=None):
|
||||
QDialog.__init__(self, parent)
|
||||
Ui_TemplateDialog.__init__(self)
|
||||
self.setupUi(self)
|
||||
@ -265,8 +264,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||
self.function.setCurrentIndex(0)
|
||||
self.function.currentIndexChanged[str].connect(self.function_changed)
|
||||
self.textbox_changed()
|
||||
self.rule = (rule_kind, None, '')
|
||||
self.rule_kind = rule_kind
|
||||
self.rule = (None, '')
|
||||
|
||||
tt = _('Template language tutorial')
|
||||
self.template_tutorial.setText(
|
||||
@ -325,5 +323,5 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
||||
_('The template box cannot be empty'), show=True)
|
||||
return
|
||||
|
||||
self.rule = (self.rule_kind, unicode(self.colored_field.currentText()), txt)
|
||||
self.rule = (unicode(self.colored_field.currentText()), txt)
|
||||
QDialog.accept(self)
|
||||
|
@ -742,7 +742,7 @@ class EditRules(QWidget): # {{{
|
||||
|
||||
def add_advanced(self):
|
||||
td = TemplateDialog(self, '', mi=self.mi, fm=self.fm, color_field='')
|
||||
self._add_rule(td)
|
||||
self._add_rule(('color', td[0], td[1]))
|
||||
|
||||
def edit_rule(self, index):
|
||||
try:
|
||||
@ -755,6 +755,8 @@ class EditRules(QWidget): # {{{
|
||||
else:
|
||||
d = TemplateDialog(self, rule, mi=self.mi, fm=self.fm, color_field=col)
|
||||
if d.exec_() == d.Accepted:
|
||||
if len(d.rule) == 2: # Convert template dialog rules to a triple
|
||||
d.rule = ('color', d.rule[0], d.rule[1])
|
||||
kind, col, r = d.rule
|
||||
if kind and r is not None and col:
|
||||
self.model.replace_rule(index, kind, col, r)
|
||||
|
@ -134,8 +134,8 @@ class Rule(object): # {{{
|
||||
|
||||
def date_condition(self, col, action, val):
|
||||
if action == 'count_days':
|
||||
return (("cmp(add(%s, 1), days_between(today(), format_date(raw_field('%s'), 'yyyy-MM-dd')), '', '1', '1')")
|
||||
%(val, col))
|
||||
return (("test(field('%s'), cmp(%s, days_between(today(), format_date(raw_field('%s'), 'yyyy-MM-dd')), '', '1', '1'), '')")
|
||||
%(col, str(int(val)+1), col))
|
||||
lt, eq, gt = {
|
||||
'eq': ('', '1', ''),
|
||||
'lt': ('1', '', ''),
|
||||
|
Loading…
x
Reference in New Issue
Block a user