diff --git a/nw/core/item.py b/nw/core/item.py index 4dd9ddb9..0eb4ef26 100644 --- a/nw/core/item.py +++ b/nw/core/item.py @@ -53,10 +53,11 @@ class NWItem(): self.isExported = True # Document Meta Data - self.charCount = 0 - self.wordCount = 0 - self.paraCount = 0 - self.cursorPos = 0 + self.charCount = 0 # Current character count + self.wordCount = 0 # Current word count + self.paraCount = 0 # Current paragraph count + self.initCount = 0 # Initial word count + self.cursorPos = 0 # Last cursor position return @@ -274,4 +275,10 @@ class NWItem(): self.cursorPos = checkInt(thePosition, 0) return + def saveInitialCount(self): + """Set the initial word count. + """ + self.initCount = self.wordCount + return + # END Class NWItem diff --git a/nw/core/tree.py b/nw/core/tree.py index beb5d2e3..e786a727 100644 --- a/nw/core/tree.py +++ b/nw/core/tree.py @@ -134,6 +134,7 @@ class NWTree(): nwItem = NWItem(self.theProject) if nwItem.unpackXML(xItem): self.append(nwItem.itemHandle, nwItem.parHandle, nwItem) + nwItem.saveInitialCount() return True diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 4b74bb1b..e412d902 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -769,7 +769,6 @@ class GuiDocEditor(QTextEdit): self.nwDocument.theItem.setWordCount(self.wordCount) self.nwDocument.theItem.setParaCount(self.paraCount) - self.theParent.statusBar.setCounts(self.charCount, self.wordCount, self.paraCount) self.theParent.treeView.propagateCount(self.theHandle, self.wordCount) self.theParent.treeView.projectWordCount() self.theParent.treeMeta.updateCounts( @@ -1845,9 +1844,7 @@ class GuiDocEditFooter(QWidget): self.theProject = docEditor.theProject self.theTheme = docEditor.theTheme self.optState = docEditor.theProject.optState - - self.theHandle = None - self.initWords = 0 + self.theHandle = None # Make a QPalette that matches the Syntax Theme self.thePalette = QPalette() @@ -1927,15 +1924,7 @@ class GuiDocEditFooter(QWidget): """Set the handle that will populate the footer's data. """ self.theHandle = tHandle - - nwItem = self.theProject.projTree[self.theHandle] - if nwItem is None: - self.initWords = 0 - else: - self.initWords = nwItem.wordCount - self.updateInfo() - return def updateInfo(self): @@ -1947,9 +1936,8 @@ class GuiDocEditFooter(QWidget): sText = "" wCount = 0 wDiff = 0 + else: - wCount = nwItem.wordCount - wDiff = wCount - self.initWords iStatus = nwItem.itemStatus if nwItem.itemClass == nwItemClass.NOVEL: iStatus = self.theProject.statusItems.checkEntry(iStatus) @@ -1957,8 +1945,11 @@ class GuiDocEditFooter(QWidget): else: iStatus = self.theProject.importItems.checkEntry(iStatus) theIcon = self.theParent.importIcons[iStatus] - sIcon = theIcon.pixmap(self.sPx, self.sPx) - sText = nwItem.itemStatus + + sIcon = theIcon.pixmap(self.sPx, self.sPx) + sText = nwItem.itemStatus + wCount = nwItem.wordCount + wDiff = wCount - nwItem.initCount self.statusIcon.setPixmap(sIcon) self.statusText.setText(sText) diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py index c851a218..040125aa 100644 --- a/nw/gui/statusbar.py +++ b/nw/gui/statusbar.py @@ -51,9 +51,6 @@ class GuiMainStatus(QStatusBar): self.theTheme = theParent.theTheme self.refTime = None - self.charCount = 0 - self.wordCount = 0 - self.paraCount = 0 self.projWords = 0 self.sessWords = 0 @@ -134,7 +131,6 @@ class GuiMainStatus(QStatusBar): """ self.setRefTime(None) self.setStats(0, 0) - self.setCounts(0, 0, 0) self.setProjectStatus(None) self.setDocumentStatus(None) self._updateTime() @@ -186,15 +182,6 @@ class GuiMainStatus(QStatusBar): self._updateStats() return - def setCounts(self, cC, wC, pC): - """Set the current document statistics. - """ - self.charCount = cC - self.wordCount = wC - self.paraCount = pC - self._updateStats() - return - ## # Internal Functions ## @@ -203,12 +190,11 @@ class GuiMainStatus(QStatusBar): """Update statistics. """ self.statsText.setToolTip( - "D: Document word count
P: Project word count (session change)" + "Project word count (session change)" ) self.statsText.setText(( - "D:{wC:n} P:{pWC:n} ({sWC:+n})" + "Words: {pWC:n} ({sWC:+n})" ).format( - wC = self.wordCount, pWC = self.projWords, sWC = self.sessWords, ))