Merge branch 'main' into outline_view
This commit is contained in:
@@ -409,10 +409,10 @@ class PagedDialog(QDialog):
|
||||
|
||||
return
|
||||
|
||||
def addTab(self, tabWidget, tabLabel):
|
||||
def addTab(self, widget, label):
|
||||
"""Forwards the adding of tabs to the QTabWidget.
|
||||
"""
|
||||
self._tabBox.addTab(tabWidget, tabLabel)
|
||||
self._tabBox.addTab(widget, label)
|
||||
return
|
||||
|
||||
def addControls(self, buttonBar):
|
||||
@@ -431,15 +431,15 @@ class VerticalTabBar(QTabBar):
|
||||
self._mW = novelwriter.CONFIG.pxInt(150)
|
||||
return
|
||||
|
||||
def tabSizeHint(self, theIndex):
|
||||
def tabSizeHint(self, index):
|
||||
"""Returns a transposed size hint for the rotated bar.
|
||||
"""
|
||||
tSize = QTabBar.tabSizeHint(self, theIndex)
|
||||
tSize = QTabBar.tabSizeHint(self, index)
|
||||
tSize.transpose()
|
||||
tSize.setWidth(min(tSize.width(), self._mW))
|
||||
return tSize
|
||||
|
||||
def paintEvent(self, theEvent):
|
||||
def paintEvent(self, event):
|
||||
"""Custom implementation of the label painter that rotates the
|
||||
label 90 degrees.
|
||||
"""
|
||||
|
||||
@@ -81,7 +81,6 @@ class GuiDocEditor(QTextEdit):
|
||||
self.mainConf = novelwriter.CONFIG
|
||||
self.theParent = theParent
|
||||
self.theTheme = theParent.theTheme
|
||||
self.theIndex = theParent.theIndex
|
||||
self.theProject = theParent.theProject
|
||||
|
||||
self._nwDocument = None
|
||||
@@ -403,7 +402,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.document().rootFrame().setFrameFormat(docFrame)
|
||||
|
||||
self.docFooter.updateLineCount()
|
||||
self._docHeaders = self.theIndex.getHandleHeaders(self._docHandle)
|
||||
self._docHeaders = self.theProject.index.getHandleHeaders(self._docHandle)
|
||||
|
||||
qApp.processEvents()
|
||||
self.document().clearUndoRedoStacks()
|
||||
@@ -508,9 +507,9 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
self.setDocumentChanged(False)
|
||||
|
||||
oldHeader = self.theIndex.getHandleHeaderLevel(tHandle)
|
||||
self.theIndex.scanText(tHandle, docText)
|
||||
newHeader = self.theIndex.getHandleHeaderLevel(tHandle)
|
||||
oldHeader = self.theProject.index.getHandleHeaderLevel(tHandle)
|
||||
self.theProject.index.scanText(tHandle, docText)
|
||||
newHeader = self.theProject.index.getHandleHeaderLevel(tHandle)
|
||||
|
||||
if self._updateHeaders(checkLevel=True):
|
||||
self.theParent.requestNovelTreeRefresh()
|
||||
@@ -2005,7 +2004,7 @@ class GuiDocEditor(QTextEdit):
|
||||
if self._docHandle is None:
|
||||
return False
|
||||
|
||||
newHeaders = self.theIndex.getHandleHeaders(self._docHandle)
|
||||
newHeaders = self.theProject.index.getHandleHeaders(self._docHandle)
|
||||
if checkPos:
|
||||
newPos = [x[0] for x in newHeaders]
|
||||
oldPos = [x[0] for x in self._docHeaders]
|
||||
@@ -2704,15 +2703,15 @@ class GuiDocEditHeader(QWidget):
|
||||
|
||||
if self.mainConf.showFullPath:
|
||||
tTitle = []
|
||||
tTree = self.theProject.projTree.getItemPath(tHandle)
|
||||
tTree = self.theProject.tree.getItemPath(tHandle)
|
||||
for aHandle in reversed(tTree):
|
||||
nwItem = self.theProject.projTree[aHandle]
|
||||
nwItem = self.theProject.tree[aHandle]
|
||||
if nwItem is not None:
|
||||
tTitle.append(nwItem.itemName)
|
||||
sSep = " %s " % nwUnicode.U_RSAQUO
|
||||
self.theTitle.setText(sSep.join(tTitle))
|
||||
else:
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
if nwItem is None:
|
||||
return False
|
||||
self.theTitle.setText(nwItem.itemName)
|
||||
@@ -2798,7 +2797,6 @@ class GuiDocEditFooter(QWidget):
|
||||
self.theParent = docEditor.theParent
|
||||
self.theProject = docEditor.theProject
|
||||
self.theTheme = docEditor.theTheme
|
||||
self.optState = docEditor.theProject.optState
|
||||
|
||||
self._theItem = None
|
||||
self._docHandle = None
|
||||
@@ -2921,7 +2919,7 @@ class GuiDocEditFooter(QWidget):
|
||||
logger.verbose("No handle set, so clearing the editor footer")
|
||||
self._theItem = None
|
||||
else:
|
||||
self._theItem = self.theProject.projTree[self._docHandle]
|
||||
self._theItem = self.theProject.tree[self._docHandle]
|
||||
|
||||
self.setHasSelection(False)
|
||||
self.updateInfo()
|
||||
@@ -2945,7 +2943,7 @@ class GuiDocEditFooter(QWidget):
|
||||
else:
|
||||
theStatus, theIcon = self._theItem.getImportStatus()
|
||||
sIcon = theIcon.pixmap(self.sPx, self.sPx)
|
||||
hLevel = self.theParent.theIndex.getHandleHeaderLevel(self._docHandle)
|
||||
hLevel = self.theProject.index.getHandleHeaderLevel(self._docHandle)
|
||||
sText = f"{theStatus} / {self._theItem.describeMe(hLevel)}"
|
||||
|
||||
self.statusIcon.setPixmap(sIcon)
|
||||
|
||||
@@ -55,7 +55,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self.spEnchant = spEnchant
|
||||
self.theParent = theParent
|
||||
self.theTheme = theParent.theTheme
|
||||
self.theIndex = theParent.theIndex
|
||||
self.theProject = theParent.theProject
|
||||
self.theHandle = None
|
||||
self.spellCheck = False
|
||||
self.spellRx = None
|
||||
@@ -287,9 +287,10 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
|
||||
if theText.startswith("@"): # Keywords and commands
|
||||
self.setCurrentBlockState(self.BLOCK_META)
|
||||
tItem = self.theParent.theProject.projTree[self.theHandle]
|
||||
isValid, theBits, thePos = self.theIndex.scanThis(theText)
|
||||
isGood = self.theIndex.checkThese(theBits, tItem)
|
||||
pIndex = self.theProject.index
|
||||
tItem = self.theParent.theProject.tree[self.theHandle]
|
||||
isValid, theBits, thePos = pIndex.scanThis(theText)
|
||||
isGood = pIndex.checkThese(theBits, tItem)
|
||||
if isValid:
|
||||
for n, theBit in enumerate(theBits):
|
||||
xPos = thePos[n]
|
||||
|
||||
@@ -164,7 +164,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
def loadText(self, tHandle, updateHistory=True):
|
||||
"""Load text into the viewer from an item handle.
|
||||
"""
|
||||
if not self.theProject.projTree.checkType(tHandle, nwItemType.FILE):
|
||||
if not self.theProject.tree.checkType(tHandle, nwItemType.FILE):
|
||||
logger.warning("Item not found")
|
||||
return False
|
||||
|
||||
@@ -843,15 +843,15 @@ class GuiDocViewHeader(QWidget):
|
||||
|
||||
if self.mainConf.showFullPath:
|
||||
tTitle = []
|
||||
tTree = self.theProject.projTree.getItemPath(tHandle)
|
||||
tTree = self.theProject.tree.getItemPath(tHandle)
|
||||
for aHandle in reversed(tTree):
|
||||
nwItem = self.theProject.projTree[aHandle]
|
||||
nwItem = self.theProject.tree[aHandle]
|
||||
if nwItem is not None:
|
||||
tTitle.append(nwItem.itemName)
|
||||
sSep = " %s " % nwUnicode.U_RSAQUO
|
||||
self.theTitle.setText(sSep.join(tTitle))
|
||||
else:
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
if nwItem is None:
|
||||
return False
|
||||
self.theTitle.setText(nwItem.itemName)
|
||||
@@ -1179,10 +1179,10 @@ class GuiDocViewDetails(QScrollArea):
|
||||
if self.theParent.docViewer.stickyRef:
|
||||
return
|
||||
|
||||
theRefs = self.theParent.theIndex.getBackReferenceList(tHandle)
|
||||
theRefs = self.theProject.index.getBackReferenceList(tHandle)
|
||||
theList = []
|
||||
for tHandle in theRefs:
|
||||
tItem = self.theProject.projTree[tHandle]
|
||||
tItem = self.theProject.tree[tHandle]
|
||||
if tItem is not None:
|
||||
theList.append("<a href='%s#%s' %s>%s</a>" % (
|
||||
tHandle, theRefs[tHandle], self.linkStyle, tItem.itemName
|
||||
|
||||
@@ -227,7 +227,7 @@ class GuiItemDetails(QWidget):
|
||||
self.clearDetails()
|
||||
return
|
||||
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
if nwItem is None:
|
||||
self.clearDetails()
|
||||
return
|
||||
@@ -269,7 +269,7 @@ class GuiItemDetails(QWidget):
|
||||
# Layout
|
||||
# ======
|
||||
|
||||
hLevel = self.theParent.theIndex.getHandleHeaderLevel(tHandle)
|
||||
hLevel = self.theProject.index.getHandleHeaderLevel(tHandle)
|
||||
usageIcon = self.theTheme.getItemIcon(
|
||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
||||
)
|
||||
|
||||
@@ -54,7 +54,6 @@ class GuiNovelTree(QTreeWidget):
|
||||
self.theParent = theParent
|
||||
self.theTheme = theParent.theTheme
|
||||
self.theProject = theParent.theProject
|
||||
self.theIndex = theParent.theIndex
|
||||
|
||||
# Internal Variables
|
||||
self._treeMap = {}
|
||||
@@ -137,7 +136,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
"""
|
||||
logger.verbose("Requesting refresh of the novel tree")
|
||||
treeChanged = self.theParent.treeView.changedSince(self._lastBuild)
|
||||
indexChanged = self.theIndex.novelChangedSince(self._lastBuild)
|
||||
indexChanged = self.theProject.index.novelChangedSince(self._lastBuild)
|
||||
if not (treeChanged or indexChanged or overRide):
|
||||
logger.verbose("No changes have been made to the novel index")
|
||||
return
|
||||
@@ -158,7 +157,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
def updateWordCounts(self, tHandle):
|
||||
"""Update the word count for a given handle.
|
||||
"""
|
||||
tHeaders = self.theIndex.getHandleWordCounts(tHandle)
|
||||
tHeaders = self.theProject.index.getHandleWordCounts(tHandle)
|
||||
for titleKey, wCount in tHeaders:
|
||||
if titleKey in self._treeMap:
|
||||
self._treeMap[titleKey].setText(self.C_WORDS, f"{wCount:n}")
|
||||
@@ -252,12 +251,12 @@ class GuiNovelTree(QTreeWidget):
|
||||
currChapter = None
|
||||
currScene = None
|
||||
|
||||
for tKey, tHandle, sTitle, novIdx in self.theIndex.novelStructure(skipExcluded=True):
|
||||
for tKey, tHandle, sTitle, novIdx in self.theProject.index.novelStructure(skipExcl=True):
|
||||
|
||||
tItem = self._createTreeItem(tHandle, sTitle, tKey, novIdx)
|
||||
self._treeMap[tKey] = tItem
|
||||
|
||||
tLevel = novIdx["level"]
|
||||
tLevel = novIdx.level
|
||||
if tLevel == "H1":
|
||||
self.addTopLevelItem(tItem)
|
||||
currTitle = tItem
|
||||
@@ -304,18 +303,18 @@ class GuiNovelTree(QTreeWidget):
|
||||
"""Populate a tree item with all the column values.
|
||||
"""
|
||||
newItem = QTreeWidgetItem()
|
||||
hIcon = "doc_%s" % novIdx["level"].lower()
|
||||
hIcon = "doc_%s" % novIdx.level.lower()
|
||||
theData = (tHandle, sTitle[1:].lstrip("0"), titleKey)
|
||||
|
||||
wC = int(novIdx["wCount"])
|
||||
wC = int(novIdx.wordCount)
|
||||
|
||||
newItem.setText(self.C_TITLE, novIdx["title"])
|
||||
newItem.setText(self.C_TITLE, novIdx.title)
|
||||
newItem.setData(self.C_TITLE, Qt.UserRole, theData)
|
||||
newItem.setIcon(self.C_TITLE, self.theTheme.getIcon(hIcon))
|
||||
newItem.setText(self.C_WORDS, f"{wC:n}")
|
||||
newItem.setTextAlignment(self.C_WORDS, Qt.AlignRight)
|
||||
|
||||
theRefs = self.theIndex.getReferences(tHandle, sTitle)
|
||||
theRefs = self.theProject.index.getReferences(tHandle, sTitle)
|
||||
newItem.setText(self.C_POV, ", ".join(theRefs[nwKeyWords.POV_KEY]))
|
||||
|
||||
return newItem
|
||||
|
||||
+36
-36
@@ -227,7 +227,7 @@ class GuiOutlineToolBar(QToolBar):
|
||||
"""Fill the novel combo box.
|
||||
"""
|
||||
self.novelValue.clear()
|
||||
for tHandle, nwItem in self.theProject.projTree.novelRoots().items():
|
||||
for tHandle, nwItem in self.theProject.tree.novelRoots().items():
|
||||
self.novelValue.addItem(
|
||||
self.theTheme.getIcon(nwLabels.CLASS_ICON[nwItem.itemClass]),
|
||||
nwItem.itemName, tHandle
|
||||
@@ -309,8 +309,6 @@ class GuiOutlineView(QTreeWidget):
|
||||
self.theParent = theOutline.theParent
|
||||
self.theProject = theOutline.theParent.theProject
|
||||
self.theTheme = theOutline.theParent.theTheme
|
||||
self.theIndex = theOutline.theParent.theIndex
|
||||
self.optState = theOutline.theParent.theProject.optState
|
||||
|
||||
self.setFrameStyle(QFrame.NoFrame)
|
||||
self.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -410,7 +408,7 @@ class GuiOutlineView(QTreeWidget):
|
||||
|
||||
# If the novel index or novel tree has changed since the tree
|
||||
# was last built, we rebuild the tree from the updated index.
|
||||
indexChanged = self.theIndex.novelChangedSince(self._lastBuild)
|
||||
indexChanged = self.theProject.index.novelChangedSince(self._lastBuild)
|
||||
doBuild = (novelChanged or indexChanged) and self.theProject.autoOutline
|
||||
if doBuild or overRide:
|
||||
logger.debug("Rebuilding Project Outline")
|
||||
@@ -495,10 +493,12 @@ class GuiOutlineView(QTreeWidget):
|
||||
"""Load the state of the main tree header, that is, column order
|
||||
and column width.
|
||||
"""
|
||||
pOptions = self.theProject.options
|
||||
|
||||
# Load whatever we saved last time, regardless of wether it
|
||||
# contains the correct names or number of columns. The names
|
||||
# must be valid though.
|
||||
tempOrder = self.optState.getValue("GuiOutline", "headerOrder", [])
|
||||
tempOrder = pOptions.getValue("GuiOutline", "headerOrder", [])
|
||||
treeOrder = []
|
||||
for hName in tempOrder:
|
||||
try:
|
||||
@@ -521,14 +521,14 @@ class GuiOutlineView(QTreeWidget):
|
||||
|
||||
# We load whatever column widths and hidden states we find in
|
||||
# the file, and leave the rest in their default state.
|
||||
tmpWidth = self.optState.getValue("GuiOutline", "columnWidth", {})
|
||||
tmpWidth = pOptions.getValue("GuiOutline", "columnWidth", {})
|
||||
for hName in tmpWidth:
|
||||
try:
|
||||
self._colWidth[nwOutline[hName]] = self.mainConf.pxInt(tmpWidth[hName])
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'", str(hName))
|
||||
|
||||
tmpHidden = self.optState.getValue("GuiOutline", "columnHidden", {})
|
||||
tmpHidden = pOptions.getValue("GuiOutline", "columnHidden", {})
|
||||
for hName in tmpHidden:
|
||||
try:
|
||||
self._colHidden[nwOutline[hName]] = tmpHidden[hName]
|
||||
@@ -569,10 +569,11 @@ class GuiOutlineView(QTreeWidget):
|
||||
if not logHidden and logWidth > 0:
|
||||
colWidth[hName] = logWidth
|
||||
|
||||
self.optState.setValue("GuiOutline", "headerOrder", treeOrder)
|
||||
self.optState.setValue("GuiOutline", "columnWidth", colWidth)
|
||||
self.optState.setValue("GuiOutline", "columnHidden", colHidden)
|
||||
self.optState.saveSettings()
|
||||
pOptions = self.theProject.options
|
||||
pOptions.setValue("GuiOutline", "headerOrder", treeOrder)
|
||||
pOptions.setValue("GuiOutline", "columnWidth", colWidth)
|
||||
pOptions.setValue("GuiOutline", "columnHidden", colHidden)
|
||||
pOptions.saveSettings()
|
||||
|
||||
return
|
||||
|
||||
@@ -609,11 +610,11 @@ class GuiOutlineView(QTreeWidget):
|
||||
currChapter = None
|
||||
currScene = None
|
||||
|
||||
for tKey, tHandle, sTitle, novIdx in self.theIndex.novelStructure(skipExcluded=True):
|
||||
for _, tHandle, sTitle, novIdx in self.theProject.index.novelStructure(skipExcl=True):
|
||||
|
||||
tItem = self._createTreeItem(tHandle, sTitle, novIdx)
|
||||
|
||||
tLevel = novIdx["level"]
|
||||
tLevel = novIdx.level
|
||||
if tLevel == "H1":
|
||||
self.addTopLevelItem(tItem)
|
||||
currTitle = tItem
|
||||
@@ -659,26 +660,26 @@ class GuiOutlineView(QTreeWidget):
|
||||
def _createTreeItem(self, tHandle, sTitle, novIdx):
|
||||
"""Populate a tree item with all the column values.
|
||||
"""
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
newItem = QTreeWidgetItem()
|
||||
hIcon = "doc_%s" % novIdx["level"].lower()
|
||||
hIcon = "doc_%s" % novIdx.level.lower()
|
||||
|
||||
hLevel = self.theIndex.getHandleHeaderLevel(tHandle)
|
||||
hLevel = self.theProject.index.getHandleHeaderLevel(tHandle)
|
||||
dIcon = self.theTheme.getItemIcon(nwItemType.FILE, None, nwItemLayout.DOCUMENT, hLevel)
|
||||
|
||||
cC = int(novIdx["cCount"])
|
||||
wC = int(novIdx["wCount"])
|
||||
pC = int(novIdx["pCount"])
|
||||
cC = int(novIdx.charCount)
|
||||
wC = int(novIdx.wordCount)
|
||||
pC = int(novIdx.paraCount)
|
||||
|
||||
newItem.setText(self._colIdx[nwOutline.TITLE], novIdx["title"])
|
||||
newItem.setText(self._colIdx[nwOutline.TITLE], novIdx.title)
|
||||
newItem.setData(self._colIdx[nwOutline.TITLE], Qt.UserRole, tHandle)
|
||||
newItem.setIcon(self._colIdx[nwOutline.TITLE], self.theTheme.getIcon(hIcon))
|
||||
newItem.setText(self._colIdx[nwOutline.LEVEL], novIdx["level"])
|
||||
newItem.setText(self._colIdx[nwOutline.LEVEL], novIdx.level)
|
||||
newItem.setText(self._colIdx[nwOutline.LABEL], nwItem.itemName)
|
||||
newItem.setIcon(self._colIdx[nwOutline.LABEL], dIcon)
|
||||
newItem.setText(self._colIdx[nwOutline.LINE], sTitle[1:].lstrip("0"))
|
||||
newItem.setData(self._colIdx[nwOutline.LINE], Qt.UserRole, sTitle)
|
||||
newItem.setText(self._colIdx[nwOutline.SYNOP], novIdx["synopsis"])
|
||||
newItem.setText(self._colIdx[nwOutline.SYNOP], novIdx.synopsis)
|
||||
newItem.setText(self._colIdx[nwOutline.CCOUNT], f"{cC:n}")
|
||||
newItem.setText(self._colIdx[nwOutline.WCOUNT], f"{wC:n}")
|
||||
newItem.setText(self._colIdx[nwOutline.PCOUNT], f"{pC:n}")
|
||||
@@ -686,7 +687,7 @@ class GuiOutlineView(QTreeWidget):
|
||||
newItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignRight)
|
||||
newItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], Qt.AlignRight)
|
||||
|
||||
theRefs = self.theIndex.getReferences(tHandle, sTitle)
|
||||
theRefs = self.theProject.index.getReferences(tHandle, sTitle)
|
||||
newItem.setText(self._colIdx[nwOutline.POV], ", ".join(theRefs[nwKeyWords.POV_KEY]))
|
||||
newItem.setText(self._colIdx[nwOutline.FOCUS], ", ".join(theRefs[nwKeyWords.FOCUS_KEY]))
|
||||
newItem.setText(self._colIdx[nwOutline.CHAR], ", ".join(theRefs[nwKeyWords.CHAR_KEY]))
|
||||
@@ -767,8 +768,6 @@ class GuiOutlineDetails(QScrollArea):
|
||||
self.theParent = theOutline.theParent
|
||||
self.theProject = theOutline.theParent.theProject
|
||||
self.theTheme = theOutline.theParent.theTheme
|
||||
self.theIndex = theOutline.theParent.theIndex
|
||||
self.optState = theOutline.theParent.theProject.optState
|
||||
|
||||
# Sizes
|
||||
minTitle = 30*self.theTheme.textNWidth
|
||||
@@ -1003,32 +1002,33 @@ class GuiOutlineDetails(QScrollArea):
|
||||
"""Update the content of the tree with the given handle and line
|
||||
number pointing to a header.
|
||||
"""
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
novIdx = self.theIndex.getNovelData(tHandle, sTitle)
|
||||
theRefs = self.theIndex.getReferences(tHandle, sTitle)
|
||||
pIndex = self.theProject.index
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
novIdx = pIndex.getNovelData(tHandle, sTitle)
|
||||
theRefs = pIndex.getReferences(tHandle, sTitle)
|
||||
if nwItem is None or novIdx is None:
|
||||
return False
|
||||
|
||||
if novIdx["level"] in self.LVL_MAP:
|
||||
self.titleLabel.setText("<b>%s</b>" % self.tr(self.LVL_MAP[novIdx["level"]]))
|
||||
if novIdx.level in self.LVL_MAP:
|
||||
self.titleLabel.setText("<b>%s</b>" % self.tr(self.LVL_MAP[novIdx.level]))
|
||||
else:
|
||||
self.titleLabel.setText("<b>%s</b>" % self.tr("Title"))
|
||||
self.titleValue.setText(novIdx["title"])
|
||||
self.titleValue.setText(novIdx.title)
|
||||
|
||||
itemStatus, _ = nwItem.getImportStatus()
|
||||
|
||||
self.fileValue.setText(nwItem.itemName)
|
||||
self.itemValue.setText(itemStatus)
|
||||
|
||||
cC = checkInt(novIdx["cCount"], 0)
|
||||
wC = checkInt(novIdx["wCount"], 0)
|
||||
pC = checkInt(novIdx["pCount"], 0)
|
||||
cC = checkInt(novIdx.charCount, 0)
|
||||
wC = checkInt(novIdx.wordCount, 0)
|
||||
pC = checkInt(novIdx.paraCount, 0)
|
||||
|
||||
self.cCValue.setText(f"{cC:n}")
|
||||
self.wCValue.setText(f"{wC:n}")
|
||||
self.pCValue.setText(f"{pC:n}")
|
||||
|
||||
self.synopValue.setText(novIdx["synopsis"])
|
||||
self.synopValue.setText(novIdx.synopsis)
|
||||
|
||||
self.povKeyValue.setText(self._formatTags(theRefs, nwKeyWords.POV_KEY))
|
||||
self.focKeyValue.setText(self._formatTags(theRefs, nwKeyWords.FOCUS_KEY))
|
||||
@@ -1046,7 +1046,7 @@ class GuiOutlineDetails(QScrollArea):
|
||||
def updateClasses(self):
|
||||
"""Update the visibility status of class details.
|
||||
"""
|
||||
usedClasses = self.theProject.projTree.rootClasses()
|
||||
usedClasses = self.theProject.tree.rootClasses()
|
||||
|
||||
pltVisible = nwItemClass.PLOT in usedClasses
|
||||
timVisible = nwItemClass.TIMELINE in usedClasses
|
||||
|
||||
+31
-30
@@ -62,7 +62,6 @@ class GuiProjectTree(QTreeWidget):
|
||||
self.theParent = theParent
|
||||
self.theTheme = theParent.theTheme
|
||||
self.theProject = theParent.theProject
|
||||
self.theIndex = theParent.theIndex
|
||||
|
||||
# Internal Variables
|
||||
self._treeMap = {}
|
||||
@@ -183,14 +182,14 @@ class GuiProjectTree(QTreeWidget):
|
||||
elif itemType in (nwItemType.FILE, nwItemType.FOLDER):
|
||||
|
||||
sHandle = self.getSelectedHandle()
|
||||
if sHandle is None or sHandle not in self.theProject.projTree:
|
||||
if sHandle is None or sHandle not in self.theProject.tree:
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Did not find anywhere to add the file or folder!"
|
||||
), nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
# If the selected item is a file, the new item will be a sibling
|
||||
pItem = self.theProject.projTree[sHandle]
|
||||
pItem = self.theProject.tree[sHandle]
|
||||
if pItem.itemType == nwItemType.FILE:
|
||||
nHandle = sHandle
|
||||
sHandle = pItem.itemParent
|
||||
@@ -198,7 +197,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.error("Internal error") # Bug
|
||||
return False
|
||||
|
||||
if self.theProject.projTree.isTrash(sHandle):
|
||||
if self.theProject.tree.isTrash(sHandle):
|
||||
self.theParent.makeAlert(self.tr(
|
||||
"Cannot add new files or folders to the Trash folder."
|
||||
), nwAlert.ERROR)
|
||||
@@ -224,7 +223,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
# Add the new item to the tree
|
||||
self.revealNewTreeItem(tHandle, nHandle)
|
||||
self.theParent.editItem(tHandle)
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
|
||||
# If this is a folder, return here
|
||||
if nwItem.itemType != nwItemType.FILE:
|
||||
@@ -238,12 +237,14 @@ class GuiProjectTree(QTreeWidget):
|
||||
else:
|
||||
newText = f"# {nwItem.itemName}\n\n"
|
||||
|
||||
pIndex = self.theProject.index
|
||||
|
||||
# Save the text and index it
|
||||
newDoc.writeDocument(newText)
|
||||
self.theIndex.scanText(tHandle, newText)
|
||||
pIndex.scanText(tHandle, newText)
|
||||
|
||||
# Get Word Counts
|
||||
cC, wC, pC = self.theIndex.getCounts(tHandle)
|
||||
cC, wC, pC = pIndex.getCounts(tHandle)
|
||||
nwItem.setCharCount(cC)
|
||||
nwItem.setWordCount(wC)
|
||||
nwItem.setParaCount(pC)
|
||||
@@ -255,7 +256,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
def revealNewTreeItem(self, tHandle, nHandle=None):
|
||||
"""Reveal a newly added project item in the project tree.
|
||||
"""
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
if nwItem is None:
|
||||
return False
|
||||
|
||||
@@ -376,7 +377,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.error("No project open")
|
||||
return False
|
||||
|
||||
trashHandle = self.theProject.projTree.trashRoot()
|
||||
trashHandle = self.theProject.tree.trashRoot()
|
||||
|
||||
logger.debug("Emptying Trash folder")
|
||||
if trashHandle is None:
|
||||
@@ -437,7 +438,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
return False
|
||||
|
||||
trItemS = self._getTreeItem(tHandle)
|
||||
nwItemS = self.theProject.projTree[tHandle]
|
||||
nwItemS = self.theProject.tree[tHandle]
|
||||
|
||||
if trItemS is None or nwItemS is None:
|
||||
logger.error("Could not find tree item for deletion")
|
||||
@@ -479,7 +480,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.error("Could not delete item")
|
||||
return False
|
||||
|
||||
if self.theProject.projTree.isTrash(tHandle):
|
||||
if self.theProject.tree.isTrash(tHandle):
|
||||
# If the file is in the trash folder already, as the
|
||||
# user if they want to permanently delete the file.
|
||||
doPermanent = False
|
||||
@@ -533,7 +534,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
already coming from the project tree.
|
||||
"""
|
||||
trItem = self._getTreeItem(tHandle)
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
if trItem is None or nwItem is None:
|
||||
return
|
||||
|
||||
@@ -545,7 +546,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
expIcon = self.theTheme.getIcon("cross")
|
||||
|
||||
itemStatus, statusIcon = nwItem.getImportStatus()
|
||||
hLevel = self.theIndex.getHandleHeaderLevel(tHandle)
|
||||
hLevel = self.theProject.index.getHandleHeaderLevel(tHandle)
|
||||
itemIcon = self.theTheme.getItemIcon(
|
||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
||||
)
|
||||
@@ -598,10 +599,10 @@ class GuiProjectTree(QTreeWidget):
|
||||
pHandle = pItem.data(self.C_NAME, Qt.UserRole)
|
||||
|
||||
if pHandle:
|
||||
if self.theProject.projTree.checkType(pHandle, nwItemType.FILE):
|
||||
if self.theProject.tree.checkType(pHandle, nwItemType.FILE):
|
||||
# A file has an internal word count we need to account
|
||||
# for, but a folder always has 0 words on its own.
|
||||
pCount += self.theIndex.getCounts(pHandle)[1]
|
||||
pCount += self.theProject.index.getCounts(pHandle)[1]
|
||||
|
||||
self.propagateCount(pHandle, pCount, countChildren=False)
|
||||
|
||||
@@ -713,7 +714,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
if isinstance(selItem, QTreeWidgetItem):
|
||||
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
|
||||
self.setSelectedHandle(tHandle) # Just to be safe
|
||||
tItem = self.theProject.projTree[tHandle]
|
||||
tItem = self.theProject.tree[tHandle]
|
||||
if tItem is not None:
|
||||
if self.ctxMenu.filterActions(tItem):
|
||||
# Only open menu if any actions remain after filter
|
||||
@@ -751,7 +752,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
return
|
||||
|
||||
tHandle = selItem.data(self.C_NAME, Qt.UserRole)
|
||||
tItem = self.theProject.projTree[tHandle]
|
||||
tItem = self.theProject.tree[tHandle]
|
||||
if tItem is None:
|
||||
return
|
||||
|
||||
@@ -799,7 +800,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
"""Run various maintenance tasks for a moved item.
|
||||
"""
|
||||
trItemS = self._getTreeItem(tHandle)
|
||||
nwItemS = self.theProject.projTree[tHandle]
|
||||
nwItemS = self.theProject.tree[tHandle]
|
||||
trItemP = trItemS.parent()
|
||||
if trItemP is None:
|
||||
logger.error("Failed to find new parent item of '%s'", tHandle)
|
||||
@@ -816,13 +817,13 @@ class GuiProjectTree(QTreeWidget):
|
||||
logger.debug("A total of %d item(s) were moved", len(mHandles))
|
||||
for mHandle in mHandles:
|
||||
logger.debug("Updating item '%s'", mHandle)
|
||||
self.theProject.projTree.updateItemData(mHandle)
|
||||
self.theProject.tree.updateItemData(mHandle)
|
||||
|
||||
# Update the index
|
||||
if nwItemS.isInactive():
|
||||
self.theIndex.deleteHandle(mHandle)
|
||||
self.theProject.index.deleteHandle(mHandle)
|
||||
else:
|
||||
self.theIndex.reIndexHandle(mHandle)
|
||||
self.theProject.index.reIndexHandle(mHandle)
|
||||
|
||||
self.setTreeItemValues(mHandle)
|
||||
|
||||
@@ -849,7 +850,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
def _deleteTreeItem(self, tHandle):
|
||||
"""Permanently delete a tree item from the project and the map.
|
||||
"""
|
||||
if self.theProject.projTree.checkType(tHandle, nwItemType.FILE):
|
||||
if self.theProject.tree.checkType(tHandle, nwItemType.FILE):
|
||||
delDoc = NWDoc(self.theProject, tHandle)
|
||||
if not delDoc.deleteDocument():
|
||||
self.theParent.makeAlert([
|
||||
@@ -857,8 +858,8 @@ class GuiProjectTree(QTreeWidget):
|
||||
], nwAlert.ERROR)
|
||||
return False
|
||||
|
||||
self.theIndex.deleteHandle(tHandle)
|
||||
del self.theProject.projTree[tHandle]
|
||||
self.theProject.index.deleteHandle(tHandle)
|
||||
del self.theProject.tree[tHandle]
|
||||
self._treeMap.pop(tHandle, None)
|
||||
|
||||
return True
|
||||
@@ -871,7 +872,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
cCount = tItem.childCount()
|
||||
|
||||
# Update tree-related meta data
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
nwItem.setExpanded(tItem.isExpanded() and cCount > 0)
|
||||
nwItem.setOrder(tIndex)
|
||||
|
||||
@@ -945,7 +946,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
trItem = self._getTreeItem(trashHandle)
|
||||
if trItem is None:
|
||||
trItem = self._addTreeItem(
|
||||
self.theProject.projTree[trashHandle]
|
||||
self.theProject.tree[trashHandle]
|
||||
)
|
||||
if trItem is not None:
|
||||
trItem.setExpanded(True)
|
||||
@@ -965,8 +966,8 @@ class GuiProjectTree(QTreeWidget):
|
||||
def _emitItemChange(self, tHandle):
|
||||
"""Emit an item change signal for a given handle.
|
||||
"""
|
||||
if self.theProject.projTree.checkType(tHandle, nwItemType.FILE):
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
if self.theProject.tree.checkType(tHandle, nwItemType.FILE):
|
||||
nwItem = self.theProject.tree[tHandle]
|
||||
if nwItem.isNovelLike():
|
||||
self.novelItemChanged.emit()
|
||||
else:
|
||||
@@ -1049,9 +1050,9 @@ class GuiProjectTreeMenu(QMenu):
|
||||
logger.error("Failed to extract information to build tree context menu")
|
||||
return False
|
||||
|
||||
trashHandle = self.theTree.theProject.projTree.trashRoot()
|
||||
trashHandle = self.theTree.theProject.tree.trashRoot()
|
||||
|
||||
inTrash = self.theTree.theProject.projTree.isTrash(theItem.itemHandle)
|
||||
inTrash = self.theTree.theProject.tree.isTrash(theItem.itemHandle)
|
||||
isTrash = theItem.itemHandle == trashHandle and trashHandle is not None
|
||||
isFile = theItem.itemType == nwItemType.FILE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user