mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
af632bed91
@ -151,7 +151,7 @@ class Matches(QAbstractItemModel):
|
|||||||
mod_query = query
|
mod_query = query
|
||||||
# Remove filter identifiers
|
# Remove filter identifiers
|
||||||
# Remove the prefix.
|
# Remove the prefix.
|
||||||
for loc in ('all', 'author', 'author2', 'authors', 'title'):
|
for loc in ('all', 'author', 'author2', 'authors', 'title', 'title2'):
|
||||||
query = re.sub(r'%s:"(?P<a>[^\s"]+)"' % loc, '\g<a>', query)
|
query = re.sub(r'%s:"(?P<a>[^\s"]+)"' % loc, '\g<a>', query)
|
||||||
query = query.replace('%s:' % loc, '')
|
query = query.replace('%s:' % loc, '')
|
||||||
# Remove the prefix and search text.
|
# Remove the prefix and search text.
|
||||||
@ -318,6 +318,7 @@ class SearchFilter(SearchQueryParser):
|
|||||||
'formats',
|
'formats',
|
||||||
'price',
|
'price',
|
||||||
'title',
|
'title',
|
||||||
|
'title2',
|
||||||
'store',
|
'store',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -396,6 +397,7 @@ class SearchFilter(SearchQueryParser):
|
|||||||
for x in ('author', 'download', 'format'):
|
for x in ('author', 'download', 'format'):
|
||||||
q[x+'s'] = q[x]
|
q[x+'s'] = q[x]
|
||||||
q['author2'] = q['author']
|
q['author2'] = q['author']
|
||||||
|
q['title2'] = q['title']
|
||||||
|
|
||||||
# make the price in query the same format as result
|
# make the price in query the same format as result
|
||||||
if location == 'price':
|
if location == 'price':
|
||||||
@ -446,9 +448,9 @@ class SearchFilter(SearchQueryParser):
|
|||||||
|
|
||||||
if locvalue == 'format':
|
if locvalue == 'format':
|
||||||
vals = accessor(sr).split(',')
|
vals = accessor(sr).split(',')
|
||||||
elif locvalue == 'author2':
|
elif locvalue in ('author2', 'title2'):
|
||||||
m = self.IN_MATCH
|
m = self.IN_MATCH
|
||||||
vals = re.sub(r'(^|\s)(and|not|or|a|the|is|of|,)(\s|$)', ' ', query).split(' ')
|
vals = re.sub(r'(^|\s)(and|not|or|a|the|is|of|,)(\s|$)', ' ', accessor(sr)).split(' ')
|
||||||
else:
|
else:
|
||||||
vals = [accessor(sr)]
|
vals = [accessor(sr)]
|
||||||
if self._match(query, vals, m):
|
if self._match(query, vals, m):
|
||||||
|
@ -167,10 +167,9 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
# Don't start a search if there is nothing to search for.
|
# Don't start a search if there is nothing to search for.
|
||||||
query = []
|
query = []
|
||||||
if self.search_title.text():
|
if self.search_title.text():
|
||||||
query.append(u'title:"~%s"' % unicode(self.search_title.text()).replace(" ", ".*"))
|
query.append(u'title2:"~%s"' % unicode(self.search_title.text()).replace('"', ' '))
|
||||||
if self.search_author.text():
|
if self.search_author.text():
|
||||||
query.append(u'author2:"%s"' % unicode(self.search_author.text()))
|
query.append(u'author2:"%s"' % unicode(self.search_author.text()).replace('"', ' '))
|
||||||
#query.append(u'author:"~%s"' % unicode(self.search_author.text()).replace(" ", ".*"))
|
|
||||||
if self.search_edit.text():
|
if self.search_edit.text():
|
||||||
query.append(unicode(self.search_edit.text()))
|
query.append(unicode(self.search_edit.text()))
|
||||||
query = " ".join(query)
|
query = " ".join(query)
|
||||||
@ -212,7 +211,7 @@ class SearchDialog(QDialog, Ui_Dialog):
|
|||||||
query = query.replace('>', '')
|
query = query.replace('>', '')
|
||||||
query = query.replace('<', '')
|
query = query.replace('<', '')
|
||||||
# Remove the prefix.
|
# Remove the prefix.
|
||||||
for loc in ('all', 'author', 'author2', 'authors', 'title'):
|
for loc in ('all', 'author', 'author2', 'authors', 'title', 'title2'):
|
||||||
query = re.sub(r'%s:"(?P<a>[^\s"]+)"' % loc, '\g<a>', query)
|
query = re.sub(r'%s:"(?P<a>[^\s"]+)"' % loc, '\g<a>', query)
|
||||||
query = query.replace('%s:' % loc, '')
|
query = query.replace('%s:' % loc, '')
|
||||||
# Remove the prefix and search text.
|
# Remove the prefix and search text.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user