From 78e0db6f8ab043334fa20c702da688e75c7912c7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Feb 2025 16:53:17 +0530 Subject: [PATCH] Fix accidental removal of completion from series and publisher delegates --- src/calibre/gui2/library/delegates.py | 19 +++++-------------- src/calibre/gui2/pin_columns.py | 1 + 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index c55d04f5a1..be49192fda 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -342,28 +342,18 @@ class PubDateDelegate(StyledItemDelegate, UpdateEditorGeometry): # {{{ class TextDelegate(StyledItemDelegate, UpdateEditorGeometry, EditableTextDelegate): # {{{ use_title_sort = False - - def __init__(self, parent): - ''' - Delegate for text data. If auto_complete_function needs to return a list - of text items to auto-complete with. If the function is None no - auto-complete will be used. - ''' - StyledItemDelegate.__init__(self, parent) - self.auto_complete_function = None - - def set_auto_complete_function(self, f): - self.auto_complete_function = f + auto_complete_function_name = '' def create_editor(self, parent, option, index): - if self.auto_complete_function: + db = index.model().db + if self.auto_complete_function_name and (f := getattr(db, self.auto_complete_function_name, None)): 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 = [i[1] for i in self.auto_complete_function()] + complete_items = [i[1] for i in f()] editor.update_items_cache(complete_items) else: editor = EnLineEdit(parent) @@ -382,6 +372,7 @@ class TextDelegate(StyledItemDelegate, UpdateEditorGeometry, EditableTextDelegat class SeriesDelegate(TextDelegate): # {{{ use_title_sort = True + auto_complete_function_name = 'all_series' def initStyleOption(self, option, index): TextDelegate.initStyleOption(self, option, index) diff --git a/src/calibre/gui2/pin_columns.py b/src/calibre/gui2/pin_columns.py index d65784b66f..18707eea41 100644 --- a/src/calibre/gui2/pin_columns.py +++ b/src/calibre/gui2/pin_columns.py @@ -88,6 +88,7 @@ class TableView(QTableView): self.cc_names_delegate = CompleteDelegate(self, '&', 'all_custom', True) self.series_delegate = SeriesDelegate(self) self.publisher_delegate = TextDelegate(self) + self.publisher_delegate.auto_complete_function_name = 'all_publishers' self.text_delegate = TextDelegate(self) self.cc_text_delegate = CcTextDelegate(self) self.cc_series_delegate = CcSeriesDelegate(self)