Viewer: Fix previous/next buttons iterating over removed bookmarks

This commit is contained in:
Kovid Goyal 2020-11-11 15:03:45 +05:30
parent eb9d921f10
commit 587b113c84
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -51,10 +51,16 @@ class BookmarksList(QListWidget):
return QListWidget.keyPressEvent(self, ev)
def activate_related_bookmark(self, delta=1):
if self.count() > 0:
if not self.count():
return
items = [self.item(r) for r in range(self.count())]
row = self.currentRow()
nrow = (row + delta + self.count()) % self.count()
self.setCurrentRow(nrow)
current_item = items[row]
items = [i for i in items if not i.isHidden()]
count = len(items)
row = items.index(current_item)
nrow = (row + delta + count) % count
self.setCurrentItem(items[nrow])
self.bookmark_activated.emit(self.currentItem())
def next_bookmark(self):