diff --git a/qutebrowser/models/completionfilter.py b/qutebrowser/models/completionfilter.py index 44ab2098f..1a5bbd36a 100644 --- a/qutebrowser/models/completionfilter.py +++ b/qutebrowser/models/completionfilter.py @@ -35,7 +35,7 @@ class CompletionFilterModel(QSortFilterProxyModel): Attributes: _pattern: The pattern to filter with. - _srcmodel: The current source model. + srcmodel: The current source model. Kept as attribute because calling `sourceModel` takes quite a long time for some reason. """ @@ -43,7 +43,7 @@ class CompletionFilterModel(QSortFilterProxyModel): def __init__(self, source, parent=None): super().__init__(parent) super().setSourceModel(source) - self._srcmodel = source + self.srcmodel = source self._pattern = '' def set_pattern(self, val): @@ -61,7 +61,7 @@ class CompletionFilterModel(QSortFilterProxyModel): self.invalidateFilter() sortcol = 0 try: - self._srcmodel.sort(sortcol) + self.srcmodel.sort(sortcol) except NotImplementedError: self.sort(sortcol) self.invalidate() @@ -111,14 +111,14 @@ class CompletionFilterModel(QSortFilterProxyModel): qtutils.ensure_valid(index) index = self.mapToSource(index) qtutils.ensure_valid(index) - self._srcmodel.mark_item(index, text) + self.srcmodel.mark_item(index, text) def setSourceModel(self, model): """Override QSortFilterProxyModel's setSourceModel to clear pattern.""" log.completion.debug("Setting source model: {}".format(model)) self.set_pattern('') super().setSourceModel(model) - self._srcmodel = model + self.srcmodel = model def filterAcceptsRow(self, row, parent): """Custom filter implementation. @@ -135,9 +135,9 @@ class CompletionFilterModel(QSortFilterProxyModel): """ if parent == QModelIndex(): return True - idx = self._srcmodel.index(row, 0, parent) + idx = self.srcmodel.index(row, 0, parent) qtutils.ensure_valid(idx) - data = self._srcmodel.data(idx) + data = self.srcmodel.data(idx) # TODO more sophisticated filtering if not self._pattern: return True @@ -159,14 +159,14 @@ class CompletionFilterModel(QSortFilterProxyModel): qtutils.ensure_valid(lindex) qtutils.ensure_valid(rindex) - left_sort = self._srcmodel.data(lindex, role=completion.Role.sort) - right_sort = self._srcmodel.data(rindex, role=completion.Role.sort) + left_sort = self.srcmodel.data(lindex, role=completion.Role.sort) + right_sort = self.srcmodel.data(rindex, role=completion.Role.sort) if left_sort is not None and right_sort is not None: return left_sort < right_sort - left = self._srcmodel.data(lindex) - right = self._srcmodel.data(rindex) + left = self.srcmodel.data(lindex) + right = self.srcmodel.data(rindex) leftstart = left.startswith(self._pattern) rightstart = right.startswith(self._pattern) diff --git a/qutebrowser/utils/completer.py b/qutebrowser/utils/completer.py index 4c2c4fe93..09760361f 100644 --- a/qutebrowser/utils/completer.py +++ b/qutebrowser/utils/completer.py @@ -233,7 +233,7 @@ class Completer(QObject): log.completion.debug( "New completion for {}: {}, with pattern '{}'".format( - parts, model._srcmodel.__class__.__name__, pattern)) + parts, model.srcmodel.__class__.__name__, pattern)) if self._model().count() == 0: completion.hide()