Get Books: Fix searching for current book/title/author by right clicking the get books icon

This commit is contained in:
Kovid Goyal 2013-04-07 20:54:14 +05:30
commit a1fd361f81
2 changed files with 11 additions and 13 deletions

View File

@ -88,9 +88,7 @@ class StoreAction(InterfaceAction):
if row == None:
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
return
query = 'author:"%s"' % self._get_author(row)
self.search(query)
self.search({ 'author': self._get_author(row) })
def _get_title(self, row):
title = ''
@ -107,18 +105,14 @@ class StoreAction(InterfaceAction):
if row == None:
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
return
query = 'title:"%s"' % self._get_title(row)
self.search(query)
self.search({ 'title': self._get_title(row) })
def search_author_title(self):
row = self._get_selected_row()
if row == None:
error_dialog(self.gui, _('Cannot search'), _('No book selected'), show=True)
return
query = 'author:"%s" title:"%s"' % (self._get_author(row), self._get_title(row))
self.search(query)
self.search({ 'author': self._get_author(row), 'title': self._get_title(row) })
def choose(self):
from calibre.gui2.store.config.chooser.chooser_dialog import StoreChooserDialog

View File

@ -62,16 +62,20 @@ class SearchDialog(QDialog, Ui_Dialog):
self.setup_store_checks()
# Set the search query
if isinstance(query, (str, unicode)):
self.search_edit.setText(query)
elif isinstance(query, dict):
if 'author' in query:
self.search_author.setText(query['author'])
if 'title' in query:
self.search_title.setText(query['title'])
# Title
self.search_title.setText(query)
self.search_title.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
self.search_title.setMinimumContentsLength(25)
# Author
self.search_author.setText(query)
self.search_author.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
self.search_author.setMinimumContentsLength(25)
# Keyword
self.search_edit.setText(query)
self.search_edit.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
self.search_edit.setMinimumContentsLength(25)
@ -408,7 +412,7 @@ class SearchDialog(QDialog, Ui_Dialog):
self.save_state()
def exec_(self):
if unicode(self.search_edit.text()).strip():
if unicode(self.search_edit.text()).strip() or unicode(self.search_title.text()).strip() or unicode(self.search_author.text()).strip():
self.do_search()
return QDialog.exec_(self)