Some improvements to the word count update
This commit is contained in:
@@ -48,6 +48,7 @@ class GuiDocDetails(QFrame):
|
|||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.theProject = theProject
|
self.theProject = theProject
|
||||||
self.theTheme = theParent.theTheme
|
self.theTheme = theParent.theTheme
|
||||||
|
self.theHandle = None
|
||||||
|
|
||||||
self.mainBox = QGridLayout(self)
|
self.mainBox = QGridLayout(self)
|
||||||
self.mainBox.setVerticalSpacing(1)
|
self.mainBox.setVerticalSpacing(1)
|
||||||
@@ -193,9 +194,20 @@ class GuiDocDetails(QFrame):
|
|||||||
# Class Methods
|
# Class Methods
|
||||||
##
|
##
|
||||||
|
|
||||||
|
def updateCounts(self, tHandle, cC, wC, pC):
|
||||||
|
"""Just update the counts if the handle is the same as the one
|
||||||
|
we're already showing.
|
||||||
|
"""
|
||||||
|
if tHandle == self.theHandle:
|
||||||
|
self.cCountData.setText("{:n}".format(cC))
|
||||||
|
self.wCountData.setText("{:n}".format(wC))
|
||||||
|
self.pCountData.setText("{:n}".format(pC))
|
||||||
|
return
|
||||||
|
|
||||||
def updateViewBox(self, tHandle):
|
def updateViewBox(self, tHandle):
|
||||||
"""Populate the details box from a given handle.
|
"""Populate the details box from a given handle.
|
||||||
"""
|
"""
|
||||||
|
self.theHandle = tHandle
|
||||||
nwItem = self.theProject.projTree[tHandle]
|
nwItem = self.theProject.projTree[tHandle]
|
||||||
|
|
||||||
if nwItem is None:
|
if nwItem is None:
|
||||||
|
|||||||
@@ -300,15 +300,16 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
docText = self.getText()
|
docText = self.getText()
|
||||||
cursPos = self.getCursorPosition()
|
cursPos = self.getCursorPosition()
|
||||||
theItem = self.nwDocument.theItem
|
self.nwDocument.theItem.setCharCount(self.charCount)
|
||||||
theItem.setCharCount(self.charCount)
|
self.nwDocument.theItem.setWordCount(self.wordCount)
|
||||||
theItem.setWordCount(self.wordCount)
|
self.nwDocument.theItem.setParaCount(self.paraCount)
|
||||||
theItem.setParaCount(self.paraCount)
|
self.nwDocument.theItem.setCursorPos(cursPos)
|
||||||
theItem.setCursorPos(cursPos)
|
|
||||||
self.nwDocument.saveDocument(docText)
|
self.nwDocument.saveDocument(docText)
|
||||||
self.setDocumentChanged(False)
|
self.setDocumentChanged(False)
|
||||||
|
|
||||||
self.theParent.theIndex.scanText(theItem.itemHandle, docText)
|
self.theParent.theIndex.scanText(
|
||||||
|
self.nwDocument.theItem.itemHandle, docText
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -737,15 +738,24 @@ class GuiDocEditor(QTextEdit):
|
|||||||
def _updateCounts(self):
|
def _updateCounts(self):
|
||||||
"""Slot for the word counter's finished signal
|
"""Slot for the word counter's finished signal
|
||||||
"""
|
"""
|
||||||
|
if self.theHandle is None or self.nwDocument.theItem is None:
|
||||||
|
return
|
||||||
|
|
||||||
logger.verbose("Updating word count")
|
logger.verbose("Updating word count")
|
||||||
|
|
||||||
tHandle = self.nwDocument.docHandle
|
|
||||||
self.charCount = self.wCounter.charCount
|
self.charCount = self.wCounter.charCount
|
||||||
self.wordCount = self.wCounter.wordCount
|
self.wordCount = self.wCounter.wordCount
|
||||||
self.paraCount = self.wCounter.paraCount
|
self.paraCount = self.wCounter.paraCount
|
||||||
self.theParent.statusBar.setCounts(self.charCount,self.wordCount,self.paraCount)
|
self.nwDocument.theItem.setCharCount(self.charCount)
|
||||||
self.theParent.treeView.propagateCount(tHandle, self.wordCount)
|
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.treeView.projectWordCount()
|
||||||
|
self.theParent.treeMeta.updateCounts(
|
||||||
|
self.theHandle, self.charCount, self.wordCount, self.paraCount
|
||||||
|
)
|
||||||
self._checkDocSize(self.charCount)
|
self._checkDocSize(self.charCount)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
+1
-1
@@ -205,7 +205,7 @@ class GuiMainStatus(QStatusBar):
|
|||||||
"""Update statistics.
|
"""Update statistics.
|
||||||
"""
|
"""
|
||||||
self.statsText.setToolTip(
|
self.statsText.setToolTip(
|
||||||
"D: Document word count<br>P: Project word count"
|
"D: Document word count<br>P: Project word count (session change)"
|
||||||
)
|
)
|
||||||
self.statsText.setText((
|
self.statsText.setText((
|
||||||
"D:{wC:n} P:{pWC:n} ({sWC:+n})"
|
"D:{wC:n} P:{pWC:n} ({sWC:+n})"
|
||||||
|
|||||||
Reference in New Issue
Block a user