mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Pass the set of book_ids already matched by previous search terms to the template search.
Reason: the template can use the candidate set to limit work to books already matched.
This commit is contained in:
parent
5d6ab97c43
commit
08c33d01cb
@ -671,7 +671,7 @@ class Parser(SearchQueryParser): # {{{
|
||||
matches = set()
|
||||
error_string = '*@*TEMPLATE_ERROR*@*'
|
||||
template_cache = {}
|
||||
global_vars = {}
|
||||
global_vars = {'_candidates': candidates}
|
||||
for book_id in candidates:
|
||||
mi = self.dbcache.get_proxy_metadata(book_id)
|
||||
val = mi.formatter.safe_format(template, {}, error_string, mi,
|
||||
|
@ -294,7 +294,15 @@ def create_template_tab(self):
|
||||
self.template_program_box = le = TemplateLineEditor(self.tab_widget)
|
||||
le.setObjectName('template_program_box')
|
||||
le.setPlaceholderText(_('The template that generates the value'))
|
||||
le.setToolTip(_('Right click to open a template editor'))
|
||||
le.setToolTip('<p>' +
|
||||
_('Right click to open a template editor. <br>'
|
||||
'Technical note: the set of book ids already matched by '
|
||||
'previous search terms in the search expression is passed '
|
||||
'to the template in the global variables dictionary with the '
|
||||
'key "{0}". You can use the set to limit any work the '
|
||||
'template does to the set of books already matched, possibly '
|
||||
'improving performance.'
|
||||
).format('_candidates') + '</p>')
|
||||
lo = QHBoxLayout()
|
||||
lo.addWidget(le)
|
||||
self.edit_template_button = tb = QToolButton()
|
||||
|
Loading…
x
Reference in New Issue
Block a user