Annotations browser: When showing a book in the calibre library that is not currently visible, display an error. Fixes #1900066 [Annotation browser's "show in Calibre" silently fails if book isn't in current library view](https://bugs.launchpad.net/calibre/+bug/1900066)

This commit is contained in:
Kovid Goyal 2020-10-16 08:12:27 +05:30
parent ebf3937628
commit cb31fc219d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
from PyQt5.Qt import Qt
from calibre.gui2 import error_dialog
from calibre.gui2.actions import InterfaceAction
@ -43,7 +44,13 @@ class BrowseAnnotationsAction(InterfaceAction):
self._browser.selection_changed()
def open_book(self, book_id, fmt):
self.gui.library_view.select_rows({book_id})
if not self.gui.library_view.select_rows({book_id}):
db = self.gui.current_db.new_api
title = db.field_for('title', book_id)
return error_dialog(self._browser or self.gui, _('Not visible'), _(
'The book "{}" is not currently visible in the calibre library.'
' If you have a search or a Virtual librry applied, first clear'
' it.').format(title), show=True)
def open_annotation(self, book_id, fmt, cfi):
self.gui.iactions['View'].view_format_by_id(book_id, fmt, open_at=cfi)

View File

@ -1236,6 +1236,7 @@ class BooksView(QTableView): # {{{
sel.merge(QItemSelection(m.index(min(group), 0),
m.index(max(group), max_col)), sm.Select)
sm.select(sel, sm.ClearAndSelect)
return rows
def get_selected_ids(self, as_set=False):
ans = []