mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix searching by tag,author and format on devices. Fixes #2806 (Search interface does not work properly in the reader pane)
This commit is contained in:
parent
24d76bd8a4
commit
ebcab0d2d3
@ -844,14 +844,15 @@ class OnDeviceSearch(SearchQueryParser):
|
|||||||
def get_matches(self, location, query):
|
def get_matches(self, location, query):
|
||||||
location = location.lower().strip()
|
location = location.lower().strip()
|
||||||
query = query.lower().strip()
|
query = query.lower().strip()
|
||||||
if location not in ('title', 'authors', 'tags', 'all'):
|
if location not in ('title', 'author', 'tag', 'all', 'format'):
|
||||||
return set([])
|
return set([])
|
||||||
matches = set([])
|
matches = set([])
|
||||||
locations = ['title', 'authors', 'tags'] if location == 'all' else [location]
|
locations = ['title', 'author', 'tag', 'format'] if location == 'all' else [location]
|
||||||
q = {
|
q = {
|
||||||
'title' : lambda x : getattr(x, 'title').lower(),
|
'title' : lambda x : getattr(x, 'title').lower(),
|
||||||
'authors': lambda x: getattr(x, 'authors').lower(),
|
'author': lambda x: getattr(x, 'authors').lower(),
|
||||||
'tags':lambda x: ','.join(getattr(x, 'tags')).lower()
|
'tag':lambda x: ','.join(getattr(x, 'tags')).lower(),
|
||||||
|
'format':lambda x: os.path.splitext(x.path)[1].lower()
|
||||||
}
|
}
|
||||||
for i, v in enumerate(locations):
|
for i, v in enumerate(locations):
|
||||||
locations[i] = q[v]
|
locations[i] = q[v]
|
||||||
@ -870,7 +871,7 @@ class DeviceBooksModel(BooksModel):
|
|||||||
self.db = []
|
self.db = []
|
||||||
self.map = []
|
self.map = []
|
||||||
self.sorted_map = []
|
self.sorted_map = []
|
||||||
self.unknown = str(self.trUtf8('Unknown'))
|
self.unknown = _('Unknown')
|
||||||
self.marked_for_deletion = {}
|
self.marked_for_deletion = {}
|
||||||
self.search_engine = OnDeviceSearch(self)
|
self.search_engine = OnDeviceSearch(self)
|
||||||
self.editable = True
|
self.editable = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user