mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
39f2ec7bbb
commit
3450e3109d
@ -170,8 +170,8 @@ class DeleteAction(InterfaceAction):
|
|||||||
title = self.gui.current_db.title(book_id, index_is_id=True)
|
title = self.gui.current_db.title(book_id, index_is_id=True)
|
||||||
if not confirm('<p>'+(_(
|
if not confirm('<p>'+(_(
|
||||||
'The %(fmt)s format will be <b>permanently deleted</b> from '
|
'The %(fmt)s format will be <b>permanently deleted</b> from '
|
||||||
'%(title)s. Are you sure?')%dict(fmt=fmt, title=title))
|
'%(title)s. Are you sure?')%dict(fmt=fmt, title=title)) +
|
||||||
+'</p>', 'library_delete_specific_format', self.gui):
|
'</p>', 'library_delete_specific_format', self.gui):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.gui.library_view.model().db.remove_format(book_id, fmt,
|
self.gui.library_view.model().db.remove_format(book_id, fmt,
|
||||||
@ -240,8 +240,8 @@ class DeleteAction(InterfaceAction):
|
|||||||
return
|
return
|
||||||
if not confirm('<p>'+_('<b>All formats</b> for the selected books will '
|
if not confirm('<p>'+_('<b>All formats</b> for the selected books will '
|
||||||
'be <b>deleted</b> from your library.<br>'
|
'be <b>deleted</b> from your library.<br>'
|
||||||
'The book metadata will be kept. Are you sure?')
|
'The book metadata will be kept. Are you sure?') +
|
||||||
+'</p>', 'delete_all_formats', self.gui):
|
'</p>', 'delete_all_formats', self.gui):
|
||||||
return
|
return
|
||||||
db = self.gui.library_view.model().db
|
db = self.gui.library_view.model().db
|
||||||
removals = {}
|
removals = {}
|
||||||
@ -291,11 +291,18 @@ class DeleteAction(InterfaceAction):
|
|||||||
ids[model] = []
|
ids[model] = []
|
||||||
paths[model].append(path)
|
paths[model].append(path)
|
||||||
ids[model].append(id)
|
ids[model].append(id)
|
||||||
|
cv, row = self.gui.current_view(), -1
|
||||||
|
if cv is not self.gui.library_view:
|
||||||
|
row = cv.currentIndex().row()
|
||||||
for model in paths:
|
for model in paths:
|
||||||
job = self.gui.remove_paths(paths[model])
|
job = self.gui.remove_paths(paths[model])
|
||||||
self.delete_memory[job] = (paths[model], model)
|
self.delete_memory[job] = (paths[model], model)
|
||||||
|
|
||||||
model.mark_for_deletion(job, ids[model], rows_are_ids=True)
|
model.mark_for_deletion(job, ids[model], rows_are_ids=True)
|
||||||
self.gui.status_bar.show_message(_('Deleting books from device.'), 1000)
|
self.gui.status_bar.show_message(_('Deleting books from device.'), 1000)
|
||||||
|
if row > -1:
|
||||||
|
nrow = row - 1 if row > 0 else row + 1
|
||||||
|
cv.set_current_row(max(0, nrow))
|
||||||
|
|
||||||
def delete_covers(self, *args):
|
def delete_covers(self, *args):
|
||||||
ids = self._get_selected_ids()
|
ids = self._get_selected_ids()
|
||||||
@ -358,8 +365,8 @@ class DeleteAction(InterfaceAction):
|
|||||||
# The user has selected to delete from the library or the device and library.
|
# The user has selected to delete from the library or the device and library.
|
||||||
if not confirm('<p>'+_('The %d selected book(s) will be '
|
if not confirm('<p>'+_('The %d selected book(s) will be '
|
||||||
'<b>permanently deleted</b> and the files '
|
'<b>permanently deleted</b> and the files '
|
||||||
'removed from your calibre library. Are you sure?')%len(to_delete_ids)
|
'removed from your calibre library. Are you sure?')%len(to_delete_ids) +
|
||||||
+'</p>', 'library_delete_books', self.gui):
|
'</p>', 'library_delete_books', self.gui):
|
||||||
return
|
return
|
||||||
if len(to_delete_ids) < 5:
|
if len(to_delete_ids) < 5:
|
||||||
try:
|
try:
|
||||||
@ -392,6 +399,9 @@ class DeleteAction(InterfaceAction):
|
|||||||
self.do_library_delete(to_delete_ids)
|
self.do_library_delete(to_delete_ids)
|
||||||
# Device view is visible.
|
# Device view is visible.
|
||||||
else:
|
else:
|
||||||
|
cv, row = self.gui.current_view(), -1
|
||||||
|
if cv is not self.gui.library_view:
|
||||||
|
row = cv.currentIndex().row()
|
||||||
if self.gui.stack.currentIndex() == 1:
|
if self.gui.stack.currentIndex() == 1:
|
||||||
view = self.gui.memory_view
|
view = self.gui.memory_view
|
||||||
elif self.gui.stack.currentIndex() == 2:
|
elif self.gui.stack.currentIndex() == 2:
|
||||||
@ -402,11 +412,13 @@ class DeleteAction(InterfaceAction):
|
|||||||
ids = view.model().indices(rows)
|
ids = view.model().indices(rows)
|
||||||
if not confirm('<p>'+_('The %d selected book(s) will be '
|
if not confirm('<p>'+_('The %d selected book(s) will be '
|
||||||
'<b>permanently deleted</b> '
|
'<b>permanently deleted</b> '
|
||||||
'from your device. Are you sure?')%len(paths)
|
'from your device. Are you sure?')%len(paths) +
|
||||||
+'</p>', 'device_delete_books', self.gui):
|
'</p>', 'device_delete_books', self.gui):
|
||||||
return
|
return
|
||||||
job = self.gui.remove_paths(paths)
|
job = self.gui.remove_paths(paths)
|
||||||
self.delete_memory[job] = (paths, view.model())
|
self.delete_memory[job] = (paths, view.model())
|
||||||
view.model().mark_for_deletion(job, ids, rows_are_ids=True)
|
view.model().mark_for_deletion(job, ids, rows_are_ids=True)
|
||||||
self.gui.status_bar.show_message(_('Deleting books from device.'), 1000)
|
self.gui.status_bar.show_message(_('Deleting books from device.'), 1000)
|
||||||
|
if row > -1:
|
||||||
|
nrow = row - 1 if row > 0 else row + 1
|
||||||
|
cv.set_current_row(max(0, nrow))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user