mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Reset ondevice when books are deleted from the library or the device
This commit is contained in:
parent
1c3a69f19d
commit
351ff91d6a
@ -199,7 +199,7 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
self.count_changed()
|
self.count_changed()
|
||||||
self.clear_caches()
|
self.clear_caches()
|
||||||
self.reset()
|
self.reset()
|
||||||
|
return ids
|
||||||
|
|
||||||
def delete_books_by_id(self, ids):
|
def delete_books_by_id(self, ids):
|
||||||
for id in ids:
|
for id in ids:
|
||||||
@ -881,6 +881,15 @@ class DeviceBooksModel(BooksModel): # {{{
|
|||||||
ans.extend(v)
|
ans.extend(v)
|
||||||
return ans
|
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):
|
def flags(self, index):
|
||||||
if self.map[index.row()] in self.indices_to_be_deleted():
|
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
|
return Qt.ItemIsUserCheckable # Can't figure out how to get the disabled flag in python
|
||||||
|
@ -1546,7 +1546,11 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
row = None
|
row = None
|
||||||
if ci.isValid():
|
if ci.isValid():
|
||||||
row = ci.row()
|
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:
|
if row is not None:
|
||||||
ci = view.model().index(row, 0)
|
ci = view.model().index(row, 0)
|
||||||
if ci.isValid():
|
if ci.isValid():
|
||||||
@ -1591,6 +1595,11 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.booklists())
|
self.booklists())
|
||||||
model.paths_deleted(paths)
|
model.paths_deleted(paths)
|
||||||
self.upload_booklists()
|
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…
x
Reference in New Issue
Block a user