mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #962968 (Regress in Series Column in Main Library screen)
This commit is contained in:
parent
47ec821d31
commit
8da6550a36
@ -6,8 +6,8 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
from PyQt4.Qt import QLineEdit, QAbstractListModel, Qt, \
|
||||
QApplication, QCompleter
|
||||
from PyQt4.Qt import (QLineEdit, QAbstractListModel, Qt,
|
||||
QApplication, QCompleter, QMetaObject)
|
||||
|
||||
from calibre.utils.icu import sort_key, lower
|
||||
from calibre.gui2 import NONE
|
||||
@ -182,14 +182,22 @@ class MultiCompleteComboBox(EnComboBox):
|
||||
def set_add_separator(self, what):
|
||||
self.lineEdit().set_add_separator(what)
|
||||
|
||||
|
||||
def show_initial_value(self, what):
|
||||
what = unicode(what)
|
||||
le = self.lineEdit()
|
||||
if not what.strip():
|
||||
QMetaObject.invokeMethod(self, 'clearEditText',
|
||||
Qt.QueuedConnection)
|
||||
else:
|
||||
self.setEditText(what)
|
||||
le.selectAll()
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt4.Qt import QDialog, QVBoxLayout
|
||||
app = QApplication([])
|
||||
d = QDialog()
|
||||
d.setLayout(QVBoxLayout())
|
||||
le = MultiCompleteLineEdit(d)
|
||||
le = MultiCompleteComboBox(d)
|
||||
d.layout().addWidget(le)
|
||||
le.all_items = ['one', 'otwo', 'othree', 'ooone', 'ootwo', 'oothree']
|
||||
d.exec_()
|
||||
|
@ -128,8 +128,7 @@ class TextDelegate(QStyledItemDelegate): # {{{
|
||||
for item in sorted(complete_items, key=sort_key):
|
||||
editor.addItem(item)
|
||||
ct = index.data(Qt.DisplayRole).toString()
|
||||
editor.setEditText(ct)
|
||||
editor.lineEdit().selectAll()
|
||||
editor.show_initial_value(ct)
|
||||
else:
|
||||
editor = EnLineEdit(parent)
|
||||
return editor
|
||||
@ -170,8 +169,7 @@ class CompleteDelegate(QStyledItemDelegate): # {{{
|
||||
for item in sorted(all_items, key=sort_key):
|
||||
editor.addItem(item)
|
||||
ct = index.data(Qt.DisplayRole).toString()
|
||||
editor.setEditText(ct)
|
||||
editor.lineEdit().selectAll()
|
||||
editor.show_initial_value(ct)
|
||||
else:
|
||||
editor = EnLineEdit(parent)
|
||||
return editor
|
||||
@ -190,8 +188,7 @@ class LanguagesDelegate(QStyledItemDelegate): # {{{
|
||||
editor = LanguagesEdit(parent=parent)
|
||||
editor.init_langs(index.model().db)
|
||||
ct = index.data(Qt.DisplayRole).toString()
|
||||
editor.setEditText(ct)
|
||||
editor.lineEdit().selectAll()
|
||||
editor.show_initial_value(ct)
|
||||
return editor
|
||||
|
||||
def setModelData(self, editor, model, index):
|
||||
|
Loading…
x
Reference in New Issue
Block a user