diff --git a/src/calibre/gui2/actions/delete.py b/src/calibre/gui2/actions/delete.py index a0f49a7e9a..24dd1d3e5c 100644 --- a/src/calibre/gui2/actions/delete.py +++ b/src/calibre/gui2/actions/delete.py @@ -12,6 +12,7 @@ from PyQt4.Qt import QMenu, QObject, QTimer from calibre.gui2 import error_dialog from calibre.gui2.dialogs.delete_matching_from_device import DeleteMatchingFromDeviceDialog from calibre.gui2.dialogs.confirm_delete import confirm +from calibre.gui2.dialogs.confirm_delete_location import confirm_location from calibre.gui2.actions import InterfaceAction single_shot = partial(QTimer.singleShot, 10) @@ -223,7 +224,31 @@ class DeleteAction(InterfaceAction): rows = view.selectionModel().selectedRows() if not rows or len(rows) == 0: return + # Library view is visible. if self.gui.stack.currentIndex() == 0: + # Ask the user if they want to delete the book from the library or device if it is in both. + if self.gui.device_manager.is_device_connected: + on_device = False + on_device_ids = self._get_selected_ids() + for id in on_device_ids: + res = self.gui.book_on_device(id) + if res[0] or res[1] or res[2]: + on_device = True + if on_device: + break + if on_device: + loc = confirm_location('
' + _('Some of the selected books are on the attached device. ' + 'Where do you want the selected files deleted from?'), + self.gui) + if not loc: + return + elif loc == 'dev': + self.remove_matching_books_from_device() + return + elif loc == 'both': + self.remove_matching_books_from_device() + # The following will run if the selected books are not on a connected device. + # The user has selected to delete from the library or the device and library. if not confirm('
'+_('The selected books will be ' 'permanently deleted and the files ' 'removed from your calibre library. Are you sure?') @@ -239,7 +264,7 @@ class DeleteAction(InterfaceAction): else: self.__md = MultiDeleter(self.gui, rows, partial(self.library_ids_deleted, current_row=row)) - + # Device view is visible. else: if not confirm('
'+_('The selected books will be '
'permanently deleted '
diff --git a/src/calibre/gui2/dialogs/confirm_delete_location.py b/src/calibre/gui2/dialogs/confirm_delete_location.py
new file mode 100644
index 0000000000..58580ad4d8
--- /dev/null
+++ b/src/calibre/gui2/dialogs/confirm_delete_location.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+__license__ = 'GPL v3'
+__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' \
+ '2010, John Schember