Rename cols_to_highlight to _filter and simplify.
This commit is contained in:
parent
c7f88c93b2
commit
3b0125e8cd
@ -195,8 +195,8 @@ class CompletionItemDelegate(QStyledItemDelegate):
|
||||
|
||||
if index.parent().isValid():
|
||||
pattern = index.model().pattern
|
||||
if (index.column() in index.model().srcmodel.columns_to_highlight
|
||||
and pattern):
|
||||
columns_to_filter = index.model().srcmodel.columns_to_filter
|
||||
if index.column() in columns_to_filter and pattern:
|
||||
repl = r'<span class="highlight">\g<0></span>'
|
||||
text = re.sub(re.escape(pattern), repl, self._opt.text,
|
||||
flags=re.IGNORECASE)
|
||||
|
@ -44,7 +44,7 @@ class BaseCompletionModel(QStandardItemModel):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setColumnCount(3)
|
||||
self.columns_to_highlight = []
|
||||
self.columns_to_filter = [0]
|
||||
|
||||
def new_category(self, name, sort=None):
|
||||
"""Add a new category to the model.
|
||||
|
@ -34,7 +34,6 @@ class SettingSectionCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
cat = self.new_category("Sections")
|
||||
for name in configdata.DATA.keys():
|
||||
desc = configdata.SECTION_DESC[name].splitlines()[0].strip()
|
||||
@ -54,7 +53,6 @@ class SettingOptionCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, section, parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
cat = self.new_category(section)
|
||||
sectdata = configdata.DATA[section]
|
||||
self._misc_items = {}
|
||||
@ -108,7 +106,6 @@ class SettingValueCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, section, option, parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
self._section = section
|
||||
self._option = option
|
||||
objreg.get('config').changed.connect(self.update_current_value)
|
||||
|
@ -33,7 +33,6 @@ class CommandCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
assert cmdutils.cmd_dict
|
||||
cmdlist = []
|
||||
for obj in set(cmdutils.cmd_dict.values()):
|
||||
@ -57,7 +56,6 @@ class HelpCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
self._init_commands()
|
||||
self._init_settings()
|
||||
|
||||
@ -100,7 +98,6 @@ class QuickmarkCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, match_field='url', parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
cat = self.new_category("Quickmarks")
|
||||
quickmarks = objreg.get('quickmark-manager').marks.items()
|
||||
if match_field == 'url':
|
||||
@ -122,7 +119,6 @@ class BookmarkCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, match_field='url', parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
cat = self.new_category("Bookmarks")
|
||||
bookmarks = objreg.get('bookmark-manager').marks.items()
|
||||
if match_field == 'url':
|
||||
@ -144,7 +140,6 @@ class SessionCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.columns_to_highlight.append(0)
|
||||
cat = self.new_category("Sessions")
|
||||
try:
|
||||
for name in objreg.get('session-manager').list_sessions():
|
||||
|
@ -39,8 +39,7 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.columns_to_highlight.append(0)
|
||||
self.columns_to_highlight.append(1)
|
||||
self.columns_to_filter = [0, 1]
|
||||
|
||||
self._quickmark_cat = self.new_category("Quickmarks")
|
||||
self._bookmark_cat = self.new_category("Bookmarks")
|
||||
|
Loading…
Reference in New Issue
Block a user