Merge from trunk

This commit is contained in:
Charles Haley 2010-09-02 15:32:11 +01:00
commit c7acbc1b07
6 changed files with 42 additions and 13 deletions

View File

@ -62,7 +62,16 @@ class HTMLTOCAdder(object):
def __call__(self, oeb, context): def __call__(self, oeb, context):
if 'toc' in oeb.guide: if 'toc' in oeb.guide:
return # Ensure toc pointed to in <guide> is in spine
from calibre.ebooks.oeb.base import urlnormalize
href = urlnormalize(oeb.guide['toc'].href)
if href in oeb.manifest.hrefs:
item = oeb.manifest.hrefs[href]
if oeb.spine.index(item) < 0:
oeb.spine.add(item, linear=False)
return
else:
oeb.guide.remove('toc')
if not getattr(getattr(oeb, 'toc', False), 'nodes', False): if not getattr(getattr(oeb, 'toc', False), 'nodes', False):
return return
oeb.logger.info('Generating in-line TOC...') oeb.logger.info('Generating in-line TOC...')

View File

@ -66,7 +66,8 @@ class Worker(Thread):
for identical_book in identical_book_list: for identical_book in identical_book_list:
self.add_formats(identical_book, paths, newdb, replace=False) self.add_formats(identical_book, paths, newdb, replace=False)
if not added: if not added:
newdb.import_book(mi, paths, notify=False, import_hooks=False) newdb.import_book(mi, paths, notify=False, import_hooks=False,
apply_import_tags=False)
co = self.db.conversion_options(x, 'PIPE') co = self.db.conversion_options(x, 'PIPE')
if co is not None: if co is not None:
newdb.set_conversion_options(x, 'PIPE', co) newdb.set_conversion_options(x, 'PIPE', co)

View File

@ -457,7 +457,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
self.priority.setCurrentIndex(p) self.priority.setCurrentIndex(p)
self.priority.setVisible(iswindows) self.priority.setVisible(iswindows)
self.priority_label.setVisible(iswindows) self.priority_label.setVisible(iswindows)
self.new_book_tags.setText(prefs['new_book_tags']) self.new_book_tags.setText(', '.join(prefs['new_book_tags']))
self._plugin_model = PluginModel() self._plugin_model = PluginModel()
self.plugin_view.setModel(self._plugin_model) self.plugin_view.setModel(self._plugin_model)
self.plugin_view.setStyleSheet( self.plugin_view.setStyleSheet(
@ -907,7 +907,9 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
config['disable_tray_notification'] = not self.systray_notifications.isChecked() config['disable_tray_notification'] = not self.systray_notifications.isChecked()
p = {0:'normal', 1:'high', 2:'low'}[self.priority.currentIndex()] p = {0:'normal', 1:'high', 2:'low'}[self.priority.currentIndex()]
prefs['worker_process_priority'] = p prefs['worker_process_priority'] = p
prefs['new_book_tags'] = unicode(self.new_book_tags.text()).strip() nbt = [x.strip() for x in
unicode(self.new_book_tags.text()).strip().split(',')]
prefs['new_book_tags'] = [x for x in nbt if x]
prefs['output_format'] = unicode(self.output_format.currentText()).upper() prefs['output_format'] = unicode(self.output_format.currentText()).upper()
config['cover_flow_queue_length'] = self.cover_browse.value() config['cover_flow_queue_length'] = self.cover_browse.value()
prefs['language'] = str(self.language.itemData(self.language.currentIndex()).toString()) prefs['language'] = str(self.language.itemData(self.language.currentIndex()).toString())

View File

@ -164,6 +164,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1">
<widget class="QLineEdit" name="opt_new_book_tags">
<property name="toolTip">
<string>A comma-separated list of tags that will be applied to books added to the library</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_230">
<property name="text">
<string>Tags to apply when adding a book:</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="6" column="0" colspan="2">

View File

@ -1726,13 +1726,14 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
return run_plugins_on_import(path, format) return run_plugins_on_import(path, format)
def _add_newbook_tag(self, mi): def _add_newbook_tag(self, mi):
tags = prefs['new_book_tags'].strip() tags = prefs['new_book_tags']
if tags: if tags:
for tag in [t.strip() for t in tags.split(',')]: for tag in [t.strip() for t in tags]:
if mi.tags is None: if tag:
mi.tags = [tag] if mi.tags is None:
else: mi.tags = [tag]
mi.tags.append(tag) else:
mi.tags.append(tag)
def create_book_entry(self, mi, cover=None, add_duplicates=True): def create_book_entry(self, mi, cover=None, add_duplicates=True):
self._add_newbook_tag(mi) self._add_newbook_tag(mi)
@ -1813,9 +1814,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
return (paths, formats, metadata), len(ids) return (paths, formats, metadata), len(ids)
return None, len(ids) return None, len(ids)
def import_book(self, mi, formats, notify=True, import_hooks=True): def import_book(self, mi, formats, notify=True, import_hooks=True,
apply_import_tags=True):
series_index = 1.0 if mi.series_index is None else mi.series_index series_index = 1.0 if mi.series_index is None else mi.series_index
self._add_newbook_tag(mi) if apply_import_tags:
self._add_newbook_tag(mi)
if not mi.title: if not mi.title:
mi.title = _('Unknown') mi.title = _('Unknown')
if not mi.authors: if not mi.authors:

View File

@ -717,7 +717,7 @@ def _prefs():
c.add_opt('add_formats_to_existing', default=False, c.add_opt('add_formats_to_existing', default=False,
help=_('Add new formats to existing book records')) help=_('Add new formats to existing book records'))
c.add_opt('installation_uuid', default=None, help='Installation UUID') c.add_opt('installation_uuid', default=None, help='Installation UUID')
c.add_opt('new_book_tags', default='', help=_('Tags to apply to books added to the library')) c.add_opt('new_book_tags', default=[], help=_('Tags to apply to books added to the library'))
# these are here instead of the gui preferences because calibredb and # these are here instead of the gui preferences because calibredb and
# calibre server can execute searches # calibre server can execute searches