Broken setting completion
This commit is contained in:
parent
1c43da163e
commit
bd4dba1ed3
@ -160,7 +160,10 @@ class CompletionModel(QAbstractItemModel):
|
||||
if not parent.isValid():
|
||||
pitem = self._root
|
||||
else:
|
||||
pitem = self._id_map[parent.internalId()]
|
||||
try:
|
||||
pitem = self._id_map[parent.internalId()]
|
||||
except KeyError:
|
||||
from qutebrowser.utils.debug import set_trace; set_trace()
|
||||
|
||||
return len(pitem.children)
|
||||
|
||||
|
40
qutebrowser/models/settingcompletion.py
Normal file
40
qutebrowser/models/settingcompletion.py
Normal file
@ -0,0 +1,40 @@
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""A CompletionModel filled with settings and their descriptions."""
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from qutebrowser.models.completion import CompletionModel
|
||||
from qutebrowser.config.configdata import configdata
|
||||
|
||||
|
||||
class SettingCompletionModel(CompletionModel):
|
||||
|
||||
"""A CompletionModel filled with settings and their descriptions."""
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
data = OrderedDict()
|
||||
for secname, secdata in configdata().items():
|
||||
newdata = []
|
||||
for name in secdata.values.keys():
|
||||
newdata.append((name, secdata.descriptions[name]))
|
||||
data[secname] = newdata
|
||||
self.init_data(data)
|
@ -35,6 +35,7 @@ import qutebrowser.config.config as config
|
||||
from qutebrowser.config.style import get_stylesheet
|
||||
from qutebrowser.models.completionfilter import CompletionFilterModel
|
||||
from qutebrowser.models.commandcompletion import CommandCompletionModel
|
||||
from qutebrowser.models.settingcompletion import SettingCompletionModel
|
||||
|
||||
|
||||
class CompletionView(QTreeView):
|
||||
@ -100,6 +101,7 @@ class CompletionView(QTreeView):
|
||||
self._completion_models = {}
|
||||
self._completion_models[''] = None
|
||||
self._completion_models['command'] = CommandCompletionModel()
|
||||
self._completion_models['setting'] = SettingCompletionModel()
|
||||
self._ignore_next = False
|
||||
self._completing = False
|
||||
|
||||
@ -176,15 +178,28 @@ class CompletionView(QTreeView):
|
||||
# Text changed by a completion, so we don't have to complete again.
|
||||
self._ignore_next = False
|
||||
return
|
||||
# FIXME more sophisticated completions
|
||||
if ' ' in text or not text.startswith(':'):
|
||||
|
||||
if not text.startswith(':'):
|
||||
self.hide()
|
||||
self._completing = False
|
||||
return
|
||||
|
||||
self._completing = True
|
||||
self.setmodel('command')
|
||||
text = text.lstrip(':')
|
||||
|
||||
if ' ' in text:
|
||||
spl = text.split()
|
||||
if len(spl) == 1 and spl[0] in ['open']: # FIXME
|
||||
self.setmodel('setting')
|
||||
else:
|
||||
self.hide()
|
||||
self._completing = False
|
||||
return
|
||||
else:
|
||||
self.setmodel('command')
|
||||
|
||||
self._completing = True
|
||||
if text:
|
||||
text = text.split()[-1]
|
||||
self.model.pattern = text
|
||||
self.model.srcmodel.mark_all_items(text)
|
||||
if self._enabled:
|
||||
|
Loading…
Reference in New Issue
Block a user