Sorted user recipes in serialize_collection

This commit is contained in:
Starson17 2011-02-04 08:47:03 -05:00
parent 1fd2981689
commit 8c952c2c32
4 changed files with 28 additions and 7 deletions

View File

@ -50,6 +50,7 @@ gprefs.defaults['action-layout-context-menu-device'] = (
gprefs.defaults['show_splash_screen'] = True
gprefs.defaults['toolbar_icon_size'] = 'medium'
gprefs.defaults['automerge'] = 'ignore'
gprefs.defaults['toolbar_text'] = 'auto'
gprefs.defaults['show_child_bar'] = False
gprefs.defaults['font'] = None

View File

@ -8,7 +8,7 @@ from functools import partial
from PyQt4.Qt import QThread, QObject, Qt, QProgressDialog, pyqtSignal, QTimer
from calibre.gui2.dialogs.progress import ProgressDialog
from calibre.gui2 import question_dialog, error_dialog, info_dialog
from calibre.gui2 import question_dialog, error_dialog, info_dialog, gprefs
from calibre.ebooks.metadata.opf2 import OPF
from calibre.ebooks.metadata import MetaInformation
from calibre.constants import preferred_encoding, filesystem_encoding, DEBUG
@ -181,11 +181,21 @@ class DBAdder(QObject): # {{{
formats = [f for f in formats if not f.lower().endswith('.opf')]
if prefs['add_formats_to_existing']:
identical_book_list = self.db.find_identical_books(mi)
if identical_book_list: # books with same author and nearly same title exist in db
self.merged_books.add(mi.title)
for identical_book in identical_book_list:
self.add_formats(identical_book, formats, replace=False)
if gprefs['automerge'] == 'ignore':
self.add_formats(identical_book, formats, replace=False)
print 'do something for ignore'
if gprefs['automerge'] == 'overwrite':
self.add_formats(identical_book, formats, replace=True)
print 'do something for overwrite'
if gprefs['automerge'] == 'new record':
id = self.db.create_book_entry(mi, cover=cover, add_duplicates=True)
self.number_of_books_added += 1
self.add_formats(id, formats)
print 'do something for new record'
else:
id = self.db.create_book_entry(mi, cover=cover, add_duplicates=True)
self.number_of_books_added += 1

View File

@ -11,6 +11,7 @@ from calibre.gui2.preferences import ConfigWidgetBase, test_widget
from calibre.gui2.preferences.adding_ui import Ui_Form
from calibre.utils.config import prefs
from calibre.gui2.widgets import FilenamePattern
from calibre.gui2 import gprefs
class ConfigWidget(ConfigWidgetBase, Ui_Form):
@ -22,6 +23,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('read_file_metadata', prefs)
r('swap_author_names', prefs)
r('add_formats_to_existing', prefs)
choices = [(_('Ignore'), 'ignore'), (_('Overwrite'), 'overwrite'),
(_('New Record'), 'new record')]
r('automerge', gprefs, choices=choices)
#print 'The automerge setting is: ', gprefs['automerge']
self.filename_pattern = FilenamePattern(self)
self.metadata_box.layout().insertWidget(0, self.filename_pattern)

View File

@ -31,19 +31,24 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="2" column="0" colspan="1"> #MOD was colspan="2"
<widget class="QCheckBox" name="opt_add_formats_to_existing">
<property name="toolTip">
<string>If an existing book with a similar title and author is found that does not have the format being added, the format is added
to the existing book, instead of creating a new entry. If the existing book already has the format, then it is silently ignored.
<string>If an existing book with a similar title and author is found, the incoming format will be added to the existing book record where possible.
If the existing book already has the incoming format, then the setting to the right controls and the new format will be ignored, it will overwrite the old format
or a new record will be created.
Title match ignores leading indefinite articles (&quot;the&quot;, &quot;a&quot;, &quot;an&quot;), punctuation, case, etc. Author match is exact.</string>
</property>
<property name="text">
<string>If books with similar titles and authors found, &amp;merge the new files automatically</string>
<string>If books with similar titles and authors found, &amp;try to merge the new formats automatically
and do this for duplicate formats: </string>
</property>
</widget>
</item>
<item row="2" column="1"> #MOD added as new item
<widget class="QComboBox" name="opt_automerge"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="metadata_box">
<property name="title">