mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix previous/next buttons iterating over removed bookmarks
This commit is contained in:
parent
eb9d921f10
commit
587b113c84
@ -51,11 +51,17 @@ class BookmarksList(QListWidget):
|
|||||||
return QListWidget.keyPressEvent(self, ev)
|
return QListWidget.keyPressEvent(self, ev)
|
||||||
|
|
||||||
def activate_related_bookmark(self, delta=1):
|
def activate_related_bookmark(self, delta=1):
|
||||||
if self.count() > 0:
|
if not self.count():
|
||||||
row = self.currentRow()
|
return
|
||||||
nrow = (row + delta + self.count()) % self.count()
|
items = [self.item(r) for r in range(self.count())]
|
||||||
self.setCurrentRow(nrow)
|
row = self.currentRow()
|
||||||
self.bookmark_activated.emit(self.currentItem())
|
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):
|
def next_bookmark(self):
|
||||||
self.activate_related_bookmark()
|
self.activate_related_bookmark()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user