From 32bcac2147ffa344fb58bcc97859b9452ee99ff8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 30 May 2011 22:49:13 -0600 Subject: [PATCH 1/2] When deleting all formats except ..., do not delete if it leaves a book with no formats --- src/calibre/gui2/actions/delete.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/actions/delete.py b/src/calibre/gui2/actions/delete.py index 718f0737b3..619a8a1031 100644 --- a/src/calibre/gui2/actions/delete.py +++ b/src/calibre/gui2/actions/delete.py @@ -161,9 +161,12 @@ class DeleteAction(InterfaceAction): continue bfmts = set([x.lower() for x in bfmts.split(',')]) rfmts = bfmts - set(fmts) - for fmt in rfmts: - self.gui.library_view.model().db.remove_format(id, fmt, - index_is_id=True, notify=False) + if bfmts - rfmts: + # Do not delete if it will leave the book with no + # formats + for fmt in rfmts: + self.gui.library_view.model().db.remove_format(id, fmt, + index_is_id=True, notify=False) self.gui.library_view.model().refresh_ids(ids) self.gui.library_view.model().current_changed(self.gui.library_view.currentIndex(), self.gui.library_view.currentIndex()) From 775c63bd39497eb7c5933b9ddaf91758e4ce20e8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 30 May 2011 22:53:15 -0600 Subject: [PATCH 2/2] ... --- src/calibre/gui2/actions/delete.py | 3 ++- src/calibre/gui2/dialogs/select_formats.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/actions/delete.py b/src/calibre/gui2/actions/delete.py index 619a8a1031..43465512e0 100644 --- a/src/calibre/gui2/actions/delete.py +++ b/src/calibre/gui2/actions/delete.py @@ -152,7 +152,8 @@ class DeleteAction(InterfaceAction): if not ids: return fmts = self._get_selected_formats( - '

'+_('Choose formats not to be deleted'), ids) + '

'+_('Choose formats not to be deleted.

Note that ' + 'this will never remove all formats from a book.'), ids) if fmts is None: return for id in ids: diff --git a/src/calibre/gui2/dialogs/select_formats.py b/src/calibre/gui2/dialogs/select_formats.py index 5934c8c0f9..aea56ad196 100644 --- a/src/calibre/gui2/dialogs/select_formats.py +++ b/src/calibre/gui2/dialogs/select_formats.py @@ -44,7 +44,7 @@ class SelectFormats(QDialog): self.setLayout(self._l) self.setWindowTitle(_('Choose formats')) self._m = QLabel(msg) - self._m.setWordWrap = True + self._m.setWordWrap(True) self._l.addWidget(self._m) self.formats = Formats(fmt_list) self.fview = QListView(self)