mirror of
https://github.com/ankitects/anki.git
synced 2025-12-12 22:36:55 -05:00
avoid adjusting position if selected row is visible
https://anki.tenderapp.com/discussions/beta-testing/1868-anki-2124-beta#comment_48227037
This commit is contained in:
parent
2f1523f82a
commit
0c5f22f4ae
1 changed files with 9 additions and 4 deletions
|
|
@ -255,12 +255,17 @@ class DataModel(QAbstractTableModel):
|
||||||
idx = focusedIdx or firstIdx
|
idx = focusedIdx or firstIdx
|
||||||
tv = self.browser.form.tableView
|
tv = self.browser.form.tableView
|
||||||
if idx:
|
if idx:
|
||||||
tv.selectRow(idx.row())
|
row = idx.row()
|
||||||
|
pos = tv.rowViewportPosition(row)
|
||||||
|
visible = pos >= 0 and pos < tv.viewport().height()
|
||||||
|
tv.selectRow(row)
|
||||||
|
|
||||||
# we save and then restore the horizontal scroll position because
|
# we save and then restore the horizontal scroll position because
|
||||||
# scrollTo() also scrolls horizontally which is confusing
|
# scrollTo() also scrolls horizontally which is confusing
|
||||||
h = tv.horizontalScrollBar().value()
|
if not visible:
|
||||||
tv.scrollTo(idx, tv.PositionAtCenter)
|
h = tv.horizontalScrollBar().value()
|
||||||
tv.horizontalScrollBar().setValue(h)
|
tv.scrollTo(idx, tv.PositionAtCenter)
|
||||||
|
tv.horizontalScrollBar().setValue(h)
|
||||||
if count < 500:
|
if count < 500:
|
||||||
# discard large selections; they're too slow
|
# discard large selections; they're too slow
|
||||||
sm.select(
|
sm.select(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue