diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 91a4b255..fb2a07e6 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -416,9 +416,7 @@ class GuiDocEditor(QTextEdit): self.theIndex.scanText(tHandle, docText) if self._updateHeaders(checkLevel=True): - if self.theParent.projTabs.currentIndex() == self.theParent.idxNovelView: - logger.verbose("Document headers have changed, updating novel tree") - self.theParent.novelView.refreshTree() + self.theParent.requestNovelTreeRefresh() else: self.theParent.novelView.updateWordCounts(tHandle) diff --git a/nw/gui/noveltree.py b/nw/gui/noveltree.py index 7a7990f8..0ceaf9ec 100644 --- a/nw/gui/noveltree.py +++ b/nw/gui/noveltree.py @@ -131,10 +131,11 @@ class GuiNovelTree(QTreeWidget): def refreshTree(self, overRide=False): """Called whenever the Novel tab is activated. """ + logger.verbose("Requesting refresh of the novel tree") treeChanged = self.theParent.treeView.changedSince(self._lastBuild) indexChanged = self.theIndex.novelChangedSince(self._lastBuild) if not (treeChanged or indexChanged): - logger.verbose("No changes made to the novel") + logger.verbose("No changes have been made to the novel index") return selItem = self.selectedItems() diff --git a/nw/guimain.py b/nw/guimain.py index f6538bf0..3500f87a 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -817,6 +817,14 @@ class GuiMain(QMainWindow): self.novelView.refreshTree() return + def requestNovelTreeRefresh(self): + """Update the novel tree, but only if it is visible. + """ + if self.projTabs.currentIndex() == self.idxNovelView and self.hasProject: + self.novelView.refreshTree() + return True + return False + def rebuildIndex(self, beQuiet=False): """Rebuild the entire index. """