Test Coverage of the Editor (#787)
* Drop the _qDocument class variables * Split up the current doceditor test file * Add tests for editor init, load and save * Add tests for editor meta functions and actions * Add tests for editor insert functions * Add tests for editor text manipulation and block formatting * Fix code style * Add text coverage for alignment and indent
This commit is contained in:
committed by
GitHub
parent
1d16cc2a03
commit
36be7b0b33
+9
-10
@@ -980,7 +980,7 @@ class GuiBuildNovel(QDialog):
|
||||
thePrinter.setFontEmbeddingEnabled(True)
|
||||
thePrinter.setColorMode(QPrinter.Color)
|
||||
thePrinter.setOutputFileName(savePath)
|
||||
self.docView.qDocument.print(thePrinter)
|
||||
self.docView.document().print(thePrinter)
|
||||
wSuccess = True
|
||||
|
||||
except Exception as e:
|
||||
@@ -1018,7 +1018,7 @@ class GuiBuildNovel(QDialog):
|
||||
"""
|
||||
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
thePrinter.setOrientation(QPrinter.Portrait)
|
||||
self.docView.qDocument.print(thePrinter)
|
||||
self.docView.document().print(thePrinter)
|
||||
qApp.restoreOverrideCursor()
|
||||
return
|
||||
|
||||
@@ -1195,8 +1195,7 @@ class GuiBuildNovelDocView(QTextBrowser):
|
||||
self.setMinimumWidth(40*self.theParent.theTheme.textNWidth)
|
||||
self.setOpenExternalLinks(False)
|
||||
|
||||
self.qDocument = self.document()
|
||||
self.qDocument.setDocumentMargin(self.mainConf.getTextMargin())
|
||||
self.document().setDocumentMargin(self.mainConf.getTextMargin())
|
||||
self.setPlaceholderText(self.tr(
|
||||
"This area will show the content of the document to be "
|
||||
"exported or printed. Press the \"Build Preview\" button "
|
||||
@@ -1206,7 +1205,7 @@ class GuiBuildNovelDocView(QTextBrowser):
|
||||
theFont = QFont()
|
||||
if self.mainConf.textFont is None:
|
||||
# If none is defined, set the default back to config
|
||||
self.mainConf.textFont = self.qDocument.defaultFont().family()
|
||||
self.mainConf.textFont = self.document().defaultFont().family()
|
||||
theFont.setFamily(self.mainConf.textFont)
|
||||
theFont.setPointSize(self.mainConf.textSize)
|
||||
self.setFont(theFont)
|
||||
@@ -1256,12 +1255,12 @@ class GuiBuildNovelDocView(QTextBrowser):
|
||||
def setJustify(self, doJustify):
|
||||
"""Set the justify text option.
|
||||
"""
|
||||
theOpt = self.qDocument.defaultTextOption()
|
||||
theOpt = self.document().defaultTextOption()
|
||||
if doJustify:
|
||||
theOpt.setAlignment(Qt.AlignJustify)
|
||||
else:
|
||||
theOpt.setAlignment(Qt.AlignAbsolute)
|
||||
self.qDocument.setDefaultTextOption(theOpt)
|
||||
self.document().setDefaultTextOption(theOpt)
|
||||
return
|
||||
|
||||
def setTextFont(self, textFont, textSize):
|
||||
@@ -1298,7 +1297,7 @@ class GuiBuildNovelDocView(QTextBrowser):
|
||||
|
||||
# Since we change the content while it may still be rendering, we mark
|
||||
# the document dirty again to make sure it's re-rendered properly.
|
||||
self.qDocument.markContentsDirty(0, self.qDocument.characterCount())
|
||||
self.document().markContentsDirty(0, self.document().characterCount())
|
||||
qApp.restoreOverrideCursor()
|
||||
|
||||
return
|
||||
@@ -1312,14 +1311,14 @@ class GuiBuildNovelDocView(QTextBrowser):
|
||||
theStyles.append("a {color: rgb(66, 113, 174);}")
|
||||
theStyles.append(".tags {color: rgb(245, 135, 31); font-weight: bold;}")
|
||||
|
||||
self.qDocument.setDefaultStyleSheet("\n".join(theStyles))
|
||||
self.document().setDefaultStyleSheet("\n".join(theStyles))
|
||||
|
||||
return
|
||||
|
||||
def clearStyleSheet(self):
|
||||
"""Clears the document stylesheet.
|
||||
"""
|
||||
self.qDocument.setDefaultStyleSheet("")
|
||||
self.document().setDefaultStyleSheet("")
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user