When deleting all formats except ..., do not delete if it leaves a book with no formats

This commit is contained in:
Kovid Goyal 2011-05-30 22:49:13 -06:00
parent 5f1b681549
commit 32bcac2147

View File

@ -161,6 +161,9 @@ class DeleteAction(InterfaceAction):
continue continue
bfmts = set([x.lower() for x in bfmts.split(',')]) bfmts = set([x.lower() for x in bfmts.split(',')])
rfmts = bfmts - set(fmts) rfmts = bfmts - set(fmts)
if bfmts - rfmts:
# Do not delete if it will leave the book with no
# formats
for fmt in rfmts: for fmt in rfmts:
self.gui.library_view.model().db.remove_format(id, fmt, self.gui.library_view.model().db.remove_format(id, fmt,
index_is_id=True, notify=False) index_is_id=True, notify=False)