Change how resorting is done.
This avoids the pattern_changed signal and does the resorting in the model directly (where it belongs) instead.
This commit is contained in:
parent
3a3a63c000
commit
1f59a00808
@ -275,7 +275,6 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
||||
|
||||
"""Subclass of QSortFilterProxyModel with custom sorting/filtering."""
|
||||
|
||||
pattern_changed = pyqtSignal(str)
|
||||
_pattern = None
|
||||
|
||||
def __init__(self, parent=None):
|
||||
@ -291,11 +290,20 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
||||
def pattern(self, val):
|
||||
"""Setter for pattern.
|
||||
|
||||
Invalidates the filter and emits pattern_changed.
|
||||
Invalidates the filter and re-sorts the model.
|
||||
|
||||
If the current completion model overrides sort(), it is used.
|
||||
If not, the default implementation in QCompletionFilterModel is called.
|
||||
"""
|
||||
self._pattern = val
|
||||
self.invalidate()
|
||||
self.pattern_changed.emit(val)
|
||||
sortcol = 0
|
||||
srcmodel = self.sourceModel()
|
||||
if srcmodel is not None:
|
||||
try:
|
||||
srcmodel.sort(sortcol)
|
||||
except NotImplementedError:
|
||||
self.sort(sortcol)
|
||||
|
||||
def filterAcceptsRow(self, row, parent):
|
||||
"""Custom filter implementation.
|
||||
|
@ -74,7 +74,6 @@ class CompletionView(QTreeView):
|
||||
self.model = CompletionFilterModel()
|
||||
self.setModel(self.model)
|
||||
self.model.setSourceModel(self.completion_models['command'])
|
||||
self.model.pattern_changed.connect(self.resort)
|
||||
self.setItemDelegate(CompletionItemDelegate())
|
||||
self.setStyleSheet(config.get_stylesheet(self._stylesheet))
|
||||
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||
@ -114,18 +113,6 @@ class CompletionView(QTreeView):
|
||||
self.model.pattern = ''
|
||||
self.expandAll()
|
||||
|
||||
def resort(self, pattern): # pylint: disable=unused-argument
|
||||
"""Sort the available completions.
|
||||
|
||||
If the current completion model overrides sort(), it is used.
|
||||
If not, the default implementation in QCompletionFilterModel is called.
|
||||
"""
|
||||
sortcol = 0
|
||||
try:
|
||||
self.model.sourceModel().sort(sortcol)
|
||||
except NotImplementedError:
|
||||
self.model.sort(sortcol)
|
||||
|
||||
def resize_to_bar(self, geom):
|
||||
"""Resize the completion area to the statusbar geometry.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user