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 return
def updateDocTitle(self, tHandle): def updateDocInfo(self, tHandle):
"""Called when an item label is changed to check if the document """Called when an item label is changed to check if the document
title bar needs updating, title bar needs updating,
""" """
if tHandle == self.theHandle: if tHandle == self.theHandle:
self.docHeader.setTitleFromHandle(self.theHandle) self.docHeader.setTitleFromHandle(self.theHandle)
self.docFooter.updateInfo()
self.updateDocMargins() self.updateDocMargins()
return return
@@ -775,7 +776,7 @@ class GuiDocEditor(QTextEdit):
self.theHandle, self.charCount, self.wordCount, self.paraCount self.theHandle, self.charCount, self.wordCount, self.paraCount
) )
self._checkDocSize(self.charCount) self._checkDocSize(self.charCount)
self.docFooter.updateInfo() self.docFooter.updateCounts()
return return
@@ -1925,6 +1926,7 @@ class GuiDocEditFooter(QWidget):
""" """
self.theHandle = tHandle self.theHandle = tHandle
self.updateInfo() self.updateInfo()
self.updateCounts()
return return
def updateInfo(self): def updateInfo(self):
@@ -1934,9 +1936,6 @@ class GuiDocEditFooter(QWidget):
if nwItem is None: if nwItem is None:
sIcon = QPixmap() sIcon = QPixmap()
sText = "" sText = ""
wCount = 0
wDiff = 0
else: else:
iStatus = nwItem.itemStatus iStatus = nwItem.itemStatus
if nwItem.itemClass == nwItemClass.NOVEL: if nwItem.itemClass == nwItemClass.NOVEL:
@@ -1945,15 +1944,25 @@ 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)
sIcon = theIcon.pixmap(self.sPx, self.sPx) sText = nwItem.itemStatus
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)
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)) self.wordsText.setText("Words: {:n} ({:+n})".format(wCount, wDiff))
return return
+1 -1
View File
@@ -251,7 +251,7 @@ class GuiDocViewer(QTextBrowser):
return return
def updateDocTitle(self, tHandle): def updateDocInfo(self, tHandle):
"""Called when an item label is changed to check if the document """Called when an item label is changed to check if the document
title bar needs updating, title bar needs updating,
""" """
+2 -2
View File
@@ -676,8 +676,8 @@ class GuiMain(QMainWindow):
if dlgProj.exec_(): if dlgProj.exec_():
self.treeView.setTreeItemValues(tHandle) self.treeView.setTreeItemValues(tHandle)
self.treeMeta.updateViewBox(tHandle) self.treeMeta.updateViewBox(tHandle)
self.docEditor.updateDocTitle(tHandle) self.docEditor.updateDocInfo(tHandle)
self.docViewer.updateDocTitle(tHandle) self.docViewer.updateDocInfo(tHandle)
return return