mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-02 15:35:44 +01:00
Get Books: Fix searching for current book/title/author by right clicking the get books icon
This commit is contained in:
commit
a1fd361f81
2 changed files with 11 additions and 13 deletions
|
|
@ -88,9 +88,7 @@ def search_author(self):
|
|||
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 @@ def search_title(self):
|
|||
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
|
||||
|
|
|
|||
|
|
@ -62,16 +62,20 @@ def __init__(self, gui, parent=None, query=''):
|
|||
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 @@ def dialog_closed(self, result):
|
|||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue