mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'texts-delegates' of https://github.com/un-pogaz/calibre
This commit is contained in:
commit
d296547799
@ -109,6 +109,11 @@ class UpdateEditorGeometry:
|
|||||||
initial_geometry.adjust(delta_x, 0, delta_width, 0)
|
initial_geometry.adjust(delta_x, 0, delta_width, 0)
|
||||||
editor.setGeometry(initial_geometry)
|
editor.setGeometry(initial_geometry)
|
||||||
|
|
||||||
|
class EditableTextDelegate:
|
||||||
|
|
||||||
|
def setEditorData(self, editor, index):
|
||||||
|
n = editor.metaObject().userProperty().name()
|
||||||
|
editor.setProperty(n, get_val_for_textlike_columns(index))
|
||||||
|
|
||||||
class DateTimeEdit(DateTimeEditBase): # {{{
|
class DateTimeEdit(DateTimeEditBase): # {{{
|
||||||
|
|
||||||
@ -285,7 +290,7 @@ class PubDateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry, EditableTextDelegate): # {{{
|
||||||
|
|
||||||
use_title_sort = False
|
use_title_sort = False
|
||||||
|
|
||||||
@ -316,10 +321,6 @@ class TextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
editor = EnLineEdit(parent)
|
editor = EnLineEdit(parent)
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
def setEditorData(self, editor, index):
|
|
||||||
n = editor.metaObject().userProperty().name()
|
|
||||||
editor.setProperty(n, get_val_for_textlike_columns(index))
|
|
||||||
|
|
||||||
def setModelData(self, editor, model, index):
|
def setModelData(self, editor, model, index):
|
||||||
if isinstance(editor, EditWithComplete):
|
if isinstance(editor, EditWithComplete):
|
||||||
val = editor.lineEdit().text()
|
val = editor.lineEdit().text()
|
||||||
@ -340,7 +341,7 @@ class SeriesDelegate(TextDelegate): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class CompleteDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
class CompleteDelegate(QStyledItemDelegate, UpdateEditorGeometry, EditableTextDelegate): # {{{
|
||||||
|
|
||||||
def __init__(self, parent, sep, items_func_name, space_before_sep=False):
|
def __init__(self, parent, sep, items_func_name, space_before_sep=False):
|
||||||
QStyledItemDelegate.__init__(self, parent)
|
QStyledItemDelegate.__init__(self, parent)
|
||||||
@ -381,10 +382,6 @@ class CompleteDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
editor = EnLineEdit(parent)
|
editor = EnLineEdit(parent)
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
def setEditorData(self, editor, index):
|
|
||||||
n = editor.metaObject().userProperty().name()
|
|
||||||
editor.setProperty(n, get_val_for_textlike_columns(index))
|
|
||||||
|
|
||||||
def setModelData(self, editor, model, index):
|
def setModelData(self, editor, model, index):
|
||||||
if isinstance(editor, EditWithComplete):
|
if isinstance(editor, EditWithComplete):
|
||||||
val = editor.lineEdit().text()
|
val = editor.lineEdit().text()
|
||||||
@ -464,7 +461,7 @@ class CcDateDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class CcTextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
class CcTextDelegate(QStyledItemDelegate, UpdateEditorGeometry, EditableTextDelegate): # {{{
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Delegate for text data.
|
Delegate for text data.
|
||||||
@ -495,10 +492,6 @@ class CcTextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
|
|||||||
editor.setText(text)
|
editor.setText(text)
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
def setEditorData(self, editor, index):
|
|
||||||
n = editor.metaObject().userProperty().name()
|
|
||||||
editor.setProperty(n, get_val_for_textlike_columns(index))
|
|
||||||
|
|
||||||
def setModelData(self, editor, model, index):
|
def setModelData(self, editor, model, index):
|
||||||
val = editor.text() or ''
|
val = editor.text() or ''
|
||||||
if not isinstance(editor, EditWithComplete):
|
if not isinstance(editor, EditWithComplete):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user