Merge branch 'kovidgoyal/master'

This commit is contained in:
Charles Haley 2013-07-11 09:52:26 +02:00
commit 8f221eecda
6 changed files with 31 additions and 20 deletions

View File

@ -279,7 +279,7 @@ class Convert(object):
self.styles.resolve_numbering(numbering)
def write(self, doc):
toc = create_toc(doc, self.body, self.resolved_link_map, self.styles, self.object_map)
toc = create_toc(doc, self.body, self.resolved_link_map, self.styles, self.object_map, self.log)
raw = html.tostring(self.html, encoding='utf-8', doctype='<!DOCTYPE html>')
with open(os.path.join(self.dest_dir, 'index.html'), 'wb') as f:
f.write(raw)

View File

@ -21,7 +21,7 @@ class Count(object):
def __init__(self):
self.val = 0
def from_headings(body):
def from_headings(body, log):
' Create a TOC from headings in the document '
headings = ('h1', 'h2', 'h3')
tocroot = TOC()
@ -58,6 +58,7 @@ def from_headings(body):
level_prev[i] = None
if len(tuple(tocroot.flat())) > 1:
log('Generating Table of Contents from headings')
return tocroot
def structure_toc(entries):
@ -98,7 +99,7 @@ def link_to_txt(a, styles, object_map):
return tostring(a, method='text', with_tail=False, encoding=unicode).strip()
def from_toc(docx, link_map, styles, object_map):
def from_toc(docx, link_map, styles, object_map, log):
toc_level = None
level = 0
TI = namedtuple('TI', 'text anchor indent')
@ -132,9 +133,10 @@ def from_toc(docx, link_map, styles, object_map):
ml = 0
toc.append(TI(txt, href[1:], ml))
if toc:
log('Found Word Table of Contents, using it to generate the Table of Contents')
return structure_toc(toc)
def create_toc(docx, body, link_map, styles, object_map):
return from_toc(docx, link_map, styles, object_map) or from_headings(body)
def create_toc(docx, body, link_map, styles, object_map, log):
return from_toc(docx, link_map, styles, object_map, log) or from_headings(body, log)

View File

@ -1,8 +1,10 @@
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
# vim:fileencoding=utf-8
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__copyright__ = '2013, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from calibre.gui2 import error_dialog

View File

@ -1,6 +1,10 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__copyright__ = '2013, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
@ -158,7 +162,7 @@ class MatchBooks(QDialog, Ui_MatchBooks):
self.save_state()
def book_clicked(self, row, column):
self.book_selected = True;
self.book_selected = True
id_ = self.books_table.item(row, 0).data(Qt.UserRole).toInt()[0]
self.current_library_book_id = id_
@ -195,3 +199,4 @@ class MatchBooks(QDialog, Ui_MatchBooks):
def reject(self):
self.close()
QDialog.reject(self)

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>768</width>
<width>751</width>
<height>342</height>
</rect>
</property>
@ -50,7 +50,7 @@
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel">
<widget class="QLabel" name="label">
<property name="text">
<string>Do a search to find the book you want to match</string>
</property>
@ -64,19 +64,21 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="columnCount">
<property name="rowCount">
<number>0</number>
</property>
<property name="rowCount">
<property name="columnCount">
<number>0</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;p&gt;Be sure to update metadata on the device when you are
finished matching books (Device -> Update Metadata)&lt;/p&gt;</string>
<string>&lt;p&gt;Remember to update metadata on the device when you are done (Right click the device icon and select &lt;i&gt;Update cached metadata&lt;/i&gt;)&lt;/p&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
@ -109,7 +111,6 @@
</item>
</layout>
</widget>
<resources/>
<customwidgets>
<customwidget>
<class>HistoryLineEdit</class>
@ -117,6 +118,7 @@
<header>calibre/gui2/widgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>

View File

@ -61,7 +61,7 @@ class LocationManager(QObject): # {{{
a = m.addAction(QIcon(I('config.png')), _('Configure this device'))
a.triggered.connect(self._configure_requested)
self._mem.append(a)
a = m.addAction(QIcon(I('sync.png')), _('Update metadata on device'))
a = m.addAction(QIcon(I('sync.png')), _('Update cached metadata on device'))
a.triggered.connect(lambda x : self.update_device_metadata.emit())
self._mem.append(a)