From ccb6ff9d3e097a794514f27860c70bca130c4a9c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Jun 2022 22:48:38 +0530 Subject: [PATCH] Forgot the custom series edit widgets in my last commit --- src/calibre/gui2/custom_column_widgets.py | 5 +++-- src/calibre/gui2/library/delegates.py | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/custom_column_widgets.py b/src/calibre/gui2/custom_column_widgets.py index c9aeb75a3a..41a56888e7 100644 --- a/src/calibre/gui2/custom_column_widgets.py +++ b/src/calibre/gui2/custom_column_widgets.py @@ -14,6 +14,7 @@ from qt.core import (Qt, QComboBox, QLabel, QSpinBox, QDoubleSpinBox, QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, QLineEdit, QMessageBox, QToolButton, QPlainTextEdit, QApplication, QStyle, QDialog) +from calibre.ebooks.metadata import title_sort from calibre.utils.date import qt_to_dt, now, as_local_time, as_utc, internal_iso_format_string from calibre.gui2.complete2 import EditWithComplete as EWC from calibre.gui2.comments_editor import Editor as CommentsEditor @@ -591,7 +592,7 @@ class Text(Base): class Series(Base): def setup_ui(self, parent): - w = EditWithComplete(parent) + w = EditWithComplete(parent, sort_key=title_sort) w.set_separator(None) w.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) w.setMinimumContentsLength(25) @@ -1178,7 +1179,7 @@ class BulkDateTime(BulkBase): class BulkSeries(BulkBase): def setup_ui(self, parent): - self.make_widgets(parent, EditWithComplete) + self.make_widgets(parent, partial(EditWithComplete, sort_func=title_sort)) values = self.all_values = list(self.db.all_custom(num=self.col_id)) values.sort(key=sort_key) self.main_widget.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index 4ce508361f..f6230b978f 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -468,6 +468,7 @@ class CcTextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{ ''' Delegate for text data. ''' + use_title_sort = False def __init__(self, parent): QStyledItemDelegate.__init__(self, parent) @@ -478,7 +479,10 @@ class CcTextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{ col = m.column_map[index.column()] key = m.db.field_metadata.key_to_label(col) if m.db.field_metadata[col]['datatype'] != 'comments': - editor = EditWithComplete(parent) + if self.use_title_sort: + editor = EditWithComplete(parent, sort_func=title_sort) + else: + editor = EditWithComplete(parent) editor.set_separator(None) editor.set_clear_button_enabled(False) complete_items = sorted(list(m.db.all_custom(label=key)), key=sort_key) @@ -505,6 +509,8 @@ class CcTextDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{ class CcSeriesDelegate(CcTextDelegate): # {{{ + use_title_sort = True + def initStyleOption(self, option, index): CcTextDelegate.initStyleOption(self, option, index) option.textElideMode = Qt.TextElideMode.ElideMiddle