Improve doc changed checking and some code cleanup
This commit is contained in:
+8
-3
@@ -903,12 +903,13 @@ class GuiDocEditor(QTextEdit):
|
|||||||
##
|
##
|
||||||
|
|
||||||
@pyqtSlot(int, int, int)
|
@pyqtSlot(int, int, int)
|
||||||
def _docChange(self, thePos, charsRemoved, charsAdded):
|
def _docChange(self, thePos, chrRem, chrAdd):
|
||||||
"""Triggered by QTextDocument->contentsChanged. This also
|
"""Triggered by QTextDocument->contentsChanged. This also
|
||||||
triggers the syntax highlighter.
|
triggers the syntax highlighter.
|
||||||
"""
|
"""
|
||||||
self.lastEdit = time()
|
self.lastEdit = time()
|
||||||
self.lastFind = None
|
self.lastFind = None
|
||||||
|
|
||||||
if self.qDocument.characterCount() > nwConst.MAX_DOCSIZE:
|
if self.qDocument.characterCount() > nwConst.MAX_DOCSIZE:
|
||||||
self.theParent.makeAlert((
|
self.theParent.makeAlert((
|
||||||
"The document has grown too big and you cannot add more text to it. "
|
"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)
|
) % (nwConst.MAX_DOCSIZE/1.0e6), nwAlert.ERROR)
|
||||||
self.undo()
|
self.undo()
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.docChanged:
|
if not self.docChanged:
|
||||||
self.setDocumentChanged(True)
|
self.setDocumentChanged(chrRem != 0 or chrAdd != 0)
|
||||||
|
|
||||||
if not self.wcTimer.isActive():
|
if not self.wcTimer.isActive():
|
||||||
self.wcTimer.start()
|
self.wcTimer.start()
|
||||||
if self.doReplace and charsAdded == 1:
|
|
||||||
|
if self.doReplace and chrAdd == 1:
|
||||||
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot("QPoint")
|
@pyqtSlot("QPoint")
|
||||||
|
|||||||
+2
-7
@@ -179,13 +179,8 @@ class GuiMainStatus(QStatusBar):
|
|||||||
def setStats(self, pWC, sWC):
|
def setStats(self, pWC, sWC):
|
||||||
"""Set the current project statistics.
|
"""Set the current project statistics.
|
||||||
"""
|
"""
|
||||||
self.statsText.setToolTip(
|
self.statsText.setText(f"Words: {pWC:n} ({sWC:+n})")
|
||||||
"Project word count (session change)"
|
self.statsText.setToolTip("Project word count (session change)")
|
||||||
)
|
|
||||||
self.statsText.setText(
|
|
||||||
f"Words: {pWC:n} ({sWC:+n})"
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
Reference in New Issue
Block a user