Fix bug that caused wrong books to be deleted from library if you choose delete from library and device while the library is sorted by the On device column

This commit is contained in:
Kovid Goyal 2011-03-01 23:37:54 -07:00
parent ab33907851
commit 4336d74ee9
2 changed files with 7 additions and 5 deletions

View File

@ -7,6 +7,7 @@ swiatczytnikow.pl
''' '''
import re import re
from calibre.web.feeds.news import BasicNewsRecipe
class swiatczytnikow(BasicNewsRecipe): class swiatczytnikow(BasicNewsRecipe):
title = u'Swiat Czytnikow' title = u'Swiat Czytnikow'

View File

@ -19,11 +19,11 @@ single_shot = partial(QTimer.singleShot, 10)
class MultiDeleter(QObject): class MultiDeleter(QObject):
def __init__(self, gui, rows, callback): def __init__(self, gui, ids, callback):
from calibre.gui2.dialogs.progress import ProgressDialog from calibre.gui2.dialogs.progress import ProgressDialog
QObject.__init__(self, gui) QObject.__init__(self, gui)
self.model = gui.library_view.model() self.model = gui.library_view.model()
self.ids = list(map(self.model.id, rows)) self.ids = ids
self.gui = gui self.gui = gui
self.failures = [] self.failures = []
self.deleted_ids = [] self.deleted_ids = []
@ -231,6 +231,7 @@ class DeleteAction(InterfaceAction):
return return
# Library view is visible. # Library view is visible.
if self.gui.stack.currentIndex() == 0: if self.gui.stack.currentIndex() == 0:
to_delete_ids = [view.model().id(r) for r in rows]
# Ask the user if they want to delete the book from the library or device if it is in both. # 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: if self.gui.device_manager.is_device_connected:
on_device = False on_device = False
@ -264,10 +265,10 @@ class DeleteAction(InterfaceAction):
if ci.isValid(): if ci.isValid():
row = ci.row() row = ci.row()
if len(rows) < 5: if len(rows) < 5:
ids_deleted = view.model().delete_books(rows) view.model().delete_books_by_id(to_delete_ids)
self.library_ids_deleted(ids_deleted, row) self.library_ids_deleted(to_delete_ids, row)
else: else:
self.__md = MultiDeleter(self.gui, rows, self.__md = MultiDeleter(self.gui, to_delete_ids,
partial(self.library_ids_deleted, current_row=row)) partial(self.library_ids_deleted, current_row=row))
# Device view is visible. # Device view is visible.
else: else: