Project tree status and total word count changes (#882)

* Fix some inconsistencies in source file docstrings
* Remove the option to show status text in project tree
* Change how total word counts are calculated and propagated
* Fix tests and improve coverage
* Add setting in preferences
* Add missing word count timer to config file
This commit is contained in:
Veronica Berglyd Olsen
2021-09-10 00:38:45 +02:00
committed by GitHub
parent b9311e84ce
commit 3c8cb34b0a
19 changed files with 246 additions and 134 deletions
+24 -3
View File
@@ -124,7 +124,7 @@ class GuiMain(QMainWindow):
self.treeView.itemSelectionChanged.connect(self._treeSingleClick)
self.treeView.itemDoubleClicked.connect(self._treeDoubleClick)
self.treeView.novelItemChanged.connect(self._treeNovelItemChanged)
self.treeView.projectWordCountChanged.connect(self.statusBar.doUpdateProjectStats)
self.treeView.wordCountsChanged.connect(self._updateStatusWordCount)
# Minor GUI Elements
self.statusIcons = []
@@ -529,7 +529,7 @@ class GuiMain(QMainWindow):
self.docEditor.toggleSpellCheck(self.theProject.spellCheck)
self.mainMenu.setAutoOutline(self.theProject.autoOutline)
self.statusBar.setRefTime(self.theProject.projOpened)
self.statusBar.doUpdateProjectStats(self.theProject.currWCount, 0)
self._updateStatusWordCount()
# Restore previously open documents, if any
if self.theProject.lastEdited is not None:
@@ -903,13 +903,13 @@ class GuiMain(QMainWindow):
tItem.setParaCount(pC)
self.treeView.propagateCount(tItem.itemHandle, wC)
self.treeView.setTreeItemValues(tItem.itemHandle)
self.treeView.projectWordCount()
tEnd = time()
self.setStatus(
self.tr("Indexing completed in {0} ms").format(f"{(tEnd - tStart)*1000.0:.1f}")
)
self.docEditor.updateTagHighLighting()
self._updateStatusWordCount()
qApp.restoreOverrideCursor()
if not beQuiet:
@@ -980,6 +980,7 @@ class GuiMain(QMainWindow):
self.novelView.initTree()
self.projView.initOutline()
self.projMeta.initDetails()
self._updateStatusWordCount()
return
@@ -1527,6 +1528,26 @@ class GuiMain(QMainWindow):
return
@pyqtSlot()
def _updateStatusWordCount(self):
"""Update the word count on the status bar.
"""
if not self.hasProject:
self.statusBar.setProjectStats(0, 0)
logger.verbose("Updating total word count")
self.theProject.updateWordCounts()
if self.mainConf.incNotesWCount:
currWords = self.theProject.currWCount
diffWords = currWords - self.theProject.lastWCount
else:
currWords = self.theProject.currNovelWC
diffWords = currWords - self.theProject.lastNovelWC
self.statusBar.setProjectStats(currWords, diffWords)
return
@pyqtSlot()
def _treeSingleClick(self):
"""Single click on a project tree item just updates the details