From 8f55839dadd2444ca29fbba3e49a3828e8abee48 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 19 Nov 2012 08:26:05 -0500 Subject: [PATCH] Store: Search, set serch title entry. Remove quotes in title and author searches. --- src/calibre/gui2/store/search/models.py | 8 +++++--- src/calibre/gui2/store/search/search.py | 7 +++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/calibre/gui2/store/search/models.py b/src/calibre/gui2/store/search/models.py index 3d24499e94..0ca3b5a2de 100644 --- a/src/calibre/gui2/store/search/models.py +++ b/src/calibre/gui2/store/search/models.py @@ -151,7 +151,7 @@ class Matches(QAbstractItemModel): mod_query = query # Remove filter identifiers # 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[^\s"]+)"' % loc, '\g', query) query = query.replace('%s:' % loc, '') # Remove the prefix and search text. @@ -318,6 +318,7 @@ class SearchFilter(SearchQueryParser): 'formats', 'price', 'title', + 'title2', 'store', ] @@ -396,6 +397,7 @@ class SearchFilter(SearchQueryParser): for x in ('author', 'download', 'format'): q[x+'s'] = q[x] q['author2'] = q['author'] + q['title2'] = q['title'] # make the price in query the same format as result if location == 'price': @@ -446,9 +448,9 @@ class SearchFilter(SearchQueryParser): if locvalue == 'format': vals = accessor(sr).split(',') - elif locvalue == 'author2': + elif locvalue in ('author2', 'title2'): 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: vals = [accessor(sr)] if self._match(query, vals, m): diff --git a/src/calibre/gui2/store/search/search.py b/src/calibre/gui2/store/search/search.py index 9f401d436c..b4ae0bc943 100644 --- a/src/calibre/gui2/store/search/search.py +++ b/src/calibre/gui2/store/search/search.py @@ -167,10 +167,9 @@ class SearchDialog(QDialog, Ui_Dialog): # Don't start a search if there is nothing to search for. query = [] 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(): - query.append(u'author2:"%s"' % unicode(self.search_author.text())) - #query.append(u'author:"~%s"' % unicode(self.search_author.text()).replace(" ", ".*")) + query.append(u'author2:"%s"' % unicode(self.search_author.text()).replace('"', ' ')) if self.search_edit.text(): query.append(unicode(self.search_edit.text())) query = " ".join(query) @@ -212,7 +211,7 @@ class SearchDialog(QDialog, Ui_Dialog): query = query.replace('>', '') query = query.replace('<', '') # 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[^\s"]+)"' % loc, '\g', query) query = query.replace('%s:' % loc, '') # Remove the prefix and search text.