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