Merge branch 'master' into dev_0.6

This commit is contained in:
Veronica K. B. Olsen
2020-05-17 00:23:45 +02:00
14 changed files with 377 additions and 129 deletions
+15 -10
View File
@@ -216,18 +216,23 @@ class GuiDocEditor(QTextEdit):
# font changed, otherwise we just clear the editor entirely,
# which makes it read only.
if self.theHandle is not None:
# We must save the current handle as clearEditor() sets it
# to None
tHandle = self.theHandle
self.clearEditor()
self.loadText(tHandle)
self.updateDocMargins()
self.reloadText()
else:
self.clearEditor()
return True
def loadText(self, tHandle, tLine=None):
def reloadText(self):
"""Reloads the document currently being edited.
"""
if self.theHandle is not None:
tHandle = self.theHandle
self.clearEditor()
self.loadText(tHandle, showStatus=False)
self.updateDocMargins()
return
def loadText(self, tHandle, tLine=None, showStatus=True):
"""Load text from a document into the editor. If we have an io
error, we must handle this and clear the editor so that we don't
risk overwriting the file if it exists. This can for instance
@@ -237,7 +242,7 @@ class GuiDocEditor(QTextEdit):
the file.
"""
theDoc = self.nwDocument.openDocument(tHandle)
theDoc = self.nwDocument.openDocument(tHandle, showStatus=showStatus)
if theDoc is None:
# There was an io error
self.clearEditor()
@@ -257,7 +262,6 @@ class GuiDocEditor(QTextEdit):
self.setPlainText(theDoc)
afTime = time()
logger.debug("Document highlighted in %.3f milliseconds" % (1000*(afTime-bfTime)))
self.updateDocMargins()
if tLine is None:
self.setCursorPosition(self.nwDocument.theItem.cursorPos)
@@ -275,6 +279,7 @@ class GuiDocEditor(QTextEdit):
self.theParent.noticeBar.showNote("This document is read only.")
self.docTitle.setTitleFromHandle(self.theHandle)
self.updateDocMargins()
self.hLight.spellCheck = spTemp
qApp.restoreOverrideCursor()
@@ -354,7 +359,7 @@ class GuiDocEditor(QTextEdit):
# The line below causes issues with large documents as it
# triggers an early repaint that seems to only render a part of
# the document. Leaving it here as a warning for now.
# self.qDocument.contentsChange.emit(0,0,0)
# self.qDocument.contentsChange.emit(0, 0, 0)
return