EPUB Input: Handle ncx files that have <navpoint> elements with no content correctly. Fixes #7396 (calibre does not show TOC from attached epub file)

This commit is contained in:
Kovid Goyal 2010-11-03 10:05:26 -06:00
parent 219feadc1e
commit 908c0ce46e
2 changed files with 14 additions and 15 deletions

View File

@ -182,6 +182,7 @@ class TOC(list):
except:
play_order = 1
href = fragment = text = None
nd = dest
nl = nl_path(np)
if nl:
nl = nl[0]
@ -190,13 +191,10 @@ class TOC(list):
text += etree.tostring(txt, method='text',
encoding=unicode, with_tail=False)
content = content_path(np)
if not content or not text:
return
if content and text:
content = content[0]
src = get_attr(content, attr='src')
if src is None:
return
if src:
purl = urlparse(unquote(content.get('src')))
href, fragment = purl[2], purl[5]
nd = dest.add_item(href, fragment, text)

View File

@ -358,6 +358,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
def toc_clicked(self, index):
item = self.toc_model.itemFromIndex(index)
if item.abspath is not None:
url = QUrl.fromLocalFile(item.abspath)
if item.fragment:
url.setFragment(item.fragment)