More work on annotations browser

This commit is contained in:
Kovid Goyal 2020-06-15 21:34:48 +05:30
parent 7ed580cad4
commit 9b7f69e4bb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 2 deletions

View File

@ -305,7 +305,7 @@ def save_annotations_for_book(cursor, book_id, fmt, annots_list, user_type='loca
aid = text = annot['title']
elif atype == 'highlight':
aid = annot['uuid']
text = annot.get('highlighed_text') or ''
text = annot.get('highlighted_text') or ''
notes = annot.get('notes') or ''
if notes:
text += '\n0x1f\n' + notes

View File

@ -37,6 +37,8 @@ class ResultsList(QListWidget):
def set_results(self, results):
self.clear()
for result in results:
print(result)
class BrowsePanel(QWidget):
@ -120,6 +122,10 @@ class AnnotationsBrowser(Dialog):
Dialog.__init__(self, _('Annotations browser'), 'library-annotations-browser-1', parent=parent)
self.setAttribute(Qt.WA_DeleteOnClose, False)
def keyPressEvent(self, ev):
if ev.key() not in (Qt.Key_Enter, Qt.Key_Return):
return Dialog.keyPressEvent(self, ev)
def setup_ui(self):
l = QVBoxLayout(self)
@ -136,10 +142,19 @@ class AnnotationsBrowser(Dialog):
self.bb.setStandardButtons(self.bb.Close)
l.addWidget(self.bb)
def show_dialog(self):
self.browse_panel.search_box.setFocus(Qt.OtherFocusReason)
if self.parent() is None:
self.exec_()
else:
self.show()
if __name__ == '__main__':
from calibre.library import db
app = Application([])
current_db.ans = db(os.path.expanduser('~/test library'))
AnnotationsBrowser().exec_()
br = AnnotationsBrowser()
br.show_dialog()
del br
del app