mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Category notes browser: Add a button to search for books in the currently selected category. Fixes #2046825 [[Enhancement] Browse category notes](https://bugs.launchpad.net/calibre/+bug/2046825)
This commit is contained in:
parent
5875303a48
commit
b714fc5023
@ -454,8 +454,26 @@ class NotesBrowser(Dialog):
|
||||
b.clicked.connect(self.export_selected)
|
||||
b.setToolTip(_('Export the selected notes as HTML files'))
|
||||
h.addWidget(us), h.addStretch(10), h.addWidget(self.bb)
|
||||
from calibre.gui2.ui import get_gui
|
||||
gui = get_gui()
|
||||
if gui is not None:
|
||||
b = self.bb.addButton(_('Search books'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||
b.setToolTip(_('Search the calibre library for books in the currently selected category'))
|
||||
b.clicked.connect(self.search_books)
|
||||
b.setIcon(QIcon.ic('search.png'))
|
||||
QTimer.singleShot(0, self.do_find)
|
||||
|
||||
def search_books(self):
|
||||
self.notes_display.current_result_changed
|
||||
item = self.results_list.currentItem()
|
||||
if item:
|
||||
r = item.data(0, Qt.ItemDataRole.UserRole)
|
||||
if isinstance(r, dict):
|
||||
ival = r['text'].split('\n', 1)[0].replace('"', '\\"')
|
||||
search_expression = f'{r["field"]}:"={ival}"'
|
||||
from calibre.gui2.ui import get_gui
|
||||
get_gui().search.set_search_string(search_expression)
|
||||
|
||||
def export_selected(self):
|
||||
results = tuple(self.results_list.selected_results())
|
||||
if not results:
|
||||
|
Loading…
x
Reference in New Issue
Block a user