mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
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:
parent
1f2daebce6
commit
805d8c6223
@ -194,12 +194,11 @@ class TOC(list):
|
||||
content = content_path(np)
|
||||
if content and text:
|
||||
content = content[0]
|
||||
src = get_attr(content, attr='src')
|
||||
if src:
|
||||
purl = urlparse(content.get('src'))
|
||||
href, fragment = unquote(purl[2]), unquote(purl[5])
|
||||
nd = dest.add_item(href, fragment, text)
|
||||
nd.play_order = play_order
|
||||
# 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)
|
||||
nd.play_order = play_order
|
||||
|
||||
for c in np_path(np):
|
||||
process_navpoint(c, nd)
|
||||
|
@ -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
|
||||
try:
|
||||
am = getattr(spine[i], 'anchor_map', {})
|
||||
except UnboundLocalError:
|
||||
# Spine was empty?
|
||||
am = {}
|
||||
am = {}
|
||||
if self.abspath is not None:
|
||||
try:
|
||||
am = getattr(spine[i], 'anchor_map', {})
|
||||
except UnboundLocalError:
|
||||
# Spine was empty?
|
||||
pass
|
||||
frag = self.fragment if (self.fragment and self.fragment in am) else None
|
||||
self.starts_at = spos
|
||||
self.start_anchor = frag
|
||||
|
Loading…
x
Reference in New Issue
Block a user