Fix regression that broke sync between the cover browser and the book list

This commit is contained in:
Kovid Goyal 2010-06-08 16:43:24 -06:00
parent 3d551ff1ab
commit e2c2067095
2 changed files with 11 additions and 3 deletions

View File

@ -426,6 +426,14 @@ class BooksView(QTableView): # {{{
if dy != 0: if dy != 0:
self.column_header.update() self.column_header.update()
def scroll_to_row(self, row):
if row > -1:
h = self.horizontalHeader()
for i in range(h.count()):
if not h.isSectionHidden(i):
self.scrollTo(self.model().index(row, i))
break
def close(self): def close(self):
self._model.close() self._model.close()

View File

@ -800,7 +800,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
d.layout().addWidget(self.cover_flow) d.layout().addWidget(self.cover_flow)
self.cover_flow.setVisible(True) self.cover_flow.setVisible(True)
self.cover_flow.setFocus(Qt.OtherFocusReason) self.cover_flow.setFocus(Qt.OtherFocusReason)
self.library_view.scrollTo(self.library_view.currentIndex()) self.library_view.scroll_to_row(self.library_view.currentIndex().row())
d.show() d.show()
d.finished.connect(self.sidebar.external_cover_flow_finished) d.finished.connect(self.sidebar.external_cover_flow_finished)
self.cf_dialog = d self.cf_dialog = d
@ -824,7 +824,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.library_view.currentIndex()) self.library_view.currentIndex())
self.cover_flow.setVisible(True) self.cover_flow.setVisible(True)
self.cover_flow.setFocus(Qt.OtherFocusReason) self.cover_flow.setFocus(Qt.OtherFocusReason)
self.library_view.scrollTo(self.library_view.currentIndex()) self.library_view.scroll_to_row(self.library_view.currentIndex().row())
self.cover_flow_sync_timer.start(500) self.cover_flow_sync_timer.start(500)
else: else:
self.cover_flow_sync_timer.stop() self.cover_flow_sync_timer.stop()
@ -922,7 +922,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
index = m.index(row, 0) index = m.index(row, 0)
if self.library_view.currentIndex().row() != row and index.isValid(): if self.library_view.currentIndex().row() != row and index.isValid():
self.cover_flow_sync_flag = False self.cover_flow_sync_flag = False
self.library_view.scrollTo(index) self.library_view.scroll_to_row(index.row())
sm = self.library_view.selectionModel() sm = self.library_view.selectionModel()
sm.select(index, sm.ClearAndSelect|sm.Rows) sm.select(index, sm.ClearAndSelect|sm.Rows)
self.library_view.setCurrentIndex(index) self.library_view.setCurrentIndex(index)