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'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
from PyQt4.Qt import QLineEdit, QAbstractListModel, Qt, \
|
from PyQt4.Qt import (QLineEdit, QAbstractListModel, Qt,
|
||||||
QApplication, QCompleter
|
QApplication, QCompleter, QMetaObject)
|
||||||
|
|
||||||
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
|
||||||
@ -182,14 +182,22 @@ class MultiCompleteComboBox(EnComboBox):
|
|||||||
def set_add_separator(self, what):
|
def set_add_separator(self, what):
|
||||||
self.lineEdit().set_add_separator(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__':
|
if __name__ == '__main__':
|
||||||
from PyQt4.Qt import QDialog, QVBoxLayout
|
from PyQt4.Qt import QDialog, QVBoxLayout
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
d = QDialog()
|
d = QDialog()
|
||||||
d.setLayout(QVBoxLayout())
|
d.setLayout(QVBoxLayout())
|
||||||
le = MultiCompleteLineEdit(d)
|
le = MultiCompleteComboBox(d)
|
||||||
d.layout().addWidget(le)
|
d.layout().addWidget(le)
|
||||||
le.all_items = ['one', 'otwo', 'othree', 'ooone', 'ootwo', 'oothree']
|
le.all_items = ['one', 'otwo', 'othree', 'ooone', 'ootwo', 'oothree']
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
@ -128,8 +128,7 @@ class TextDelegate(QStyledItemDelegate): # {{{
|
|||||||
for item in sorted(complete_items, key=sort_key):
|
for item in sorted(complete_items, key=sort_key):
|
||||||
editor.addItem(item)
|
editor.addItem(item)
|
||||||
ct = index.data(Qt.DisplayRole).toString()
|
ct = index.data(Qt.DisplayRole).toString()
|
||||||
editor.setEditText(ct)
|
editor.show_initial_value(ct)
|
||||||
editor.lineEdit().selectAll()
|
|
||||||
else:
|
else:
|
||||||
editor = EnLineEdit(parent)
|
editor = EnLineEdit(parent)
|
||||||
return editor
|
return editor
|
||||||
@ -170,8 +169,7 @@ class CompleteDelegate(QStyledItemDelegate): # {{{
|
|||||||
for item in sorted(all_items, key=sort_key):
|
for item in sorted(all_items, key=sort_key):
|
||||||
editor.addItem(item)
|
editor.addItem(item)
|
||||||
ct = index.data(Qt.DisplayRole).toString()
|
ct = index.data(Qt.DisplayRole).toString()
|
||||||
editor.setEditText(ct)
|
editor.show_initial_value(ct)
|
||||||
editor.lineEdit().selectAll()
|
|
||||||
else:
|
else:
|
||||||
editor = EnLineEdit(parent)
|
editor = EnLineEdit(parent)
|
||||||
return editor
|
return editor
|
||||||
@ -190,8 +188,7 @@ class LanguagesDelegate(QStyledItemDelegate): # {{{
|
|||||||
editor = LanguagesEdit(parent=parent)
|
editor = LanguagesEdit(parent=parent)
|
||||||
editor.init_langs(index.model().db)
|
editor.init_langs(index.model().db)
|
||||||
ct = index.data(Qt.DisplayRole).toString()
|
ct = index.data(Qt.DisplayRole).toString()
|
||||||
editor.setEditText(ct)
|
editor.show_initial_value(ct)
|
||||||
editor.lineEdit().selectAll()
|
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
def setModelData(self, editor, model, index):
|
def setModelData(self, editor, model, index):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user