Set text correctly when completing

This commit is contained in:
Florian Bruhin 2014-04-09 07:14:26 +02:00
parent fd3262e2ba
commit ad742d51d8
3 changed files with 14 additions and 10 deletions

View File

@ -63,8 +63,8 @@ class CompletionView(QTreeView):
_delegate: The item delegate used.
Signals:
append_cmd_text: Command text which should be appended to the
statusbar.
change_completed_part: Text which should be substituted for the word
we're currently completing.
"""
@ -98,7 +98,7 @@ class CompletionView(QTreeView):
# like one anymore
# FIXME somehow only the first column is yellow, even with
# setAllColumnsShowFocus
append_cmd_text = pyqtSignal(str)
change_completed_part = pyqtSignal(str)
def __init__(self, parent=None):
super().__init__(parent)
@ -250,7 +250,7 @@ class CompletionView(QTreeView):
shift: Whether shift is pressed or not.
Emit:
append_cmd_text: When a command text should be set/appended.
change_completed_part: When a completion took place.
"""
if not self._completing:
@ -262,7 +262,7 @@ class CompletionView(QTreeView):
data = self._model.data(idx)
if data is not None:
self._ignore_next = True
self.append_cmd_text.emit(self._model.data(idx))
self.change_completed_part.emit(self._model.data(idx))
class _CompletionItemDelegate(QStyledItemDelegate):

View File

@ -91,8 +91,8 @@ class MainWindow(QWidget):
self.status.cmd.textChanged.connect(
self.completion.on_cmd_text_changed)
self.status.cmd.tab_pressed.connect(self.completion.on_tab_pressed)
self.completion.append_cmd_text.connect(
self.status.cmd.on_append_cmd_text)
self.completion.change_completed_part.connect(
self.status.cmd.on_change_completed_part)
#self.retranslateUi(MainWindow)
#self.tabWidget.setCurrentIndex(0)

View File

@ -29,6 +29,7 @@ from qutebrowser.config.style import get_stylesheet
import qutebrowser.commands.keys as keys
from qutebrowser.utils.url import urlstring
from qutebrowser.utils.usertypes import NeighborList
from qutebrowser.commands.parsers import split_cmdline
class StatusBar(QWidget):
@ -376,14 +377,17 @@ class _Command(QLineEdit):
self.show_cmd.emit()
@pyqtSlot(str)
def on_append_cmd_text(self, text):
"""Append text to the commandline.
def on_change_completed_part(self, text):
"""Change the part we're currently completing in the commandline.
Args:
text: The text to set (string).
"""
self.setText(self.text() + text)
# FIXME we should consider the cursor position.
parts = split_cmdline(self.text())
parts[-1] = text
self.setText(':' + ' '.join(parts))
self.setFocus()
self.show_cmd.emit()