From 0b3bc6d5d5b4d119b228522704af116bdd3f905b Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 21 May 2010 13:32:25 +0100 Subject: [PATCH] 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. --- src/calibre/gui2/library/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 7bf679fa0c..6fbc0660f7 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -729,18 +729,19 @@ class BooksModel(QAbstractTableModel): # {{{ class OnDeviceSearch(SearchQueryParser): # {{{ - DEFAULT_LOCATIONS = [ + USABLE_LOCATIONS = set([ 'collections', 'title', 'author', 'format', 'all', - ] + ]) def __init__(self, model): SearchQueryParser.__init__(self) self.model = model + self.DEFAULT_LOCATIONS = set(self.DEFAULT_LOCATIONS) | self.USABLE_LOCATIONS def universal_set(self): 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 query = query.lower() - if location not in self.DEFAULT_LOCATIONS: + if location not in self.USABLE_LOCATIONS: return 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] q = { 'title' : lambda x : getattr(x, 'title').lower(),