diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index a17551f623..1eb249c0b4 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -510,7 +510,7 @@ class Cache(object): return frozenset(self.fields[field].table.col_book_map) try: - return frozenset(itervalues(self.fields[field].table.id_map)) + return frozenset(self.fields[field].table.id_map.values()) except AttributeError: raise ValueError('%s is not a many-one or many-many field' % field) diff --git a/src/calibre/gui2/complete2.py b/src/calibre/gui2/complete2.py index f28232defa..9b49f6164c 100644 --- a/src/calibre/gui2/complete2.py +++ b/src/calibre/gui2/complete2.py @@ -36,8 +36,10 @@ class CompleteModel(QAbstractListModel): # {{{ self.current_prefix = '' def set_items(self, items): - items = [unicode_type(x).strip() if self.strip_completion_entries else unicode_type(x) for x in items] - items = [x for x in items if x] + if self.strip_completion_entries: + items = (str(x).strip() for x in items if x) + else: + items = (str(x) for x in items if x) items = tuple(sorted(items, key=self.sort_func)) self.beginResetModel() self.all_items = self.current_items = items diff --git a/src/calibre/gui2/dialogs/search.py b/src/calibre/gui2/dialogs/search.py index 771da22b52..4638f0a059 100644 --- a/src/calibre/gui2/dialogs/search.py +++ b/src/calibre/gui2/dialogs/search.py @@ -127,22 +127,21 @@ def create_simple_tab(self, db): le.set_separator('&') le.set_space_before_sep(True) le.set_add_separator(tweaks['authors_completer_append_separator']) - le.update_items_cache(db.all_author_names()) + le.update_items_cache(db.new_api.all_field_names('authors')) l.addRow(_('&Author:'), le) self.series_box = le = EditWithComplete(self) le.lineEdit().setPlaceholderText(_('The series to search for')) le.setObjectName('series_box') - all_series = sorted((x[1] for x in db.all_series()), key=sort_key) le.set_separator(None) - le.update_items_cache(all_series) + le.update_items_cache(db.new_api.all_field_names('series')) le.show_initial_value('') l.addRow(_('&Series:'), le) self.tags_box = le = EditWithComplete(self) le.setObjectName('tags_box') le.lineEdit().setPlaceholderText(_('The tags to search for')) - self.tags_box.update_items_cache(db.all_tags()) + self.tags_box.update_items_cache(db.new_api.all_field_names('tags')) l.addRow(_('Ta&gs:'), le) searchables = sorted(db.field_metadata.searchable_fields(), @@ -490,4 +489,5 @@ if __name__ == '__main__': app = Application([]) d = SearchDialog(None, db) d.exec_() + print(d.search_string())