Remove doc word count from main statusbar, and added support for session word count for documents
This commit is contained in:
+11
-4
@@ -53,10 +53,11 @@ class NWItem():
|
|||||||
self.isExported = True
|
self.isExported = True
|
||||||
|
|
||||||
# Document Meta Data
|
# Document Meta Data
|
||||||
self.charCount = 0
|
self.charCount = 0 # Current character count
|
||||||
self.wordCount = 0
|
self.wordCount = 0 # Current word count
|
||||||
self.paraCount = 0
|
self.paraCount = 0 # Current paragraph count
|
||||||
self.cursorPos = 0
|
self.initCount = 0 # Initial word count
|
||||||
|
self.cursorPos = 0 # Last cursor position
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -274,4 +275,10 @@ class NWItem():
|
|||||||
self.cursorPos = checkInt(thePosition, 0)
|
self.cursorPos = checkInt(thePosition, 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def saveInitialCount(self):
|
||||||
|
"""Set the initial word count.
|
||||||
|
"""
|
||||||
|
self.initCount = self.wordCount
|
||||||
|
return
|
||||||
|
|
||||||
# END Class NWItem
|
# END Class NWItem
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ class NWTree():
|
|||||||
nwItem = NWItem(self.theProject)
|
nwItem = NWItem(self.theProject)
|
||||||
if nwItem.unpackXML(xItem):
|
if nwItem.unpackXML(xItem):
|
||||||
self.append(nwItem.itemHandle, nwItem.parHandle, nwItem)
|
self.append(nwItem.itemHandle, nwItem.parHandle, nwItem)
|
||||||
|
nwItem.saveInitialCount()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
+7
-16
@@ -769,7 +769,6 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.nwDocument.theItem.setWordCount(self.wordCount)
|
self.nwDocument.theItem.setWordCount(self.wordCount)
|
||||||
self.nwDocument.theItem.setParaCount(self.paraCount)
|
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.propagateCount(self.theHandle, self.wordCount)
|
||||||
self.theParent.treeView.projectWordCount()
|
self.theParent.treeView.projectWordCount()
|
||||||
self.theParent.treeMeta.updateCounts(
|
self.theParent.treeMeta.updateCounts(
|
||||||
@@ -1845,9 +1844,7 @@ class GuiDocEditFooter(QWidget):
|
|||||||
self.theProject = docEditor.theProject
|
self.theProject = docEditor.theProject
|
||||||
self.theTheme = docEditor.theTheme
|
self.theTheme = docEditor.theTheme
|
||||||
self.optState = docEditor.theProject.optState
|
self.optState = docEditor.theProject.optState
|
||||||
|
self.theHandle = None
|
||||||
self.theHandle = None
|
|
||||||
self.initWords = 0
|
|
||||||
|
|
||||||
# Make a QPalette that matches the Syntax Theme
|
# Make a QPalette that matches the Syntax Theme
|
||||||
self.thePalette = QPalette()
|
self.thePalette = QPalette()
|
||||||
@@ -1927,15 +1924,7 @@ class GuiDocEditFooter(QWidget):
|
|||||||
"""Set the handle that will populate the footer's data.
|
"""Set the handle that will populate the footer's data.
|
||||||
"""
|
"""
|
||||||
self.theHandle = tHandle
|
self.theHandle = tHandle
|
||||||
|
|
||||||
nwItem = self.theProject.projTree[self.theHandle]
|
|
||||||
if nwItem is None:
|
|
||||||
self.initWords = 0
|
|
||||||
else:
|
|
||||||
self.initWords = nwItem.wordCount
|
|
||||||
|
|
||||||
self.updateInfo()
|
self.updateInfo()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def updateInfo(self):
|
def updateInfo(self):
|
||||||
@@ -1947,9 +1936,8 @@ class GuiDocEditFooter(QWidget):
|
|||||||
sText = ""
|
sText = ""
|
||||||
wCount = 0
|
wCount = 0
|
||||||
wDiff = 0
|
wDiff = 0
|
||||||
|
|
||||||
else:
|
else:
|
||||||
wCount = nwItem.wordCount
|
|
||||||
wDiff = wCount - self.initWords
|
|
||||||
iStatus = nwItem.itemStatus
|
iStatus = nwItem.itemStatus
|
||||||
if nwItem.itemClass == nwItemClass.NOVEL:
|
if nwItem.itemClass == nwItemClass.NOVEL:
|
||||||
iStatus = self.theProject.statusItems.checkEntry(iStatus)
|
iStatus = self.theProject.statusItems.checkEntry(iStatus)
|
||||||
@@ -1957,8 +1945,11 @@ class GuiDocEditFooter(QWidget):
|
|||||||
else:
|
else:
|
||||||
iStatus = self.theProject.importItems.checkEntry(iStatus)
|
iStatus = self.theProject.importItems.checkEntry(iStatus)
|
||||||
theIcon = self.theParent.importIcons[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.statusIcon.setPixmap(sIcon)
|
||||||
self.statusText.setText(sText)
|
self.statusText.setText(sText)
|
||||||
|
|||||||
+2
-16
@@ -51,9 +51,6 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.theTheme = theParent.theTheme
|
self.theTheme = theParent.theTheme
|
||||||
self.refTime = None
|
self.refTime = None
|
||||||
|
|
||||||
self.charCount = 0
|
|
||||||
self.wordCount = 0
|
|
||||||
self.paraCount = 0
|
|
||||||
self.projWords = 0
|
self.projWords = 0
|
||||||
self.sessWords = 0
|
self.sessWords = 0
|
||||||
|
|
||||||
@@ -134,7 +131,6 @@ class GuiMainStatus(QStatusBar):
|
|||||||
"""
|
"""
|
||||||
self.setRefTime(None)
|
self.setRefTime(None)
|
||||||
self.setStats(0, 0)
|
self.setStats(0, 0)
|
||||||
self.setCounts(0, 0, 0)
|
|
||||||
self.setProjectStatus(None)
|
self.setProjectStatus(None)
|
||||||
self.setDocumentStatus(None)
|
self.setDocumentStatus(None)
|
||||||
self._updateTime()
|
self._updateTime()
|
||||||
@@ -186,15 +182,6 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self._updateStats()
|
self._updateStats()
|
||||||
return
|
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
|
# Internal Functions
|
||||||
##
|
##
|
||||||
@@ -203,12 +190,11 @@ class GuiMainStatus(QStatusBar):
|
|||||||
"""Update statistics.
|
"""Update statistics.
|
||||||
"""
|
"""
|
||||||
self.statsText.setToolTip(
|
self.statsText.setToolTip(
|
||||||
"D: Document word count<br>P: Project word count (session change)"
|
"Project word count (session change)"
|
||||||
)
|
)
|
||||||
self.statsText.setText((
|
self.statsText.setText((
|
||||||
"D:{wC:n} P:{pWC:n} ({sWC:+n})"
|
"Words: {pWC:n} ({sWC:+n})"
|
||||||
).format(
|
).format(
|
||||||
wC = self.wordCount,
|
|
||||||
pWC = self.projWords,
|
pWC = self.projWords,
|
||||||
sWC = self.sessWords,
|
sWC = self.sessWords,
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user