mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a delete button to the details panel as well
This commit is contained in:
parent
ff063d0783
commit
b90e6964d0
@ -348,6 +348,7 @@ class DetailsPanel(QWidget):
|
|||||||
|
|
||||||
open_annotation = pyqtSignal(object, object, object)
|
open_annotation = pyqtSignal(object, object, object)
|
||||||
show_book = pyqtSignal(object, object)
|
show_book = pyqtSignal(object, object)
|
||||||
|
delete_annotation = pyqtSignal(object)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
@ -368,6 +369,13 @@ class DetailsPanel(QWidget):
|
|||||||
lb.clicked.connect(self.show_in_library)
|
lb.clicked.connect(self.show_in_library)
|
||||||
h.addWidget(lb)
|
h.addWidget(lb)
|
||||||
|
|
||||||
|
h = QHBoxLayout()
|
||||||
|
l.addLayout(h)
|
||||||
|
self.delete_button = ob = QPushButton(QIcon(I('trash.png')), _('Delete'), self)
|
||||||
|
ob.setToolTip(_('Delete this annotation'))
|
||||||
|
ob.clicked.connect(self.delete_result)
|
||||||
|
h.addWidget(ob)
|
||||||
|
|
||||||
self.show_result(None)
|
self.show_result(None)
|
||||||
|
|
||||||
def open_result(self):
|
def open_result(self):
|
||||||
@ -375,6 +383,11 @@ class DetailsPanel(QWidget):
|
|||||||
r = self.current_result
|
r = self.current_result
|
||||||
self.open_annotation.emit(r['book_id'], r['format'], r['annotation'])
|
self.open_annotation.emit(r['book_id'], r['format'], r['annotation'])
|
||||||
|
|
||||||
|
def delete_result(self):
|
||||||
|
if self.current_result is not None:
|
||||||
|
r = self.current_result
|
||||||
|
self.delete_annotation.emit(r['id'])
|
||||||
|
|
||||||
def show_in_library(self):
|
def show_in_library(self):
|
||||||
if self.current_result is not None:
|
if self.current_result is not None:
|
||||||
self.show_book.emit(self.current_result['book_id'], self.current_result['format'])
|
self.show_book.emit(self.current_result['book_id'], self.current_result['format'])
|
||||||
@ -495,6 +508,7 @@ class AnnotationsBrowser(Dialog):
|
|||||||
s.addWidget(dp)
|
s.addWidget(dp)
|
||||||
dp.open_annotation.connect(self.do_open_annotation)
|
dp.open_annotation.connect(self.do_open_annotation)
|
||||||
dp.show_book.connect(self.show_book)
|
dp.show_book.connect(self.show_book)
|
||||||
|
dp.delete_annotation.connect(self.delete_annotation)
|
||||||
bp.current_result_changed.connect(dp.show_result)
|
bp.current_result_changed.connect(dp.show_result)
|
||||||
|
|
||||||
h = QHBoxLayout()
|
h = QHBoxLayout()
|
||||||
@ -510,6 +524,8 @@ class AnnotationsBrowser(Dialog):
|
|||||||
if not ids:
|
if not ids:
|
||||||
return error_dialog(self, _('No selected annotations'), _(
|
return error_dialog(self, _('No selected annotations'), _(
|
||||||
'No annotations have been selected'), show=True)
|
'No annotations have been selected'), show=True)
|
||||||
|
|
||||||
|
def delete_annotations(self, ids):
|
||||||
if question_dialog(self, _('Are you sure?'), ngettext(
|
if question_dialog(self, _('Are you sure?'), ngettext(
|
||||||
'Are you sure you want to <b>permanently</b> delete this annotation?',
|
'Are you sure you want to <b>permanently</b> delete this annotation?',
|
||||||
'Are you sure you want to <b>permanently</b> delete these {} annotations?',
|
'Are you sure you want to <b>permanently</b> delete these {} annotations?',
|
||||||
@ -519,6 +535,9 @@ class AnnotationsBrowser(Dialog):
|
|||||||
db.delete_annotations(ids)
|
db.delete_annotations(ids)
|
||||||
self.browse_panel.refresh()
|
self.browse_panel.refresh()
|
||||||
|
|
||||||
|
def delete_annotation(self, annot_id):
|
||||||
|
self.delete_annotations(frozenset({annot_id}))
|
||||||
|
|
||||||
def show_dialog(self):
|
def show_dialog(self):
|
||||||
if self.parent() is None:
|
if self.parent() is None:
|
||||||
self.browse_panel.effective_query_changed()
|
self.browse_panel.effective_query_changed()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user