Get rid of quickmark_by_name completion.

This commit is contained in:
Florian Bruhin 2015-07-29 12:35:43 +02:00
parent c016e8a4cf
commit 69ade32cb9
3 changed files with 7 additions and 20 deletions

View File

@ -97,13 +97,10 @@ def init_quickmark_completions():
"""Initialize quickmark completion models."""
log.completion.debug("Initializing quickmark completion.")
try:
_instances[usertypes.Completion.quickmark_by_url].deleteLater()
_instances[usertypes.Completion.quickmark_by_name].deleteLater()
except KeyError:
pass
model = _init_model(miscmodels.QuickmarkCompletionModel, 'url')
_instances[usertypes.Completion.quickmark_by_url] = model
model = _init_model(miscmodels.QuickmarkCompletionModel, 'name')
model = _init_model(miscmodels.QuickmarkCompletionModel)
_instances[usertypes.Completion.quickmark_by_name] = model
@ -138,7 +135,6 @@ INITIALIZERS = {
usertypes.Completion.section: _init_setting_completions,
usertypes.Completion.option: _init_setting_completions,
usertypes.Completion.value: _init_setting_completions,
usertypes.Completion.quickmark_by_url: init_quickmark_completions,
usertypes.Completion.quickmark_by_name: init_quickmark_completions,
usertypes.Completion.bookmark_by_url: init_bookmark_completions,
usertypes.Completion.sessions: init_session_completion,
@ -176,8 +172,7 @@ def init():
"""Initialize completions. Note this only connects signals."""
quickmark_manager = objreg.get('quickmark-manager')
quickmark_manager.changed.connect(
functools.partial(update, [usertypes.Completion.quickmark_by_url,
usertypes.Completion.quickmark_by_name]))
functools.partial(update, [usertypes.Completion.quickmark_by_name]))
bookmark_manager = objreg.get('bookmark-manager')
bookmark_manager.changed.connect(

View File

@ -96,19 +96,12 @@ class QuickmarkCompletionModel(base.BaseCompletionModel):
# pylint: disable=abstract-method
def __init__(self, match_field='url', parent=None):
def __init__(self, parent=None):
super().__init__(parent)
cat = self.new_category("Quickmarks")
quickmarks = objreg.get('quickmark-manager').marks.items()
if match_field == 'url':
for qm_name, qm_url in quickmarks:
self.new_item(cat, qm_url, qm_name)
elif match_field == 'name':
for qm_name, qm_url in quickmarks:
self.new_item(cat, qm_name, qm_url)
else:
raise ValueError("Invalid value '{}' for match_field!".format(
match_field))
for qm_name, qm_url in quickmarks:
self.new_item(cat, qm_name, qm_url)
class BookmarkCompletionModel(base.BaseCompletionModel):

View File

@ -236,9 +236,8 @@ KeyMode = enum('KeyMode', ['normal', 'hint', 'command', 'yesno', 'prompt',
# Available command completions
Completion = enum('Completion', ['command', 'section', 'option', 'value',
'helptopic', 'quickmark_by_url',
'quickmark_by_name', 'bookmark_by_url',
'url', 'sessions'])
'helptopic', 'quickmark_by_name',
'bookmark_by_url', 'url', 'sessions'])
# Exit statuses for errors. Needs to be an int for sys.exit.