don't throw error completing empty tag, hide popup, propagate key event

This commit is contained in:
Damien Elmes 2009-05-16 03:50:58 +09:00
parent 484b15f592
commit 6f2f253d96

View file

@ -36,12 +36,15 @@ class TagEdit(QLineEdit):
def keyPressEvent(self, evt): def keyPressEvent(self, evt):
if evt.key() in (Qt.Key_Enter, Qt.Key_Return): if evt.key() in (Qt.Key_Enter, Qt.Key_Return):
evt.accept() evt.ignore()
if self.completer.completionCount(): if not self.text():
pass
elif self.completer.completionCount():
self.setText( self.setText(
self.completer.pathFromIndex(self.completer.popup().currentIndex())) self.completer.pathFromIndex(self.completer.popup().currentIndex()))
else: else:
self.setText(self.completer.completionPrefix()) self.setText(self.completer.completionPrefix())
self.completer.popup().hide()
return return
QLineEdit.keyPressEvent(self, evt) QLineEdit.keyPressEvent(self, evt)