mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
When adding empty books to the library also allow creating duplicates of the current book, with all metadata copied. To use right click the Add Books button and select 'Add Empty Books'. Fixes #1488398 [Enhancement: Create duplicate book record of existing one](https://bugs.launchpad.net/calibre/+bug/1488398)
This commit is contained in:
parent
20a4140c56
commit
ccc52ba308
@ -238,7 +238,7 @@ class AddAction(InterfaceAction):
|
||||
Add an empty book item to the library. This does not import any formats
|
||||
from a book file.
|
||||
'''
|
||||
author = series = None
|
||||
author = series = title = None
|
||||
index = self.gui.library_view.currentIndex()
|
||||
if index.isValid():
|
||||
raw = index.model().db.authors(index.row())
|
||||
@ -247,8 +247,9 @@ class AddAction(InterfaceAction):
|
||||
if authors:
|
||||
author = authors[0]
|
||||
series = index.model().db.series(index.row())
|
||||
title = index.model().db.title(index.row())
|
||||
dlg = AddEmptyBookDialog(self.gui, self.gui.library_view.model().db,
|
||||
author, series)
|
||||
author, series, dup_title=title)
|
||||
if dlg.exec_() == dlg.Accepted:
|
||||
temp_files = []
|
||||
num = dlg.qty_to_add
|
||||
@ -256,7 +257,12 @@ class AddAction(InterfaceAction):
|
||||
title = dlg.selected_title or _('Unknown')
|
||||
db = self.gui.library_view.model().db
|
||||
ids = []
|
||||
if dlg.duplicate_current_book:
|
||||
origmi = db.get_metadata(index.row(), get_cover=True, cover_as_data=True)
|
||||
for x in xrange(num):
|
||||
if dlg.duplicate_current_book:
|
||||
mi = origmi
|
||||
else:
|
||||
mi = MetaInformation(title, dlg.selected_authors)
|
||||
if series:
|
||||
mi.series = series
|
||||
|
@ -15,7 +15,7 @@ from calibre.gui2 import gprefs
|
||||
|
||||
class AddEmptyBookDialog(QDialog):
|
||||
|
||||
def __init__(self, parent, db, author, series=None, title=None):
|
||||
def __init__(self, parent, db, author, series=None, title=None, dup_title=None):
|
||||
QDialog.__init__(self, parent)
|
||||
self.db = db
|
||||
|
||||
@ -99,7 +99,20 @@ class AddEmptyBookDialog(QDialog):
|
||||
button_box.accepted.connect(self.accept)
|
||||
button_box.rejected.connect(self.reject)
|
||||
self._layout.addWidget(button_box, 10, 0, 1, -1)
|
||||
if dup_title:
|
||||
self.dup_button = b = button_box.addButton(_('&Duplicate current book'), button_box.ActionRole)
|
||||
b.clicked.connect(self.do_duplicate_book)
|
||||
b.setIcon(QIcon(I('edit-copy.png')))
|
||||
b.setToolTip(_(
|
||||
'Make the new empty book records exact duplicates\n'
|
||||
'of the current book "%s", with all metadata identical'
|
||||
) % dup_title)
|
||||
self.resize(self.sizeHint())
|
||||
self.duplicate_current_book = False
|
||||
|
||||
def do_duplicate_book(self):
|
||||
self.duplicate_current_book = True
|
||||
self.accept()
|
||||
|
||||
def accept(self):
|
||||
gprefs['create_empty_format_file'] = self.format_value.currentText().lower()
|
||||
|
Loading…
x
Reference in New Issue
Block a user