mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
33bdde0edf
commit
b7be75ad8c
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
|
|
||||||
from PyQt4.Qt import (QLineEdit, QAbstractListModel, Qt,
|
from PyQt4.Qt import (QLineEdit, QAbstractListModel, Qt,
|
||||||
QApplication, QCompleter, QMetaObject)
|
QApplication, QCompleter, pyqtSignal)
|
||||||
|
|
||||||
from calibre.utils.icu import sort_key, lower
|
from calibre.utils.icu import sort_key, lower
|
||||||
from calibre.gui2 import NONE
|
from calibre.gui2 import NONE
|
||||||
@ -158,6 +158,8 @@ class MultiCompleteLineEdit(QLineEdit, LineEditECM):
|
|||||||
|
|
||||||
class MultiCompleteComboBox(EnComboBox):
|
class MultiCompleteComboBox(EnComboBox):
|
||||||
|
|
||||||
|
clear_edit_text = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
EnComboBox.__init__(self, *args)
|
EnComboBox.__init__(self, *args)
|
||||||
self.setLineEdit(MultiCompleteLineEdit(self))
|
self.setLineEdit(MultiCompleteLineEdit(self))
|
||||||
@ -169,6 +171,8 @@ class MultiCompleteComboBox(EnComboBox):
|
|||||||
self.dummy_model = CompleteModel(self)
|
self.dummy_model = CompleteModel(self)
|
||||||
c.setModel(self.dummy_model)
|
c.setModel(self.dummy_model)
|
||||||
self.lineEdit()._completer.setWidget(self)
|
self.lineEdit()._completer.setWidget(self)
|
||||||
|
self.clear_edit_text.connect(self.clearEditText,
|
||||||
|
type=Qt.QueuedConnection)
|
||||||
|
|
||||||
def update_items_cache(self, complete_items):
|
def update_items_cache(self, complete_items):
|
||||||
self.lineEdit().update_items_cache(complete_items)
|
self.lineEdit().update_items_cache(complete_items)
|
||||||
@ -191,8 +195,7 @@ class MultiCompleteComboBox(EnComboBox):
|
|||||||
what = unicode(what)
|
what = unicode(what)
|
||||||
le = self.lineEdit()
|
le = self.lineEdit()
|
||||||
if not what.strip():
|
if not what.strip():
|
||||||
QMetaObject.invokeMethod(self, 'clearEditText',
|
self.clear_edit_text.emit()
|
||||||
Qt.QueuedConnection)
|
|
||||||
else:
|
else:
|
||||||
self.setEditText(what)
|
self.setEditText(what)
|
||||||
le.selectAll()
|
le.selectAll()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user