Update count and infor separately, and make sure info is updated on item edit

This commit is contained in:
Veronica K. B. Olsen
2020-06-27 19:49:06 +02:00
parent 243d9dd85a
commit c0074ca269
3 changed files with 22 additions and 13 deletions
+19 -10
View File
@@ -362,12 +362,13 @@ class GuiDocEditor(QTextEdit):
return
def updateDocTitle(self, tHandle):
def updateDocInfo(self, tHandle):
"""Called when an item label is changed to check if the document
title bar needs updating,
"""
if tHandle == self.theHandle:
self.docHeader.setTitleFromHandle(self.theHandle)
self.docFooter.updateInfo()
self.updateDocMargins()
return
@@ -775,7 +776,7 @@ class GuiDocEditor(QTextEdit):
self.theHandle, self.charCount, self.wordCount, self.paraCount
)
self._checkDocSize(self.charCount)
self.docFooter.updateInfo()
self.docFooter.updateCounts()
return
@@ -1925,6 +1926,7 @@ class GuiDocEditFooter(QWidget):
"""
self.theHandle = tHandle
self.updateInfo()
self.updateCounts()
return
def updateInfo(self):
@@ -1934,9 +1936,6 @@ class GuiDocEditFooter(QWidget):
if nwItem is None:
sIcon = QPixmap()
sText = ""
wCount = 0
wDiff = 0
else:
iStatus = nwItem.itemStatus
if nwItem.itemClass == nwItemClass.NOVEL:
@@ -1945,15 +1944,25 @@ 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
wCount = nwItem.wordCount
wDiff = wCount - nwItem.initCount
sIcon = theIcon.pixmap(self.sPx, self.sPx)
sText = nwItem.itemStatus
self.statusIcon.setPixmap(sIcon)
self.statusText.setText(sText)
return
def updateCounts(self):
"""Update the word counts.
"""
nwItem = self.theProject.projTree[self.theHandle]
if nwItem is None:
wCount = 0
wDiff = 0
else:
wCount = nwItem.wordCount
wDiff = wCount - nwItem.initCount
self.wordsText.setText("Words: {:n} ({:+n})".format(wCount, wDiff))
return
+1 -1
View File
@@ -251,7 +251,7 @@ class GuiDocViewer(QTextBrowser):
return
def updateDocTitle(self, tHandle):
def updateDocInfo(self, tHandle):
"""Called when an item label is changed to check if the document
title bar needs updating,
"""
+2 -2
View File
@@ -676,8 +676,8 @@ class GuiMain(QMainWindow):
if dlgProj.exec_():
self.treeView.setTreeItemValues(tHandle)
self.treeMeta.updateViewBox(tHandle)
self.docEditor.updateDocTitle(tHandle)
self.docViewer.updateDocTitle(tHandle)
self.docEditor.updateDocInfo(tHandle)
self.docViewer.updateDocInfo(tHandle)
return