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.
This commit is contained in:
Damien Elmes 2018-11-12 12:26:23 +10:00
parent 6609dfda7b
commit fea23177e8

View file

@ -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 |