mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
OndeviceSearch must permit all the locations that the library permits or exceptions get raised. Changed to do that, but also limit the locations that the search will actually use.
This commit is contained in:
parent
76ceb08b58
commit
0b3bc6d5d5
@ -729,18 +729,19 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
|
|
||||||
class OnDeviceSearch(SearchQueryParser): # {{{
|
class OnDeviceSearch(SearchQueryParser): # {{{
|
||||||
|
|
||||||
DEFAULT_LOCATIONS = [
|
USABLE_LOCATIONS = set([
|
||||||
'collections',
|
'collections',
|
||||||
'title',
|
'title',
|
||||||
'author',
|
'author',
|
||||||
'format',
|
'format',
|
||||||
'all',
|
'all',
|
||||||
]
|
])
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, model):
|
def __init__(self, model):
|
||||||
SearchQueryParser.__init__(self)
|
SearchQueryParser.__init__(self)
|
||||||
self.model = model
|
self.model = model
|
||||||
|
self.DEFAULT_LOCATIONS = set(self.DEFAULT_LOCATIONS) | self.USABLE_LOCATIONS
|
||||||
|
|
||||||
def universal_set(self):
|
def universal_set(self):
|
||||||
return set(range(0, len(self.model.db)))
|
return set(range(0, len(self.model.db)))
|
||||||
@ -763,10 +764,10 @@ class OnDeviceSearch(SearchQueryParser): # {{{
|
|||||||
if matchkind != REGEXP_MATCH: ### leave case in regexps because it can be significant e.g. \S \W \D
|
if matchkind != REGEXP_MATCH: ### leave case in regexps because it can be significant e.g. \S \W \D
|
||||||
query = query.lower()
|
query = query.lower()
|
||||||
|
|
||||||
if location not in self.DEFAULT_LOCATIONS:
|
if location not in self.USABLE_LOCATIONS:
|
||||||
return set([])
|
return set([])
|
||||||
matches = set([])
|
matches = set([])
|
||||||
all_locs = set(self.DEFAULT_LOCATIONS) - set(['all'])
|
all_locs = set(self.USABLE_LOCATIONS) - set(['all'])
|
||||||
locations = all_locs if location == 'all' else [location]
|
locations = all_locs if location == 'all' else [location]
|
||||||
q = {
|
q = {
|
||||||
'title' : lambda x : getattr(x, 'title').lower(),
|
'title' : lambda x : getattr(x, 'title').lower(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user