This commit is contained in:
Kovid Goyal 2022-05-23 06:29:11 +05:30
commit bf43041b19
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 20 additions and 14 deletions

View File

@ -386,7 +386,8 @@ class View:
changed_ids = old_marked_ids | cmids changed_ids = old_marked_ids | cmids
self.cache.clear_search_caches(changed_ids) self.cache.clear_search_caches(changed_ids)
self.cache.clear_caches(book_ids=changed_ids) self.cache.clear_caches(book_ids=changed_ids)
if old_marked_ids != cmids: # Always call the listener because the labels might have changed even
# if the ids haven't.
for funcref in itervalues(self.marked_listeners): for funcref in itervalues(self.marked_listeners):
func = funcref() func = funcref()
if func is not None: if func is not None:
@ -412,11 +413,16 @@ class View:
def refresh_ids(self, ids): def refresh_ids(self, ids):
self.cache.clear_caches(book_ids=ids) self.cache.clear_caches(book_ids=ids)
# The ids list can contain invalid ids (deleted etc). We want to filter
# those out while keeping the valid ones.
def f(id_):
try: try:
return list(map(self.id_to_index, ids)) return self.id_to_index(id_)
except ValueError: except ValueError:
pass
return None return None
res = [i for i in map(f, ids) if i is not None]
return res if res else None
def remove(self, book_id): def remove(self, book_id):
try: try:

View File

@ -965,15 +965,15 @@ class BooksView(QTableView): # {{{
# viewport correctly. See https://bugs.launchpad.net/bugs/1404697 # viewport correctly. See https://bugs.launchpad.net/bugs/1404697
self.row_header.viewport().update() self.row_header.viewport().update()
# refresh the rows because there might be a composite that uses marked_books() # refresh the rows because there might be a composite that uses marked_books()
self.model().refresh_rows(changed) self.model().refresh_rows(sections)
else: else:
# Marked items have either appeared or all been removed # Marked items have either appeared or all been removed
self.model().set_row_decoration(current_marked) self.model().set_row_decoration(current_marked)
self.row_header.headerDataChanged(Qt.Orientation.Vertical, 0, self.row_header.count()-1) self.row_header.headerDataChanged(Qt.Orientation.Vertical, 0, self.row_header.count()-1)
self.row_header.geometriesChanged.emit() self.row_header.geometriesChanged.emit()
self.set_row_header_visibility() self.set_row_header_visibility()
# refresh the rows because there might be a composite that uses marked_books() # refresh rows for the ids because there might be a composite that uses marked_books()
self.model().refresh_rows(current_marked) self.model().refresh_ids(current_marked)
def set_row_header_visibility(self): def set_row_header_visibility(self):
visible = self.model().row_decoration is not None or gprefs['row_numbers_in_book_list'] visible = self.model().row_decoration is not None or gprefs['row_numbers_in_book_list']