From 93f98ee19c2324107abb9ff79e3a0cdbe244a01b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 22 Mar 2012 10:15:06 +0530 Subject: [PATCH] Copy to Library: If books were auto merged by the copy to library process, popup a message telling the user about it, as otherwise some people forget they have turned on auto merge and accuse calibre of losing their books. --- src/calibre/gui2/actions/copy_to_library.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/actions/copy_to_library.py b/src/calibre/gui2/actions/copy_to_library.py index dd25b83d50..abc10c2d76 100644 --- a/src/calibre/gui2/actions/copy_to_library.py +++ b/src/calibre/gui2/actions/copy_to_library.py @@ -13,7 +13,8 @@ from contextlib import closing from PyQt4.Qt import QToolButton from calibre.gui2.actions import InterfaceAction -from calibre.gui2 import error_dialog, Dispatcher, warning_dialog, gprefs +from calibre.gui2 import (error_dialog, Dispatcher, warning_dialog, gprefs, + info_dialog) from calibre.gui2.dialogs.progress import ProgressDialog from calibre.utils.config import prefs, tweaks from calibre.utils.date import now @@ -30,6 +31,7 @@ class Worker(Thread): # {{{ self.progress = progress self.done = done self.delete_after = delete_after + self.auto_merged_ids = {} def run(self): try: @@ -79,6 +81,8 @@ class Worker(Thread): # {{{ if prefs['add_formats_to_existing']: identical_book_list = newdb.find_identical_books(mi) if identical_book_list: # books with same author and nearly same title exist in newdb + self.auto_merged_ids[x] = _('%s by %s')%(mi.title, + mi.format_field('authors')[1]) automerged = True seen_fmts = set() for identical_book in identical_book_list: @@ -196,6 +200,15 @@ class CopyToLibraryAction(InterfaceAction): self.gui.status_bar.show_message( _('Copied %(num)d books to %(loc)s') % dict(num=len(ids), loc=loc), 2000) + if self.worker.auto_merged_ids: + books = '\n'.join(self.worker.auto_merged_ids.itervalues()) + info_dialog(self.gui, _('Auto merged'), + _('Some books were automatically merged into existing ' + 'records in the target library. Click Show ' + 'details to see which ones. This behavior is ' + 'controlled by the Auto merge option in ' + 'Preferences->Adding books.'), det_msg=books, + show=True) if delete_after and self.worker.processed: v = self.gui.library_view ci = v.currentIndex()