Merge pull request #780 from vkbo/class_cleanup

GUI Class Cleanup
This commit is contained in:
Veronica Berglyd Olsen
2021-05-17 17:02:39 +02:00
committed by GitHub
8 changed files with 89 additions and 69 deletions
+1
View File
@@ -28,6 +28,7 @@ __pycache__
/nw/assets/sample.zip /nw/assets/sample.zip
/sample/cache /sample/cache
/sample/meta /sample/meta
/sample/versions
*.bak *.bak
*.lock *.lock
ToC.txt ToC.txt
+42 -25
View File
@@ -58,9 +58,12 @@ class GuiDocViewer(QTextBrowser):
self.theParent = theParent self.theParent = theParent
self.theTheme = theParent.theTheme self.theTheme = theParent.theTheme
self.theProject = theParent.theProject self.theProject = theParent.theProject
self.theHandle = None
self.qDocument = self.document() # Internal Variables
self._docHandle = None
self._qDocument = self.document()
# Settings
self.setMinimumWidth(self.mainConf.pxInt(300)) self.setMinimumWidth(self.mainConf.pxInt(300))
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
self.setOpenExternalLinks(False) self.setOpenExternalLinks(False)
@@ -90,8 +93,8 @@ class GuiDocViewer(QTextBrowser):
""" """
self.clear() self.clear()
self.setSearchPaths([""]) self.setSearchPaths([""])
self.theHandle = None self._docHandle = None
self.docHeader.setTitleFromHandle(self.theHandle) self.docHeader.setTitleFromHandle(self._docHandle)
return True return True
def initViewer(self): def initViewer(self):
@@ -103,7 +106,7 @@ class GuiDocViewer(QTextBrowser):
theFont = QFont() theFont = QFont()
if self.mainConf.textFont is None: if self.mainConf.textFont is None:
# If none is defined, set the default back to config # If none is defined, set the default back to config
self.mainConf.textFont = self.qDocument.defaultFont().family() self.mainConf.textFont = self._qDocument.defaultFont().family()
theFont.setFamily(self.mainConf.textFont) theFont.setFamily(self.mainConf.textFont)
theFont.setPointSize(self.mainConf.textSize) theFont.setPointSize(self.mainConf.textSize)
self.setFont(theFont) self.setFont(theFont)
@@ -124,11 +127,11 @@ class GuiDocViewer(QTextBrowser):
self.docFooter.matchColours() self.docFooter.matchColours()
# Set default text margins # Set default text margins
self.qDocument.setDocumentMargin(0) self._qDocument.setDocumentMargin(0)
theOpt = QTextOption() theOpt = QTextOption()
if self.mainConf.doJustify: if self.mainConf.doJustify:
theOpt.setAlignment(Qt.AlignJustify) theOpt.setAlignment(Qt.AlignJustify)
self.qDocument.setDefaultTextOption(theOpt) self._qDocument.setDefaultTextOption(theOpt)
# Scroll bars # Scroll bars
if self.mainConf.hideVScroll: if self.mainConf.hideVScroll:
@@ -148,7 +151,7 @@ class GuiDocViewer(QTextBrowser):
self.setTabStopWidth(self.mainConf.getTabWidth()) self.setTabStopWidth(self.mainConf.getTabWidth())
# If we have a document open, we should reload it in case the font changed # If we have a document open, we should reload it in case the font changed
if self.theHandle is not None: if self._docHandle is not None:
self.reloadText() self.reloadText()
return True return True
@@ -205,11 +208,11 @@ class GuiDocViewer(QTextBrowser):
theCursor = self.textCursor() theCursor = self.textCursor()
theCursor.insertText("\t") theCursor.insertText("\t")
if self.theHandle == tHandle: if self._docHandle == tHandle:
self.verticalScrollBar().setValue(sPos) self.verticalScrollBar().setValue(sPos)
self.theHandle = tHandle self._docHandle = tHandle
self.theProject.setLastViewed(tHandle) self.theProject.setLastViewed(tHandle)
self.docHeader.setTitleFromHandle(self.theHandle) self.docHeader.setTitleFromHandle(self._docHandle)
self.updateDocMargins() self.updateDocMargins()
# Make sure the main GUI knows we changed the content # Make sure the main GUI knows we changed the content
@@ -225,13 +228,13 @@ class GuiDocViewer(QTextBrowser):
def reloadText(self): def reloadText(self):
"""Reload the text in the current document. """Reload the text in the current document.
""" """
self.loadText(self.theHandle, updateHistory=False) self.loadText(self._docHandle, updateHistory=False)
return return
def redrawText(self): def redrawText(self):
"""Redraw the text by marking the document content as "dirty". """Redraw the text by marking the document content as "dirty".
""" """
self.qDocument.markContentsDirty(0, self.qDocument.characterCount()) self._qDocument.markContentsDirty(0, self._qDocument.characterCount())
self.updateDocMargins() self.updateDocMargins()
return return
@@ -265,7 +268,7 @@ class GuiDocViewer(QTextBrowser):
document. document.
""" """
logger.verbose("Requesting action: %s" % theAction.name) logger.verbose("Requesting action: %s" % theAction.name)
if self.theHandle is None: if self._docHandle is None:
logger.error("No document open") logger.error("No document open")
return False return False
if theAction == nwDocAction.CUT: if theAction == nwDocAction.CUT:
@@ -337,11 +340,21 @@ class GuiDocViewer(QTextBrowser):
"""Called when an item label is changed to check if the document """Called when an item label is changed to check if the document
title bar needs updating, title bar needs updating,
""" """
if tHandle == self.theHandle: if tHandle == self._docHandle:
self.docHeader.setTitleFromHandle(self.theHandle) self.docHeader.setTitleFromHandle(self._docHandle)
self.updateDocMargins() self.updateDocMargins()
return return
##
# Properties
##
def docHandle(self):
"""Return the handle of the currently open document. Returns
None if no document is open.
"""
return self._docHandle
## ##
# Setters # Setters
## ##
@@ -363,7 +376,7 @@ class GuiDocViewer(QTextBrowser):
if not isinstance(theLine, int): if not isinstance(theLine, int):
return False return False
if theLine >= 0: if theLine >= 0:
theBlock = self.qDocument.findBlockByLineNumber(theLine) theBlock = self._qDocument.findBlockByLineNumber(theLine)
if theBlock: if theBlock:
self.setCursorPosition(theBlock.position()) self.setCursorPosition(theBlock.position())
logger.verbose("Cursor moved to line %d" % theLine) logger.verbose("Cursor moved to line %d" % theLine)
@@ -553,7 +566,7 @@ class GuiDocViewer(QTextBrowser):
mColG = self.theTheme.colMod[1], mColG = self.theTheme.colMod[1],
mColB = self.theTheme.colMod[2], mColB = self.theTheme.colMod[2],
) )
self.qDocument.setDefaultStyleSheet(styleSheet) self._qDocument.setDefaultStyleSheet(styleSheet)
return True return True
@@ -707,7 +720,9 @@ class GuiDocViewHeader(QWidget):
self.theParent = docViewer.theParent self.theParent = docViewer.theParent
self.theProject = docViewer.theProject self.theProject = docViewer.theProject
self.theTheme = docViewer.theTheme self.theTheme = docViewer.theTheme
self.theHandle = None
# Internal Variables
self._docHandle = None
fPx = int(0.9*self.theTheme.fontPixelSize) fPx = int(0.9*self.theTheme.fontPixelSize)
hSp = self.mainConf.pxInt(6) hSp = self.mainConf.pxInt(6)
@@ -825,7 +840,7 @@ class GuiDocViewHeader(QWidget):
"""Sets the document title from the handle, or alternatively, """Sets the document title from the handle, or alternatively,
set the whole document path. set the whole document path.
""" """
self.theHandle = tHandle self._docHandle = tHandle
if tHandle is None: if tHandle is None:
self.theTitle.setText("") self.theTitle.setText("")
self.backButton.setVisible(False) self.backButton.setVisible(False)
@@ -876,7 +891,7 @@ class GuiDocViewHeader(QWidget):
def _refreshDocument(self): def _refreshDocument(self):
"""Reload the content of the document. """Reload the content of the document.
""" """
if self.docViewer.theHandle == self.theParent.docEditor.docHandle(): if self.docViewer.docHandle() == self.theParent.docEditor.docHandle():
self.theParent.saveDocument() self.theParent.saveDocument()
self.docViewer.reloadText() self.docViewer.reloadText()
return return
@@ -889,7 +904,7 @@ class GuiDocViewHeader(QWidget):
"""Capture a click on the title and ensure that the item is """Capture a click on the title and ensure that the item is
selected in the project tree. selected in the project tree.
""" """
self.theParent.treeView.setSelectedHandle(self.theHandle, doScroll=True) self.theParent.treeView.setSelectedHandle(self._docHandle, doScroll=True)
return return
# END Class GuiDocViewHeader # END Class GuiDocViewHeader
@@ -911,7 +926,9 @@ class GuiDocViewFooter(QWidget):
self.theParent = docViewer.theParent self.theParent = docViewer.theParent
self.theTheme = docViewer.theTheme self.theTheme = docViewer.theTheme
self.viewMeta = docViewer.theParent.viewMeta self.viewMeta = docViewer.theParent.viewMeta
self.theHandle = None
# Internal Variables
self._docHandle = None
fPx = int(0.9*self.theTheme.fontPixelSize) fPx = int(0.9*self.theTheme.fontPixelSize)
bSp = self.mainConf.pxInt(2) bSp = self.mainConf.pxInt(2)
@@ -1097,8 +1114,8 @@ class GuiDocViewFooter(QWidget):
""" """
logger.verbose("Reference sticky is %s" % str(theState)) logger.verbose("Reference sticky is %s" % str(theState))
self.docViewer.stickyRef = theState self.docViewer.stickyRef = theState
if not theState and self.docViewer.theHandle is not None: if not theState and self.docViewer.docHandle() is not None:
self.viewMeta.refreshReferences(self.docViewer.theHandle) self.viewMeta.refreshReferences(self.docViewer.docHandle())
return return
def _doToggleComments(self, theState): def _doToggleComments(self, theState):
+32 -30
View File
@@ -46,7 +46,9 @@ class GuiItemDetails(QWidget):
self.theParent = theParent self.theParent = theParent
self.theProject = theParent.theProject self.theProject = theParent.theProject
self.theTheme = theParent.theTheme self.theTheme = theParent.theTheme
self.theHandle = None
# Internal Variables
self._itemHandle = None
# Sizes # Sizes
hSp = self.mainConf.pxInt(6) hSp = self.mainConf.pxInt(6)
@@ -55,92 +57,92 @@ class GuiItemDetails(QWidget):
iPx = self.theTheme.baseIconSize iPx = self.theTheme.baseIconSize
fPt = self.theTheme.fontPointSize fPt = self.theTheme.fontPointSize
self.expCheck = self.theTheme.getPixmap("check", (iPx, iPx)) self._expCheck = self.theTheme.getPixmap("check", (iPx, iPx))
self.expCross = self.theTheme.getPixmap("cross", (iPx, iPx)) self._expCross = self.theTheme.getPixmap("cross", (iPx, iPx))
self.fntLabel = QFont() fntLabel = QFont()
self.fntLabel.setBold(True) fntLabel.setBold(True)
self.fntLabel.setPointSizeF(0.9*fPt) fntLabel.setPointSizeF(0.9*fPt)
self.fntValue = QFont() fntValue = QFont()
self.fntValue.setPointSizeF(0.9*fPt) fntValue.setPointSizeF(0.9*fPt)
# Label # Label
self.labelName = QLabel(self.tr("Label")) self.labelName = QLabel(self.tr("Label"))
self.labelName.setFont(self.fntLabel) self.labelName.setFont(fntLabel)
self.labelName.setAlignment(Qt.AlignLeft | Qt.AlignBaseline) self.labelName.setAlignment(Qt.AlignLeft | Qt.AlignBaseline)
self.labelFlag = QLabel("") self.labelFlag = QLabel("")
self.labelFlag.setAlignment(Qt.AlignRight | Qt.AlignBaseline) self.labelFlag.setAlignment(Qt.AlignRight | Qt.AlignBaseline)
self.labelData = QLabel("") self.labelData = QLabel("")
self.labelData.setFont(self.fntValue) self.labelData.setFont(fntValue)
self.labelData.setAlignment(Qt.AlignLeft | Qt.AlignBaseline) self.labelData.setAlignment(Qt.AlignLeft | Qt.AlignBaseline)
self.labelData.setWordWrap(True) self.labelData.setWordWrap(True)
# Status # Status
self.statusName = QLabel(self.tr("Status")) self.statusName = QLabel(self.tr("Status"))
self.statusName.setFont(self.fntLabel) self.statusName.setFont(fntLabel)
self.statusName.setAlignment(Qt.AlignLeft) self.statusName.setAlignment(Qt.AlignLeft)
self.statusFlag = QLabel("") self.statusFlag = QLabel("")
self.statusFlag.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.statusFlag.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
self.statusData = QLabel("") self.statusData = QLabel("")
self.statusData.setFont(self.fntValue) self.statusData.setFont(fntValue)
self.statusData.setAlignment(Qt.AlignLeft) self.statusData.setAlignment(Qt.AlignLeft)
# Class # Class
self.className = QLabel(self.tr("Class")) self.className = QLabel(self.tr("Class"))
self.className.setFont(self.fntLabel) self.className.setFont(fntLabel)
self.className.setAlignment(Qt.AlignLeft) self.className.setAlignment(Qt.AlignLeft)
self.classFlag = QLabel("") self.classFlag = QLabel("")
self.classFlag.setFont(self.fntValue) self.classFlag.setFont(fntValue)
self.classFlag.setAlignment(Qt.AlignRight) self.classFlag.setAlignment(Qt.AlignRight)
self.classData = QLabel("") self.classData = QLabel("")
self.classData.setFont(self.fntValue) self.classData.setFont(fntValue)
self.classData.setAlignment(Qt.AlignLeft) self.classData.setAlignment(Qt.AlignLeft)
# Layout # Layout
self.layoutName = QLabel(self.tr("Layout")) self.layoutName = QLabel(self.tr("Layout"))
self.layoutName.setFont(self.fntLabel) self.layoutName.setFont(fntLabel)
self.layoutName.setAlignment(Qt.AlignLeft) self.layoutName.setAlignment(Qt.AlignLeft)
self.layoutFlag = QLabel("") self.layoutFlag = QLabel("")
self.layoutFlag.setFont(self.fntValue) self.layoutFlag.setFont(fntValue)
self.layoutFlag.setAlignment(Qt.AlignRight) self.layoutFlag.setAlignment(Qt.AlignRight)
self.layoutData = QLabel("") self.layoutData = QLabel("")
self.layoutData.setFont(self.fntValue) self.layoutData.setFont(fntValue)
self.layoutData.setAlignment(Qt.AlignLeft) self.layoutData.setAlignment(Qt.AlignLeft)
# Character Count # Character Count
self.cCountName = QLabel(" "+self.tr("Characters")) self.cCountName = QLabel(" "+self.tr("Characters"))
self.cCountName.setFont(self.fntLabel) self.cCountName.setFont(fntLabel)
self.cCountName.setAlignment(Qt.AlignRight) self.cCountName.setAlignment(Qt.AlignRight)
self.cCountData = QLabel("") self.cCountData = QLabel("")
self.cCountData.setFont(self.fntValue) self.cCountData.setFont(fntValue)
self.cCountData.setAlignment(Qt.AlignRight) self.cCountData.setAlignment(Qt.AlignRight)
# Word Count # Word Count
self.wCountName = QLabel(" "+self.tr("Words")) self.wCountName = QLabel(" "+self.tr("Words"))
self.wCountName.setFont(self.fntLabel) self.wCountName.setFont(fntLabel)
self.wCountName.setAlignment(Qt.AlignRight) self.wCountName.setAlignment(Qt.AlignRight)
self.wCountData = QLabel("") self.wCountData = QLabel("")
self.wCountData.setFont(self.fntValue) self.wCountData.setFont(fntValue)
self.wCountData.setAlignment(Qt.AlignRight) self.wCountData.setAlignment(Qt.AlignRight)
# Paragraph Count # Paragraph Count
self.pCountName = QLabel(" "+self.tr("Paragraphs")) self.pCountName = QLabel(" "+self.tr("Paragraphs"))
self.pCountName.setFont(self.fntLabel) self.pCountName.setFont(fntLabel)
self.pCountName.setAlignment(Qt.AlignRight) self.pCountName.setAlignment(Qt.AlignRight)
self.pCountData = QLabel("") self.pCountData = QLabel("")
self.pCountData.setFont(self.fntValue) self.pCountData.setFont(fntValue)
self.pCountData.setAlignment(Qt.AlignRight) self.pCountData.setAlignment(Qt.AlignRight)
# Assemble # Assemble
@@ -180,8 +182,8 @@ class GuiItemDetails(QWidget):
self.setLayout(self.mainBox) self.setLayout(self.mainBox)
# Make sure the columns for flags and counts don't resize too often # Make sure the columns for flags and counts don't resize too often
flagWidth = self.theTheme.getTextWidth("Mm", self.fntValue) flagWidth = self.theTheme.getTextWidth("Mm", fntValue)
countWidth = self.theTheme.getTextWidth("99,999", self.fntValue) countWidth = self.theTheme.getTextWidth("99,999", fntValue)
self.mainBox.setColumnMinimumWidth(1, flagWidth) self.mainBox.setColumnMinimumWidth(1, flagWidth)
self.mainBox.setColumnMinimumWidth(4, countWidth) self.mainBox.setColumnMinimumWidth(4, countWidth)
@@ -224,7 +226,7 @@ class GuiItemDetails(QWidget):
self.clearDetails() self.clearDetails()
return return
self.theHandle = tHandle self._itemHandle = tHandle
theLabel = nwItem.itemName theLabel = nwItem.itemName
if len(theLabel) > 100: if len(theLabel) > 100:
theLabel = theLabel[:96].rstrip()+" ..." theLabel = theLabel[:96].rstrip()+" ..."
@@ -239,9 +241,9 @@ class GuiItemDetails(QWidget):
if nwItem.itemType == nwItemType.FILE: if nwItem.itemType == nwItemType.FILE:
if nwItem.isExported: if nwItem.isExported:
self.labelFlag.setPixmap(self.expCheck) self.labelFlag.setPixmap(self._expCheck)
else: else:
self.labelFlag.setPixmap(self.expCross) self.labelFlag.setPixmap(self._expCross)
else: else:
self.labelFlag.setPixmap(QPixmap(1, 1)) self.labelFlag.setPixmap(QPixmap(1, 1))
@@ -279,7 +281,7 @@ class GuiItemDetails(QWidget):
"""Update the counts if the handle is the same as the one we're """Update the counts if the handle is the same as the one we're
already showing. Otherwise, do nothing. already showing. Otherwise, do nothing.
""" """
if tHandle == self.theHandle: if tHandle == self._itemHandle:
self.cCountData.setText(f"{cC:n}") self.cCountData.setText(f"{cC:n}")
self.wCountData.setText(f"{wC:n}") self.wCountData.setText(f"{wC:n}")
self.pCountData.setText(f"{pC:n}") self.pCountData.setText(f"{pC:n}")
+1 -1
View File
@@ -1251,7 +1251,7 @@ class GuiMain(QMainWindow):
if self.splitView.isVisible(): if self.splitView.isVisible():
self.splitView.setVisible(False) self.splitView.setVisible(False)
elif self.docViewer.theHandle is not None: elif self.docViewer.docHandle() is not None:
self.splitView.setVisible(True) self.splitView.setVisible(True)
return True return True
+5 -5
View File
@@ -58,7 +58,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
theItem = nwGUI.treeView._getTreeItem("88243afbe5ed8") theItem = nwGUI.treeView._getTreeItem("88243afbe5ed8")
theRect = nwGUI.treeView.visualItemRect(theItem) theRect = nwGUI.treeView.visualItemRect(theItem)
qtbot.mouseClick(nwGUI.treeView.viewport(), Qt.MidButton, pos=theRect.center()) qtbot.mouseClick(nwGUI.treeView.viewport(), Qt.MidButton, pos=theRect.center())
assert nwGUI.docViewer.theHandle == "88243afbe5ed8" assert nwGUI.docViewer.docHandle() == "88243afbe5ed8"
# Reload the text # Reload the text
origText = nwGUI.docViewer.toPlainText() origText = nwGUI.docViewer.toPlainText()
@@ -112,7 +112,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
# Close document # Close document
nwGUI.docViewer.docHeader._closeDocument() nwGUI.docViewer.docHeader._closeDocument()
assert nwGUI.docViewer.theHandle is None assert nwGUI.docViewer.docHandle() is None
# Action on no document # Action on no document
assert not nwGUI.docViewer.docAction(nwDocAction.COPY) assert not nwGUI.docViewer.docAction(nwDocAction.COPY)
@@ -127,13 +127,13 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
theRect = nwGUI.docViewer.cursorRect() theRect = nwGUI.docViewer.cursorRect()
# qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.LeftButton, pos=theRect.center(), delay=100) # qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.LeftButton, pos=theRect.center(), delay=100)
nwGUI.docViewer._linkClicked(QUrl("#char=Bod")) nwGUI.docViewer._linkClicked(QUrl("#char=Bod"))
assert nwGUI.docViewer.theHandle == "4c4f28287af27" assert nwGUI.docViewer.docHandle() == "4c4f28287af27"
# Click mouse nav buttons # Click mouse nav buttons
qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.BackButton, pos=theRect.center(), delay=100) qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.BackButton, pos=theRect.center(), delay=100)
assert nwGUI.docViewer.theHandle == "88243afbe5ed8" assert nwGUI.docViewer.docHandle() == "88243afbe5ed8"
qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.ForwardButton, pos=theRect.center(), delay=100) qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.ForwardButton, pos=theRect.center(), delay=100)
assert nwGUI.docViewer.theHandle == "4c4f28287af27" assert nwGUI.docViewer.docHandle() == "4c4f28287af27"
# Scroll bar default on empty document # Scroll bar default on empty document
nwGUI.docViewer.clear() nwGUI.docViewer.clear()
+3 -3
View File
@@ -337,17 +337,17 @@ def testGuiMenu_ContextMenus(qtbot, monkeypatch, nwGUI, nwLipsum):
# Navigation History # Navigation History
assert nwGUI.viewDocument("04468803b92e1") assert nwGUI.viewDocument("04468803b92e1")
assert nwGUI.docViewer.theHandle == "04468803b92e1" assert nwGUI.docViewer.docHandle() == "04468803b92e1"
assert nwGUI.docViewer.docHeader.backButton.isEnabled() assert nwGUI.docViewer.docHeader.backButton.isEnabled()
assert not nwGUI.docViewer.docHeader.forwardButton.isEnabled() assert not nwGUI.docViewer.docHeader.forwardButton.isEnabled()
qtbot.mouseClick(nwGUI.docViewer.docHeader.backButton, Qt.LeftButton) qtbot.mouseClick(nwGUI.docViewer.docHeader.backButton, Qt.LeftButton)
assert nwGUI.docViewer.theHandle == "4c4f28287af27" assert nwGUI.docViewer.docHandle() == "4c4f28287af27"
assert not nwGUI.docViewer.docHeader.backButton.isEnabled() assert not nwGUI.docViewer.docHeader.backButton.isEnabled()
assert nwGUI.docViewer.docHeader.forwardButton.isEnabled() assert nwGUI.docViewer.docHeader.forwardButton.isEnabled()
qtbot.mouseClick(nwGUI.docViewer.docHeader.forwardButton, Qt.LeftButton) qtbot.mouseClick(nwGUI.docViewer.docHeader.forwardButton, Qt.LeftButton)
assert nwGUI.docViewer.theHandle == "04468803b92e1" assert nwGUI.docViewer.docHandle() == "04468803b92e1"
assert nwGUI.docViewer.docHeader.backButton.isEnabled() assert nwGUI.docViewer.docHeader.backButton.isEnabled()
assert not nwGUI.docViewer.docHeader.forwardButton.isEnabled() assert not nwGUI.docViewer.docHeader.forwardButton.isEnabled()
+4 -4
View File
@@ -104,19 +104,19 @@ def testGuiNovelTree_TreeItems(qtbot, caplog, monkeypatch, nwGUI, nwMinimal):
# Open item with middle mouse button # Open item with middle mouse button
scItem.setSelected(True) scItem.setSelected(True)
assert scItem.isSelected() assert scItem.isSelected()
assert nwGUI.docViewer.theHandle is None assert nwGUI.docViewer.docHandle() is None
qtbot.mouseClick(vPort, Qt.MiddleButton, pos=vPort.rect().center(), delay=10) qtbot.mouseClick(vPort, Qt.MiddleButton, pos=vPort.rect().center(), delay=10)
assert nwGUI.docViewer.theHandle is None assert nwGUI.docViewer.docHandle() is None
scRect = nwTree.visualItemRect(scItem) scRect = nwTree.visualItemRect(scItem)
oldData = scItem.data(nwTree.C_TITLE, Qt.UserRole) oldData = scItem.data(nwTree.C_TITLE, Qt.UserRole)
scItem.setData(nwTree.C_TITLE, Qt.UserRole, (None, "", "")) scItem.setData(nwTree.C_TITLE, Qt.UserRole, (None, "", ""))
qtbot.mouseClick(vPort, Qt.MiddleButton, pos=scRect.center(), delay=10) qtbot.mouseClick(vPort, Qt.MiddleButton, pos=scRect.center(), delay=10)
assert nwGUI.docViewer.theHandle is None assert nwGUI.docViewer.docHandle() is None
scItem.setData(nwTree.C_TITLE, Qt.UserRole, oldData) scItem.setData(nwTree.C_TITLE, Qt.UserRole, oldData)
qtbot.mouseClick(vPort, Qt.MiddleButton, pos=scRect.center(), delay=10) qtbot.mouseClick(vPort, Qt.MiddleButton, pos=scRect.center(), delay=10)
assert nwGUI.docViewer.theHandle == "8c659a11cd429" assert nwGUI.docViewer.docHandle() == "8c659a11cd429"
## ##
# Populate Tree # Populate Tree
+1 -1
View File
@@ -85,7 +85,7 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
# Click POV Link # Click POV Link
assert nwGUI.projMeta.povKeyValue.text() == "<a href='#pov=Bod'>Bod</a>" assert nwGUI.projMeta.povKeyValue.text() == "<a href='#pov=Bod'>Bod</a>"
nwGUI.projMeta._tagClicked("#pov=Bod") nwGUI.projMeta._tagClicked("#pov=Bod")
assert nwGUI.docViewer.theHandle == "4c4f28287af27" assert nwGUI.docViewer.docHandle() == "4c4f28287af27"
# qtbot.stopForInteraction() # qtbot.stopForInteraction()