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 tv = self.browser.form.tableView
if idx: if idx:
tv.selectRow(idx.row()) tv.selectRow(idx.row())
# we save and then restore the horizontal scroll position because # scroll if the selection count has changed
# scrollTo() also scrolls horizontally which is confusing if count != len(self.selectedCards):
h = tv.horizontalScrollBar().value() # we save and then restore the horizontal scroll position because
tv.scrollTo(idx, tv.PositionAtCenter) # scrollTo() also scrolls horizontally which is confusing
tv.horizontalScrollBar().setValue(h) h = tv.horizontalScrollBar().value()
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(items, QItemSelectionModel.SelectCurrent | sm.select(items, QItemSelectionModel.SelectCurrent |