diff --git a/nw/core/index.py b/nw/core/index.py index 4afa37ea..f94bbf3e 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -143,16 +143,11 @@ class NWIndex(): logger.error(str(e)) return False - if "tagIndex" in theData.keys(): - self.tagIndex = theData["tagIndex"] - if "refIndex" in theData.keys(): - self.refIndex = theData["refIndex"] - if "novelIndex" in theData.keys(): - self.novelIndex = theData["novelIndex"] - if "noteIndex" in theData.keys(): - self.noteIndex = theData["noteIndex"] - if "textCounts" in theData.keys(): - self.textCounts = theData["textCounts"] + self.tagIndex = theData.get("tagIndex", {}) + self.refIndex = theData.get("refIndex", {}) + self.novelIndex = theData.get("novelIndex", {}) + self.noteIndex = theData.get("noteIndex", {}) + self.textCounts = theData.get("textCounts", {}) nowTime = round(time()) self.timeNovel = nowTime @@ -221,6 +216,7 @@ class NWIndex(): except Exception: self.indexBroken = True + logger.debug("Index check complete") if self.indexBroken: self.clearIndex() self.theParent.makeAlert( @@ -593,8 +589,7 @@ class NWIndex(): return theRefs for refTitle in self.refIndex[tHandle]: - theTags = self.refIndex[tHandle][refTitle].get("tags", None) - for aTag in theTags: + for aTag in self.refIndex[tHandle][refTitle].get("tags", []): if len(aTag) == 3 and (sTitle is None or sTitle == refTitle): theRefs[aTag[1]].append(aTag[2]) diff --git a/nw/gui/outline.py b/nw/gui/outline.py index 55720a72..38046576 100644 --- a/nw/gui/outline.py +++ b/nw/gui/outline.py @@ -395,14 +395,19 @@ class GuiOutline(QTreeWidget): self.treeMap[titleKey] = tItem if tLevel == "H1": - currTitle = tItem self.addTopLevelItem(tItem) + currTitle = tItem + currChapter = None + currScene = None + elif tLevel == "H2": if currTitle is None: self.addTopLevelItem(tItem) else: currTitle.addChild(tItem) currChapter = tItem + currScene = None + elif tLevel == "H3": if currChapter is None: if currTitle is None: @@ -412,6 +417,7 @@ class GuiOutline(QTreeWidget): else: currChapter.addChild(tItem) currScene = tItem + elif tLevel == "H4": if currScene is None: if currChapter is None: diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py index 85025a15..0a6dce7f 100644 --- a/nw/gui/outlinedetails.py +++ b/nw/gui/outlinedetails.py @@ -329,7 +329,7 @@ class GuiOutlineDetails(QScrollArea): def _formatTags(self, theRefs, theKey): """Format the tags as clickable links. """ - if theKey not in theKey: + if theKey not in theRefs: return "" refTags = [] for tTag in theRefs[theKey]: