Merge branch 'completion_trivial' of https://github.com/lahwaacz/qutebrowser into lahwaacz-completion_trivial
This commit is contained in:
commit
14eabc7160
@ -200,7 +200,7 @@ class CompletionItemDelegate(QStyledItemDelegate):
|
|||||||
columns_to_filter = index.model().srcmodel.columns_to_filter
|
columns_to_filter = index.model().srcmodel.columns_to_filter
|
||||||
if index.column() in columns_to_filter and pattern:
|
if index.column() in columns_to_filter and pattern:
|
||||||
repl = r'<span class="highlight">\g<0></span>'
|
repl = r'<span class="highlight">\g<0></span>'
|
||||||
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)
|
repl, self._opt.text, flags=re.IGNORECASE)
|
||||||
self._doc.setHtml(text)
|
self._doc.setHtml(text)
|
||||||
else:
|
else:
|
||||||
|
@ -128,20 +128,3 @@ class BaseCompletionModel(QStandardItemModel):
|
|||||||
else:
|
else:
|
||||||
# category
|
# category
|
||||||
return Qt.NoItemFlags
|
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
|
|
||||||
|
@ -63,9 +63,6 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
|||||||
|
|
||||||
Invalidates the filter and re-sorts the model.
|
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:
|
Args:
|
||||||
val: The value to set.
|
val: The value to set.
|
||||||
"""
|
"""
|
||||||
@ -74,13 +71,9 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
|||||||
val = re.escape(val)
|
val = re.escape(val)
|
||||||
val = val.replace(r'\ ', r'.*')
|
val = val.replace(r'\ ', r'.*')
|
||||||
self.pattern_re = re.compile(val, re.IGNORECASE)
|
self.pattern_re = re.compile(val, re.IGNORECASE)
|
||||||
self.invalidateFilter()
|
|
||||||
sortcol = 0
|
|
||||||
try:
|
|
||||||
self.srcmodel.sort(sortcol)
|
|
||||||
except NotImplementedError:
|
|
||||||
self.sort(sortcol)
|
|
||||||
self.invalidate()
|
self.invalidate()
|
||||||
|
sortcol = 0
|
||||||
|
self.sort(sortcol)
|
||||||
|
|
||||||
def count(self):
|
def count(self):
|
||||||
"""Get the count of non-toplevel items currently visible.
|
"""Get the count of non-toplevel items currently visible.
|
||||||
@ -140,20 +133,17 @@ class CompletionFilterModel(QSortFilterProxyModel):
|
|||||||
if parent == QModelIndex() or not self.pattern:
|
if parent == QModelIndex() or not self.pattern:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
for col in self.srcmodel.columns_to_filter:
|
||||||
return self.srcmodel.custom_filter(self.pattern, row, parent)
|
idx = self.srcmodel.index(row, col, parent)
|
||||||
except NotImplementedError:
|
if not idx.isValid():
|
||||||
for col in self.srcmodel.columns_to_filter:
|
# No entries in parent model
|
||||||
idx = self.srcmodel.index(row, col, parent)
|
continue
|
||||||
if not idx.isValid():
|
data = self.srcmodel.data(idx)
|
||||||
# No entries in parent model
|
if not data:
|
||||||
continue
|
continue
|
||||||
data = self.srcmodel.data(idx)
|
elif self.pattern_re.search(data):
|
||||||
if not data:
|
return True
|
||||||
continue
|
return False
|
||||||
elif self.pattern_re.search(data):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def intelligentLessThan(self, lindex, rindex):
|
def intelligentLessThan(self, lindex, rindex):
|
||||||
"""Custom sorting implementation.
|
"""Custom sorting implementation.
|
||||||
|
Loading…
Reference in New Issue
Block a user