Full text search: Show an error when trying to select a book that is not currently visible in the calibre library. Fixes #1993044 [Enhancement Request: FTS: Notification when trying to select currently unavailable book](https://bugs.launchpad.net/calibre/+bug/1993044)

This commit is contained in:
Kovid Goyal 2022-10-31 13:12:41 +05:30
parent fc8c0979d1
commit 2819ff2c63
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -43,10 +43,19 @@ def mark_books(*book_ids):
gui.iactions['Mark Books'].add_ids(book_ids)
def jump_to_book(book_id):
def jump_to_book(book_id, parent=None):
gui = get_gui()
if gui is not None:
gui.library_view.select_rows((book_id,))
parent = parent or gui
if not gui.library_view.select_rows((book_id,)):
if gprefs['fts_library_restrict_books']:
error_dialog(parent, _('Not found'), _('This book was not found in the calibre library'), show=True)
else:
error_dialog(parent, _('Not found'), _(
'This book is not currently visible in the calibre library.'
' If you have a search or Virtual library active, try clearing that.'
' Or click the "Restrict searched books" checkbox in this window to'
' only search currently visible books.'), show=True)
class SearchDelegate(ResultsDelegate):
@ -419,7 +428,7 @@ class ResultsView(QTreeView):
results, match = self.m.data_for_index(index)
m = QMenu(self)
if results:
m.addAction(QIcon.ic('lt.png'), _('Jump to this book in the library'), partial(jump_to_book, results.book_id))
m.addAction(QIcon.ic('lt.png'), _('Jump to this book in the library'), partial(jump_to_book, results.book_id, self))
m.addAction(QIcon.ic('marked.png'), _('Mark this book in the library'), partial(mark_books, results.book_id))
m.addSeparator()
m.addAction(QIcon.ic('plus.png'), _('Expand all'), self.expandAll)