@@ -342,28 +342,18 @@ def set_editor_data(self, editor, index):
342
342
class TextDelegate (StyledItemDelegate , UpdateEditorGeometry , EditableTextDelegate ): # {{{
343
343
344
344
use_title_sort = False
345
-
346
- def __init__ (self , parent ):
347
- '''
348
- Delegate for text data. If auto_complete_function needs to return a list
349
- of text items to auto-complete with. If the function is None no
350
- auto-complete will be used.
351
- '''
352
- StyledItemDelegate .__init__ (self , parent )
353
- self .auto_complete_function = None
354
-
355
- def set_auto_complete_function (self , f ):
356
- self .auto_complete_function = f
345
+ auto_complete_function_name = ''
357
346
358
347
def create_editor (self , parent , option , index ):
359
- if self .auto_complete_function :
348
+ db = index .model ().db
349
+ if self .auto_complete_function_name and (f := getattr (db , self .auto_complete_function_name , None )):
360
350
if self .use_title_sort :
361
351
editor = EditWithComplete (parent , sort_func = title_sort )
362
352
else :
363
353
editor = EditWithComplete (parent )
364
354
editor .set_separator (None )
365
355
editor .set_clear_button_enabled (False )
366
- complete_items = [i [1 ] for i in self . auto_complete_function ()]
356
+ complete_items = [i [1 ] for i in f ()]
367
357
editor .update_items_cache (complete_items )
368
358
else :
369
359
editor = EnLineEdit (parent )
@@ -382,6 +372,7 @@ def setModelData(self, editor, model, index):
382
372
class SeriesDelegate (TextDelegate ): # {{{
383
373
384
374
use_title_sort = True
375
+ auto_complete_function_name = 'all_series'
385
376
386
377
def initStyleOption (self , option , index ):
387
378
TextDelegate .initStyleOption (self , option , index )
0 commit comments