From 9fc59262a995de9ca718f7ce2eb035ac7a3819ac Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 25 May 2019 23:16:27 +0200 Subject: [PATCH] Added project word count --- nw/gui/doceditor.py | 1 + nw/gui/doctree.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 59f6a7c7..c708536e 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -380,6 +380,7 @@ class GuiDocEditor(QTextEdit): self.paraCount = self.wCounter.paraCount self.theParent.statusBar.setCounts(self.charCount,self.wordCount,self.paraCount) self.theParent.treeView.propagateCount(tHandle, self.wordCount) + self.theParent.treeView.projectWordCount() return diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py index da074375..3e4176d0 100644 --- a/nw/gui/doctree.py +++ b/nw/gui/doctree.py @@ -50,7 +50,7 @@ class GuiDocTree(QTreeWidget): self.setExpandsOnDoubleClick(True) self.setIndentation(13) self.setColumnCount(4) - self.setHeaderLabels(["Name","Count","Flags","Handle"]) + self.setHeaderLabels(["Name","Words","Flags","Handle"]) if not self.debugGUI: self.hideColumn(self.C_HANDLE) @@ -286,6 +286,16 @@ class GuiDocTree(QTreeWidget): self.propagateCount(pHandle, pCount, nDepth+1) return + def projectWordCount(self): + nWords = 0 + for n in range(self.topLevelItemCount()): + tItem = self.topLevelItem(n) + if tItem == self.orphRoot: + continue + nWords += int(tItem.text(self.C_COUNT)) + self.theParent.statusBar.setStats(nWords,0) + return + def buildTree(self): self.clear() for nwItem in self.theProject.getProjectItems():