Allow setting current with ids as well

This commit is contained in:
Kovid Goyal 2022-03-23 08:18:13 +05:30
parent 3155a36b4b
commit 29500738eb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1157,7 +1157,9 @@ class BooksView(QTableView): # {{{
if self.pin_view.isVisible(): if self.pin_view.isVisible():
self.pin_view.horizontalScrollBar().setValue(pv_hpos) self.pin_view.horizontalScrollBar().setValue(pv_hpos)
def set_current_row(self, row=0, select=True, for_sync=False): def set_current_row(self, row=0, select=True, for_sync=False, book_id=None):
if book_id is not None:
row = self.model().db.data.id_to_index(book_id)
if row > -1 and row < self.model().rowCount(QModelIndex()): if row > -1 and row < self.model().rowCount(QModelIndex()):
h = self.horizontalHeader() h = self.horizontalHeader()
logical_indices = list(range(h.count())) logical_indices = list(range(h.count()))