E-book viewer: Allow entries in the Table of Contents that do not point anywhere, instead of just ignoring them.

This commit is contained in:
Kovid Goyal 2013-01-18 20:00:23 +05:30
parent 1f2daebce6
commit 805d8c6223
2 changed files with 13 additions and 12 deletions

View File

@ -194,8 +194,7 @@ class TOC(list):
content = content_path(np)
if content and text:
content = content[0]
src = get_attr(content, attr='src')
if src:
# if get_attr(content, attr='src'):
purl = urlparse(content.get('src'))
href, fragment = unquote(purl[2]), unquote(purl[5])
nd = dest.add_item(href, fragment, text)

View File

@ -56,7 +56,7 @@ class TOCItem(QStandardItem):
self.title = text
self.parent = parent
QStandardItem.__init__(self, text if text else '')
self.abspath = toc.abspath
self.abspath = toc.abspath if toc.href else None
self.fragment = toc.fragment
all_items.append(self)
self.bold_font = QFont(self.font())
@ -70,11 +70,13 @@ class TOCItem(QStandardItem):
if si == self.abspath:
spos = i
break
am = {}
if self.abspath is not None:
try:
am = getattr(spine[i], 'anchor_map', {})
except UnboundLocalError:
# Spine was empty?
am = {}
pass
frag = self.fragment if (self.fragment and self.fragment in am) else None
self.starts_at = spos
self.start_anchor = frag