Remove doc word count from main statusbar, and added support for session word count for documents

This commit is contained in:
Veronica K. B. Olsen
2020-06-27 19:41:41 +02:00
parent 7d30a2c044
commit 243d9dd85a
4 changed files with 21 additions and 36 deletions
+11 -4
View File
@@ -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
+1
View File
@@ -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
+7 -16
View File
@@ -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)
+2 -16
View File
@@ -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<br>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,
))