mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 07:03:41 +02:00
Reset ondevice when books are deleted from the library or the device
This commit is contained in:
parent
1c3a69f19d
commit
351ff91d6a
2 changed files with 20 additions and 2 deletions
|
|
@ -199,7 +199,7 @@ def delete_books(self, indices):
|
|||
self.count_changed()
|
||||
self.clear_caches()
|
||||
self.reset()
|
||||
|
||||
return ids
|
||||
|
||||
def delete_books_by_id(self, ids):
|
||||
for id in ids:
|
||||
|
|
@ -881,6 +881,15 @@ def indices_to_be_deleted(self):
|
|||
ans.extend(v)
|
||||
return ans
|
||||
|
||||
def clear_ondevice(self, db_ids):
|
||||
for data in self.db:
|
||||
if data is None:
|
||||
continue
|
||||
app_id = getattr(data, 'application_id', None)
|
||||
if app_id is not None and app_id in db_ids:
|
||||
data.in_library = False
|
||||
self.reset()
|
||||
|
||||
def flags(self, index):
|
||||
if self.map[index.row()] in self.indices_to_be_deleted():
|
||||
return Qt.ItemIsUserCheckable # Can't figure out how to get the disabled flag in python
|
||||
|
|
|
|||
|
|
@ -1546,7 +1546,11 @@ def delete_books(self, *args):
|
|||
row = None
|
||||
if ci.isValid():
|
||||
row = ci.row()
|
||||
view.model().delete_books(rows)
|
||||
ids_deleted = view.model().delete_books(rows)
|
||||
for v in (self.memory_view, self.card_a_view, self.card_b_view):
|
||||
if v is None:
|
||||
continue
|
||||
v.model().clear_ondevice(ids_deleted)
|
||||
if row is not None:
|
||||
ci = view.model().index(row, 0)
|
||||
if ci.isValid():
|
||||
|
|
@ -1591,6 +1595,11 @@ def books_deleted(self, job):
|
|||
self.booklists())
|
||||
model.paths_deleted(paths)
|
||||
self.upload_booklists()
|
||||
# Clear the ondevice info so it will be recomputed
|
||||
self.book_on_device(None, None, reset=True)
|
||||
# We want to reset all the ondevice flags in the library. Use a big
|
||||
# hammer, so we don't need to worry about whether some succeeded or not
|
||||
self.library_view.model().refresh()
|
||||
|
||||
############################################################################
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue