Clear completion model after an item is selected

This commit is contained in:
Florian Bruhin 2014-04-13 22:11:47 +02:00
parent 5d3fe4f506
commit f59f8cac6c
4 changed files with 13 additions and 1 deletions

1
TODO
View File

@ -7,7 +7,6 @@ New config TODO
Bugs
====
- Tabbing to a command, then executing it with an error (e.g. :set) keeps the completion position
Underlines aren't displayed correctly in completion widget
All kind of FIXMEs
Weird font rendering

View File

@ -275,6 +275,12 @@ class CompletionView(QTreeView):
self._ignore_next = True
self.change_completed_part.emit(data)
@pyqtSlot()
def on_clear_completion_selection(self):
"""Clear the selection model when an item is activated."""
self.selectionModel().clearSelection()
self.selectionModel().clearCurrentIndex()
class _CompletionItemDelegate(QStyledItemDelegate):

View File

@ -86,6 +86,8 @@ class MainWindow(QWidget):
self.tabs.cur_url_changed.connect(self.status.url.set_url)
self.tabs.cur_link_hovered.connect(self.status.url.set_hover_url)
self.status.cmd.esc_pressed.connect(self.tabs.setFocus)
self.status.cmd.clear_completion_selection.connect(
self.completion.on_clear_completion_selection)
self.status.cmd.hide_completion.connect(self.completion.hide)
self.status.cmd.textChanged.connect(
self.completion.on_cmd_text_changed)

View File

@ -227,6 +227,8 @@ class _Command(QLineEdit):
esc_pressed: Emitted when the escape key was pressed.
tab_pressed: Emitted when the tab key was pressed.
arg: Whether shift has been pressed.
clear_completion_selection: Emitted before the completion widget is
hidden.
hide_completion: Emitted when the completion widget should be hidden.
show_cmd: Emitted when command input should be shown.
hide_cmd: Emitted when command input can be hidden.
@ -239,6 +241,7 @@ class _Command(QLineEdit):
got_search_rev = pyqtSignal(str)
esc_pressed = pyqtSignal()
tab_pressed = pyqtSignal(bool)
clear_completion_selection = pyqtSignal()
hide_completion = pyqtSignal()
show_cmd = pyqtSignal()
hide_cmd = pyqtSignal()
@ -393,6 +396,7 @@ class _Command(QLineEdit):
e: The QFocusEvent.
Emit:
clear_completion_selection: Always emitted.
hide_completion: Always emitted so the completion is hidden.
"""
if e.reason() in [Qt.MouseFocusReason, Qt.TabFocusReason,
@ -400,6 +404,7 @@ class _Command(QLineEdit):
self.setText('')
self._histbrowse_stop()
self.hide_cmd.emit()
self.clear_completion_selection.emit()
self.hide_completion.emit()
super().focusOutEvent(e)