mirror of
https://github.com/ankitects/anki.git
synced 2026-01-14 06:23:57 -05:00
Fix issues with scrolling row into view
1) Check whether full row height is in viewport instead of just the top left corner. 2) Add timer before scrolling to current row so editor will already be set up.
This commit is contained in:
parent
dd434d9093
commit
bd3d210fa2
1 changed files with 5 additions and 3 deletions
|
|
@ -417,7 +417,8 @@ class Table:
|
|||
current = current or rows[0]
|
||||
self._select_rows(rows)
|
||||
self._set_current(current)
|
||||
self._scroll_to_row(current)
|
||||
# editor may pop up and hide the row later on
|
||||
QTimer.singleShot(100, lambda: self._scroll_to_row(current))
|
||||
if self.len_selection() == 0:
|
||||
# no row change will fire
|
||||
self.browser.onRowChanged(QItemSelection(), QItemSelection())
|
||||
|
|
@ -462,8 +463,9 @@ class Table:
|
|||
|
||||
def _scroll_to_row(self, row: int) -> None:
|
||||
"""Scroll vertically to row."""
|
||||
position = self._view.rowViewportPosition(row)
|
||||
visible = 0 <= position < self._view.viewport().height()
|
||||
top_border = self._view.rowViewportPosition(row)
|
||||
bottom_border = top_border + self._view.rowHeight(0)
|
||||
visible = top_border >= 0 and bottom_border < self._view.viewport().height()
|
||||
if not visible:
|
||||
horizontal = self._view.horizontalScrollBar().value()
|
||||
self._view.scrollTo(self._model.index(row, 0), self._view.PositionAtCenter)
|
||||
|
|
|
|||
Loading…
Reference in a new issue