From 9787a710c26a37672f8ac3236f5b67d8054f581f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 29 Jun 2022 16:42:08 +0530 Subject: [PATCH] FTS: Fix restrict books working on selected books rather than filtered books --- src/calibre/gui2/fts/search.py | 2 +- src/calibre/gui2/library/models.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/fts/search.py b/src/calibre/gui2/fts/search.py index 53fda5e559..6e6698bcca 100644 --- a/src/calibre/gui2/fts/search.py +++ b/src/calibre/gui2/fts/search.py @@ -398,7 +398,7 @@ class ResultsView(QTreeView): gui = get_gui() restrict = None if gui and gprefs['fts_library_restrict_books']: - restrict = gui.library_view.get_selected_ids(as_set=True) + restrict = frozenset(gui.library_view.model().all_current_book_ids()) with BusyCursor(): self.m.search(*a, restrict_to_book_ids=restrict, use_stemming=gprefs['fts_library_use_stemmer']) self.expandAll() diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 7b54f7c7b6..fe87a81ee1 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -585,6 +585,9 @@ class BooksModel(QAbstractTableModel): # {{{ return 0 return len(self.db.data) if self.db else 0 + def all_current_book_ids(self): + return self.db.data._map_filtered + def count(self): return self.rowCount(None)