Add set/unset operators for date searches in the advanced search dialog

This commit is contained in:
Kovid Goyal 2022-01-17 12:16:08 +05:30
parent 575c46310a
commit 7c59955b54
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -31,6 +31,8 @@ def init_dateop(cb):
('>', _('after')),
('<=', _('before or equal to')),
('>=', _('after or equal to')),
('s', _('set')),
('u', _('unset')),
]:
cb.addItem(desc, op)
@ -383,6 +385,8 @@ class SearchDialog(QDialog):
def date_search_string(self):
field = str(self.date_field.itemData(self.date_field.currentIndex()) or '')
op = current_dateop(self.dateop_date)
if op in 'su':
return f'{field}:{"true" if op == "s" else "false"}'
prefix = f'{field}:{op}'
if self.sel_date.isChecked():
ans = f'{prefix}{self.date_year.value()}'