if not self.gui.device_manager.is_device_connected:
d = error_dialog(self.gui, _('Cannot delete books'), _('No device is connected'))
d.exec_()
return None
ids = self._get_selected_ids()
if not ids:
return None
to_delete = { }
some_to_delete = False
for model, name in ((self.gui.memory_view.model(), _('Main memory')), (self.gui.card_a_view.model(), _('Storage Card A')), (self.gui.card_b_view.model(), _('Storage Card B'))):
for v in (self.gui.memory_view, self.gui.card_a_view, self.gui.card_b_view):
if v is None:
continue
v.model().clear_ondevice(ids_deleted)
if current_row is not None:
ci = view.model().index(current_row, 0)
if ci.isValid():
view.set_current_row(current_row)
def delete_books(self, *args):
view = self.gui.current_view()
rows = view.selectionModel().selectedRows()
if not rows or len(rows) == 0:
return None
if self.gui.stack.currentIndex() == 0:
if not confirm('<p>' + _('The selected books will be <b>permanently deleted</b> and the files removed from your calibre library. Are you sure?') + '</p>', 'library_delete_books', self.gui):
return None
ci = view.currentIndex()
row = None
ids_deleted = view.model().delete_books(rows)
self.library_ids_deleted(ids_deleted, row)
elif not confirm('<p>' + _('The selected books will be <b>permanently deleted</b> from your device. Are you sure?') + '</p>', 'device_delete_books', self.gui):
return None
if self.gui.stack.currentIndex() == 1:
view = self.gui.memory_view
elif self.gui.stack.currentIndex() == 2:
view = self.gui.card_a_view
else:
view = self.gui.card_b_view
paths = view.model().paths(rows)
job = self.gui.remove_paths(paths)
self.delete_memory[job] = (paths, view.model())
view.model().mark_for_deletion(job, rows)
self.gui.status_bar.show_message(_('Deleting books from device.'), 1000)