Improve doc changed checking and some code cleanup

This commit is contained in:
Veronica K. B. Olsen
2021-01-09 20:26:05 +01:00
parent e2d5534959
commit 73cd7f7513
2 changed files with 10 additions and 10 deletions
+8 -3
View File
@@ -903,12 +903,13 @@ class GuiDocEditor(QTextEdit):
##
@pyqtSlot(int, int, int)
def _docChange(self, thePos, charsRemoved, charsAdded):
def _docChange(self, thePos, chrRem, chrAdd):
"""Triggered by QTextDocument->contentsChanged. This also
triggers the syntax highlighter.
"""
self.lastEdit = time()
self.lastFind = None
if self.qDocument.characterCount() > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert((
"The document has grown too big and you cannot add more text to it. "
@@ -916,12 +917,16 @@ class GuiDocEditor(QTextEdit):
) % (nwConst.MAX_DOCSIZE/1.0e6), nwAlert.ERROR)
self.undo()
return
if not self.docChanged:
self.setDocumentChanged(True)
self.setDocumentChanged(chrRem != 0 or chrAdd != 0)
if not self.wcTimer.isActive():
self.wcTimer.start()
if self.doReplace and charsAdded == 1:
if self.doReplace and chrAdd == 1:
self._docAutoReplace(self.qDocument.findBlock(thePos))
return
@pyqtSlot("QPoint")
+2 -7
View File
@@ -179,13 +179,8 @@ class GuiMainStatus(QStatusBar):
def setStats(self, pWC, sWC):
"""Set the current project statistics.
"""
self.statsText.setToolTip(
"Project word count (session change)"
)
self.statsText.setText(
f"Words: {pWC:n} ({sWC:+n})"
)
self.statsText.setText(f"Words: {pWC:n} ({sWC:+n})")
self.statsText.setToolTip("Project word count (session change)")
return
##