Skip to content

Commit

Permalink
Fix automatic horizontal scrolling
Browse files Browse the repository at this point in the history
Fix annoying bug where the table view scrolls horizontally to seemingly
random locations whenever the list was refreshed (i.e., doing anything
useful).

Also changed the horizontal scroll mode to by-pixel because it's a lot
nicer.
  • Loading branch information
hssm committed Jun 7, 2016
1 parent 025abf3 commit 818fc91
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions advancedbrowser/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def __init__(self, browser):
if 'noteFld' not in self.activeCols:
self.activeCols.append('noteFld')

def restoreSelection(self):
"""Workaround for annoying horizontal re-scrolling bug in qt"""
origH = self.browser.form.tableView.horizontalScrollBar().value()
super(AdvancedDataModel, self).restoreSelection()
self.browser.form.tableView.horizontalScrollBar().setValue(origH)

def columnData(self, index):
# Try to handle built-in Anki column
returned = self._columnData(self, index)
Expand Down Expand Up @@ -261,6 +267,11 @@ def __removeColumns(self):
if type in self.model.activeCols:
self.toggleField(type)

def setupTable(self):
"""Some customizations to the table view"""
super(AdvancedBrowser, self).setupTable()
self.form.tableView.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)

def setupColumns(self):
"""Build a list of candidate columns. We extend the internal
self.columns list with our custom types."""
Expand Down

0 comments on commit 818fc91

Please # to comment.