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)
|
content = content_path(np)
|
||||||
if content and text:
|
if content and text:
|
||||||
content = content[0]
|
content = content[0]
|
||||||
src = get_attr(content, attr='src')
|
# if get_attr(content, attr='src'):
|
||||||
if src:
|
purl = urlparse(content.get('src'))
|
||||||
purl = urlparse(content.get('src'))
|
href, fragment = unquote(purl[2]), unquote(purl[5])
|
||||||
href, fragment = unquote(purl[2]), unquote(purl[5])
|
nd = dest.add_item(href, fragment, text)
|
||||||
nd = dest.add_item(href, fragment, text)
|
nd.play_order = play_order
|
||||||
nd.play_order = play_order
|
|
||||||
|
|
||||||
for c in np_path(np):
|
for c in np_path(np):
|
||||||
process_navpoint(c, nd)
|
process_navpoint(c, nd)
|
||||||
|
@ -56,7 +56,7 @@ class TOCItem(QStandardItem):
|
|||||||
self.title = text
|
self.title = text
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
QStandardItem.__init__(self, text if text else '')
|
QStandardItem.__init__(self, text if text else '')
|
||||||
self.abspath = toc.abspath
|
self.abspath = toc.abspath if toc.href else None
|
||||||
self.fragment = toc.fragment
|
self.fragment = toc.fragment
|
||||||
all_items.append(self)
|
all_items.append(self)
|
||||||
self.bold_font = QFont(self.font())
|
self.bold_font = QFont(self.font())
|
||||||
@ -70,11 +70,13 @@ class TOCItem(QStandardItem):
|
|||||||
if si == self.abspath:
|
if si == self.abspath:
|
||||||
spos = i
|
spos = i
|
||||||
break
|
break
|
||||||
try:
|
am = {}
|
||||||
am = getattr(spine[i], 'anchor_map', {})
|
if self.abspath is not None:
|
||||||
except UnboundLocalError:
|
try:
|
||||||
# Spine was empty?
|
am = getattr(spine[i], 'anchor_map', {})
|
||||||
am = {}
|
except UnboundLocalError:
|
||||||
|
# Spine was empty?
|
||||||
|
pass
|
||||||
frag = self.fragment if (self.fragment and self.fragment in am) else None
|
frag = self.fragment if (self.fragment and self.fragment in am) else None
|
||||||
self.starts_at = spos
|
self.starts_at = spos
|
||||||
self.start_anchor = frag
|
self.start_anchor = frag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user