mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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.
This commit is contained in:
parent
ce5375db54
commit
93f98ee19c
@ -13,7 +13,8 @@ from contextlib import closing
|
|||||||
from PyQt4.Qt import QToolButton
|
from PyQt4.Qt import QToolButton
|
||||||
|
|
||||||
from calibre.gui2.actions import InterfaceAction
|
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.gui2.dialogs.progress import ProgressDialog
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from calibre.utils.date import now
|
from calibre.utils.date import now
|
||||||
@ -30,6 +31,7 @@ class Worker(Thread): # {{{
|
|||||||
self.progress = progress
|
self.progress = progress
|
||||||
self.done = done
|
self.done = done
|
||||||
self.delete_after = delete_after
|
self.delete_after = delete_after
|
||||||
|
self.auto_merged_ids = {}
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
@ -79,6 +81,8 @@ class Worker(Thread): # {{{
|
|||||||
if prefs['add_formats_to_existing']:
|
if prefs['add_formats_to_existing']:
|
||||||
identical_book_list = newdb.find_identical_books(mi)
|
identical_book_list = newdb.find_identical_books(mi)
|
||||||
if identical_book_list: # books with same author and nearly same title exist in newdb
|
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
|
automerged = True
|
||||||
seen_fmts = set()
|
seen_fmts = set()
|
||||||
for identical_book in identical_book_list:
|
for identical_book in identical_book_list:
|
||||||
@ -196,6 +200,15 @@ class CopyToLibraryAction(InterfaceAction):
|
|||||||
self.gui.status_bar.show_message(
|
self.gui.status_bar.show_message(
|
||||||
_('Copied %(num)d books to %(loc)s') %
|
_('Copied %(num)d books to %(loc)s') %
|
||||||
dict(num=len(ids), loc=loc), 2000)
|
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:
|
if delete_after and self.worker.processed:
|
||||||
v = self.gui.library_view
|
v = self.gui.library_view
|
||||||
ci = v.currentIndex()
|
ci = v.currentIndex()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user