Add ability to search for books in a vl (vl:foo).

Fix not recomputing the search cache when vls are edited.
This commit is contained in:
Charles Haley 2017-08-19 14:37:55 +02:00
parent c90a726acc
commit 622833eb05
2 changed files with 10 additions and 1 deletions

View File

@ -498,6 +498,15 @@ class Parser(SearchQueryParser): # {{{
if location not in self.all_search_locations: if location not in self.all_search_locations:
return matches return matches
if location == 'vl':
vl = self.dbcache._pref('virtual_libraries', {}).get(query) if query else None
if not vl:
raise ParseException(_('No such virtual library: {0}').format(query))
try:
return candidates & self.dbcache.books_in_virtual_library(query)
except (RuntimeError):
raise ParseException(_('Virtual library search is recursive: {0}').format(query))
if (len(location) > 2 and location.startswith('@') and if (len(location) > 2 and location.startswith('@') and
location[1:] in self.grouped_search_terms): location[1:] in self.grouped_search_terms):
location = location[1:] location = location[1:]

View File

@ -380,7 +380,7 @@ class FieldMetadata(object):
'int', 'float', 'bool', 'series', 'composite', 'enumeration']) 'int', 'float', 'bool', 'series', 'composite', 'enumeration'])
# search labels that are not db columns # search labels that are not db columns
search_items = ['all', 'search'] search_items = ['all', 'search', 'vl']
__calibre_serializable__ = True __calibre_serializable__ = True
def __init__(self): def __init__(self):