diff --git a/qutebrowser/completion/completiondelegate.py b/qutebrowser/completion/completiondelegate.py index 167cdb6b8..ab7b3ad88 100644 --- a/qutebrowser/completion/completiondelegate.py +++ b/qutebrowser/completion/completiondelegate.py @@ -200,7 +200,7 @@ class CompletionItemDelegate(QStyledItemDelegate): columns_to_filter = index.model().srcmodel.columns_to_filter if index.column() in columns_to_filter and pattern: repl = r'\g<0>' - text = re.sub(re.escape(pattern).replace(r'\ ', r'.*'), + text = re.sub(re.escape(pattern).replace(r'\ ', r'|'), repl, self._opt.text, flags=re.IGNORECASE) self._doc.setHtml(text) else: diff --git a/qutebrowser/completion/models/base.py b/qutebrowser/completion/models/base.py index 5f33eaaa5..88b06a4e0 100644 --- a/qutebrowser/completion/models/base.py +++ b/qutebrowser/completion/models/base.py @@ -128,20 +128,3 @@ class BaseCompletionModel(QStandardItemModel): else: # category return Qt.NoItemFlags - - def sort(self, column, order=Qt.AscendingOrder): - """Sort the data in column according to order. - - Override QAbstractItemModel::sort. - """ - raise NotImplementedError - - def custom_filter(self, pattern, row, parent): - """Custom filter. - - Args: - pattern: The current filter pattern. - row: The row to accept or reject in the filter. - parent: The parent item QModelIndex. - """ - raise NotImplementedError diff --git a/qutebrowser/completion/models/sortfilter.py b/qutebrowser/completion/models/sortfilter.py index ab0a60242..ffa44b82e 100644 --- a/qutebrowser/completion/models/sortfilter.py +++ b/qutebrowser/completion/models/sortfilter.py @@ -63,9 +63,6 @@ class CompletionFilterModel(QSortFilterProxyModel): 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. - Args: val: The value to set. """ @@ -74,13 +71,9 @@ class CompletionFilterModel(QSortFilterProxyModel): val = re.escape(val) val = val.replace(r'\ ', r'.*') self.pattern_re = re.compile(val, re.IGNORECASE) - self.invalidateFilter() - sortcol = 0 - try: - self.srcmodel.sort(sortcol) - except NotImplementedError: - self.sort(sortcol) self.invalidate() + sortcol = 0 + self.sort(sortcol) def count(self): """Get the count of non-toplevel items currently visible. @@ -140,20 +133,17 @@ class CompletionFilterModel(QSortFilterProxyModel): if parent == QModelIndex() or not self.pattern: return True - try: - return self.srcmodel.custom_filter(self.pattern, row, parent) - except NotImplementedError: - for col in self.srcmodel.columns_to_filter: - idx = self.srcmodel.index(row, col, parent) - if not idx.isValid(): - # No entries in parent model - continue - data = self.srcmodel.data(idx) - if not data: - continue - elif self.pattern_re.search(data): - return True - return False + for col in self.srcmodel.columns_to_filter: + idx = self.srcmodel.index(row, col, parent) + if not idx.isValid(): + # No entries in parent model + continue + data = self.srcmodel.data(idx) + if not data: + continue + elif self.pattern_re.search(data): + return True + return False def intelligentLessThan(self, lindex, rindex): """Custom sorting implementation.