mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Notes browser: When searching books search over all currently selected categories not just the last selected one
This commit is contained in:
parent
59fa8a62d3
commit
f35276dccb
@ -477,19 +477,20 @@ class NotesBrowser(Dialog):
|
|||||||
gui = get_gui()
|
gui = get_gui()
|
||||||
if gui is not None:
|
if gui is not None:
|
||||||
b = self.bb.addButton(_('Search books'), QDialogButtonBox.ButtonRole.ActionRole)
|
b = self.bb.addButton(_('Search books'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||||
b.setToolTip(_('Search the calibre library for books in the currently selected category'))
|
b.setToolTip(_('Search the calibre library for books in the currently selected categories'))
|
||||||
b.clicked.connect(self.search_books)
|
b.clicked.connect(self.search_books)
|
||||||
b.setIcon(QIcon.ic('search.png'))
|
b.setIcon(QIcon.ic('search.png'))
|
||||||
QTimer.singleShot(0, self.do_find)
|
QTimer.singleShot(0, self.do_find)
|
||||||
|
|
||||||
def search_books(self):
|
def search_books(self):
|
||||||
self.notes_display.current_result_changed
|
vals = []
|
||||||
item = self.results_list.currentItem()
|
for item in self.results_list.selectedItems():
|
||||||
if item:
|
|
||||||
r = item.data(0, Qt.ItemDataRole.UserRole)
|
r = item.data(0, Qt.ItemDataRole.UserRole)
|
||||||
if isinstance(r, dict):
|
if isinstance(r, dict):
|
||||||
ival = r['text'].split('\n', 1)[0].replace('"', '\\"')
|
ival = r['text'].split('\n', 1)[0].replace('"', '\\"')
|
||||||
search_expression = f'{r["field"]}:"={ival}"'
|
vals.append(ival)
|
||||||
|
if vals:
|
||||||
|
search_expression = ' OR '.join(f'{r["field"]}:"={ival}"' for ival in vals)
|
||||||
from calibre.gui2.ui import get_gui
|
from calibre.gui2.ui import get_gui
|
||||||
get_gui().search.set_search_string(search_expression)
|
get_gui().search.set_search_string(search_expression)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user