always position selection in center after search

https://anki.tenderapp.com/discussions/beta-testing/1888-retaining-position-when-searching
This commit is contained in:
Damien Elmes 2020-04-01 11:01:20 +10:00
parent 6495240914
commit c050833aba

View File

@ -261,13 +261,11 @@ class DataModel(QAbstractTableModel):
tv = self.browser.form.tableView
if idx:
tv.selectRow(idx.row())
# scroll if the selection count has changed
if count != len(self.selectedCards):
# we save and then restore the horizontal scroll position because
# scrollTo() also scrolls horizontally which is confusing
h = tv.horizontalScrollBar().value()
tv.scrollTo(idx, tv.PositionAtCenter)
tv.horizontalScrollBar().setValue(h)
# we save and then restore the horizontal scroll position because
# scrollTo() also scrolls horizontally which is confusing
h = tv.horizontalScrollBar().value()
tv.scrollTo(idx, tv.PositionAtCenter)
tv.horizontalScrollBar().setValue(h)
if count < 500:
# discard large selections; they're too slow
sm.select(