Cursor position is now saved and loaded with the document.

This commit is contained in:
Veronica K. B. Olsen
2019-05-18 13:52:45 +02:00
parent cb71da5200
commit 19b2521b73
4 changed files with 26 additions and 3 deletions
+10
View File
@@ -120,6 +120,16 @@ class GuiDocEditor(QTextEdit):
theText = self.toPlainText()
return theText
def setCursorPosition(self, thePosition):
theCursor = self.textCursor()
theCursor.setPosition(thePosition)
self.setTextCursor(theCursor)
return True
def getCursorPosition(self):
theCursor = self.textCursor()
return theCursor.position()
##
# Spell Checking
##
+4
View File
@@ -206,15 +206,19 @@ class GuiMain(QMainWindow):
self.saveDocument()
self.stackPane.setCurrentIndex(self.stackDoc)
self.docEditor.setText(self.theDocument.openDocument(tHandle))
self.docEditor.setCursorPosition(self.theDocument.theItem.cursorPos)
self.docEditor.changeWidth()
self.docEditor.setFocus()
return True
def saveDocument(self):
if self.theDocument.theItem is not None:
docHtml = self.docEditor.getText()
cursPos = self.docEditor.getCursorPosition()
self.theDocument.theItem.setCharCount(self.docEditor.charCount)
self.theDocument.theItem.setWordCount(self.docEditor.wordCount)
self.theDocument.theItem.setParaCount(self.docEditor.paraCount)
self.theDocument.theItem.setCursorPos(cursPos)
self.theDocument.saveDocument(docHtml)
self.docEditor.setDocumentChanged(False)
return True