Shortcuts config, commit open editor if user clicks OK

This commit is contained in:
Kovid Goyal 2013-12-03 08:47:31 +05:30
parent eabb3078e8
commit 5ad0ce80c9

View file

@ -538,9 +538,13 @@ def createEditor(self, parent, option, index):
w = Editor(parent=parent)
w.editing_done.connect(self.editor_done)
self.editing_index = index
self.current_editor = w
self.sizeHintChanged.emit(index)
return w
def accept_changes(self):
self.editor_done(self.current_editor)
def editor_done(self, editor):
self.commitData.emit(editor)
@ -579,6 +583,7 @@ def updateEditorGeometry(self, editor, option, index):
editor.setGeometry(option.rect)
def editing_done(self, *args):
self.current_editor = None
idx = self.editing_index
self.editing_index = None
if idx is not None:
@ -625,6 +630,8 @@ def restore_defaults(self):
self.changed_signal.emit()
def commit(self):
if self.view.state() == self.view.EditingState:
self.delegate.accept_changes()
self._model.commit()
def initialize(self, keyboard):