Fix editing of text type custom columns in book list broken

This commit is contained in:
Kovid Goyal 2012-07-13 20:54:31 +05:30
commit 5102a20efb
2 changed files with 7 additions and 3 deletions

View File

@ -357,9 +357,8 @@ class EditWithComplete(EnComboBox):
def show_initial_value(self, what):
what = unicode(what) if what else u''
le = self.lineEdit()
self.setEditText(what)
le.selectAll()
self.setText(what)
self.lineEdit().selectAll()
@dynamic_property
def all_items(self):

View File

@ -249,8 +249,13 @@ class CcTextDelegate(QStyledItemDelegate): # {{{
complete_items = sorted(list(m.db.all_custom(label=m.db.field_metadata.key_to_label(col))),
key=sort_key)
editor.update_items_cache(complete_items)
ct = index.data(Qt.DisplayRole).toString()
editor.show_initial_value(ct)
return editor
def setModelData(self, editor, model, index):
val = editor.text()
model.setData(index, QVariant(val), Qt.EditRole)
# }}}
class CcNumberDelegate(QStyledItemDelegate): # {{{