This commit is contained in:
Kovid Goyal 2012-04-23 15:50:44 +05:30
parent 33bdde0edf
commit b7be75ad8c

View File

@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
from PyQt4.Qt import (QLineEdit, QAbstractListModel, Qt,
QApplication, QCompleter, QMetaObject)
QApplication, QCompleter, pyqtSignal)
from calibre.utils.icu import sort_key, lower
from calibre.gui2 import NONE
@ -158,6 +158,8 @@ class MultiCompleteLineEdit(QLineEdit, LineEditECM):
class MultiCompleteComboBox(EnComboBox):
clear_edit_text = pyqtSignal()
def __init__(self, *args):
EnComboBox.__init__(self, *args)
self.setLineEdit(MultiCompleteLineEdit(self))
@ -169,6 +171,8 @@ class MultiCompleteComboBox(EnComboBox):
self.dummy_model = CompleteModel(self)
c.setModel(self.dummy_model)
self.lineEdit()._completer.setWidget(self)
self.clear_edit_text.connect(self.clearEditText,
type=Qt.QueuedConnection)
def update_items_cache(self, complete_items):
self.lineEdit().update_items_cache(complete_items)
@ -191,8 +195,7 @@ class MultiCompleteComboBox(EnComboBox):
what = unicode(what)
le = self.lineEdit()
if not what.strip():
QMetaObject.invokeMethod(self, 'clearEditText',
Qt.QueuedConnection)
self.clear_edit_text.emit()
else:
self.setEditText(what)
le.selectAll()