From 555e94f5586b3bcc3a8c6a5a87ec4942e270f9e7 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 12 Nov 2018 12:26:23 +1000 Subject: [PATCH] skip scroll if the number of cards has not changed The scrolling behaviour is useful when cards are deleted, but annoying in other cases such as when changing flags. --- aqt/browser.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aqt/browser.py b/aqt/browser.py index ce802784a..a2e5a225f 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -207,11 +207,13 @@ class DataModel(QAbstractTableModel): tv = self.browser.form.tableView if idx: tv.selectRow(idx.row()) - # 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) + # 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) if count < 500: # discard large selections; they're too slow sm.select(items, QItemSelectionModel.SelectCurrent |