diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index cb32358d3b..59d3b89770 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -125,7 +125,7 @@ class BooksView(QTableView): # {{{ self.last_modified_delegate = DateDelegate(self, tweak_name='gui_last_modified_display_format') self.languages_delegate = LanguagesDelegate(self) - self.tags_delegate = CompleteDelegate(self, ',', 'all_tags') + self.tags_delegate = CompleteDelegate(self, ',', 'all_tag_names') self.authors_delegate = CompleteDelegate(self, '&', 'all_author_names', True) self.cc_names_delegate = CompleteDelegate(self, '&', 'all_custom', True) self.series_delegate = TextDelegate(self) diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index d2a983415f..0d9f4e6aa8 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -1114,7 +1114,7 @@ class TagsEdit(MultiCompleteLineEdit): # {{{ tags = db.tags(id_, index_is_id=True) tags = tags.split(',') if tags else [] self.current_val = tags - self.all_items = db.all_tags() + self.all_items = db.all_tag_names() self.original_val = self.current_val @property diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index e60350b307..905eb84fa4 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -3737,4 +3737,42 @@ books_series_link feeds 'SELECT {0}, count(*) FROM books_{1}_link GROUP BY {0}'.format( fm['link_column'], fm['table'])) + def all_author_names(self): + ai = self.FIELD_MAP['authors'] + ans = set() + for rec in self.data.iterall(): + auts = rec[ai] + if auts: + for x in auts.split(','): + ans.add(x.replace('|', ',')) + return ans + + def all_tag_names(self): + ai = self.FIELD_MAP['tags'] + ans = set() + for rec in self.data.iterall(): + auts = rec[ai] + if auts: + for x in auts.split(','): + ans.add(x) + return ans + + def all_publisher_names(self): + ai = self.FIELD_MAP['publisher'] + ans = set() + for rec in self.data.iterall(): + auts = rec[ai] + if auts: + ans.add(auts) + return ans + + def all_series_names(self): + ai = self.FIELD_MAP['series'] + ans = set() + for rec in self.data.iterall(): + auts = rec[ai] + if auts: + ans.add(auts) + return ans +