Update classes and functions to use the item as source of main heading instead of index
This commit is contained in:
@@ -91,7 +91,7 @@ class DocMerger:
|
|||||||
docText = (inDoc.readDocument() or "").rstrip("\n")
|
docText = (inDoc.readDocument() or "").rstrip("\n")
|
||||||
|
|
||||||
if addComment:
|
if addComment:
|
||||||
docInfo = srcItem.describeMe("H0")
|
docInfo = srcItem.describeMe()
|
||||||
docSt, _ = srcItem.getImportStatus(incIcon=False)
|
docSt, _ = srcItem.getImportStatus(incIcon=False)
|
||||||
cmtLine = f"% {cmtPrefix} {docInfo}: {srcItem.itemName} [{docSt}]\n\n"
|
cmtLine = f"% {cmtPrefix} {docInfo}: {srcItem.itemName} [{docSt}]\n\n"
|
||||||
docText = cmtLine + docText
|
docText = cmtLine + docText
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ class NWItem:
|
|||||||
# Lookup Methods
|
# Lookup Methods
|
||||||
##
|
##
|
||||||
|
|
||||||
def describeMe(self, hLevel=None):
|
def describeMe(self):
|
||||||
"""Return a string description of the item.
|
"""Return a string description of the item.
|
||||||
"""
|
"""
|
||||||
descKey = "none"
|
descKey = "none"
|
||||||
@@ -286,13 +286,13 @@ class NWItem:
|
|||||||
descKey = "folder"
|
descKey = "folder"
|
||||||
elif self._type == nwItemType.FILE:
|
elif self._type == nwItemType.FILE:
|
||||||
if self._layout == nwItemLayout.DOCUMENT:
|
if self._layout == nwItemLayout.DOCUMENT:
|
||||||
if hLevel == "H1":
|
if self._heading == "H1":
|
||||||
descKey = "doc_h1"
|
descKey = "doc_h1"
|
||||||
elif hLevel == "H2":
|
elif self._heading == "H2":
|
||||||
descKey = "doc_h2"
|
descKey = "doc_h2"
|
||||||
elif hLevel == "H3":
|
elif self._heading == "H3":
|
||||||
descKey = "doc_h3"
|
descKey = "doc_h3"
|
||||||
elif hLevel == "H4":
|
elif self._heading == "H4":
|
||||||
descKey = "doc_h4"
|
descKey = "doc_h4"
|
||||||
else:
|
else:
|
||||||
descKey = "document"
|
descKey = "document"
|
||||||
|
|||||||
@@ -155,9 +155,8 @@ class GuiDocMerge(QDialog):
|
|||||||
if nwItem is None or not nwItem.isFileType():
|
if nwItem is None or not nwItem.isFileType():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
hLevel = self.theProject.index.getHandleHeaderLevel(tHandle)
|
|
||||||
itemIcon = self.mainTheme.getItemIcon(
|
itemIcon = self.mainTheme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
||||||
)
|
)
|
||||||
|
|
||||||
newItem = QListWidgetItem()
|
newItem = QListWidgetItem()
|
||||||
|
|||||||
@@ -508,9 +508,9 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
self.setDocumentChanged(False)
|
self.setDocumentChanged(False)
|
||||||
|
|
||||||
oldHeader = self.theProject.index.getHandleHeaderLevel(tHandle)
|
oldHeader = self._nwItem.mainHeading
|
||||||
self.theProject.index.scanText(tHandle, docText)
|
self.theProject.index.scanText(tHandle, docText)
|
||||||
newHeader = self.theProject.index.getHandleHeaderLevel(tHandle)
|
newHeader = self._nwItem.mainHeading
|
||||||
|
|
||||||
# ToDo: This should be a signal
|
# ToDo: This should be a signal
|
||||||
if self._updateHeaders(checkLevel=True):
|
if self._updateHeaders(checkLevel=True):
|
||||||
@@ -2972,8 +2972,7 @@ class GuiDocEditFooter(QWidget):
|
|||||||
else:
|
else:
|
||||||
theStatus, theIcon = self._theItem.getImportStatus()
|
theStatus, theIcon = self._theItem.getImportStatus()
|
||||||
sIcon = theIcon.pixmap(self.sPx, self.sPx)
|
sIcon = theIcon.pixmap(self.sPx, self.sPx)
|
||||||
hLevel = self.theProject.index.getHandleHeaderLevel(self._docHandle)
|
sText = f"{theStatus} / {self._theItem.describeMe()}"
|
||||||
sText = f"{theStatus} / {self._theItem.describeMe(hLevel)}"
|
|
||||||
|
|
||||||
self.statusIcon.setPixmap(sIcon)
|
self.statusIcon.setPixmap(sIcon)
|
||||||
self.statusText.setText(sText)
|
self.statusText.setText(sText)
|
||||||
|
|||||||
@@ -273,12 +273,11 @@ class GuiItemDetails(QWidget):
|
|||||||
# Layout
|
# Layout
|
||||||
# ======
|
# ======
|
||||||
|
|
||||||
hLevel = self.theProject.index.getHandleHeaderLevel(tHandle)
|
|
||||||
usageIcon = self.mainTheme.getItemIcon(
|
usageIcon = self.mainTheme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
||||||
)
|
)
|
||||||
self.usageIcon.setPixmap(usageIcon.pixmap(iPx, iPx))
|
self.usageIcon.setPixmap(usageIcon.pixmap(iPx, iPx))
|
||||||
self.usageData.setText(nwItem.describeMe(hLevel))
|
self.usageData.setText(nwItem.describeMe())
|
||||||
|
|
||||||
# Counts
|
# Counts
|
||||||
# ======
|
# ======
|
||||||
|
|||||||
@@ -685,7 +685,6 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
for _, tHandle, sTitle, novIdx in novStruct:
|
for _, tHandle, sTitle, novIdx in novStruct:
|
||||||
|
|
||||||
iLevel = nwHeaders.H_LEVEL.get(novIdx.level, 0)
|
iLevel = nwHeaders.H_LEVEL.get(novIdx.level, 0)
|
||||||
dLevel = self.theProject.index.getHandleHeaderLevel(tHandle)
|
|
||||||
if iLevel == 0:
|
if iLevel == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -699,7 +698,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
trItem.setData(self._colIdx[nwOutline.TITLE], self.D_TITLE, sTitle)
|
trItem.setData(self._colIdx[nwOutline.TITLE], self.D_TITLE, sTitle)
|
||||||
trItem.setFont(self._colIdx[nwOutline.TITLE], self._hFonts[iLevel])
|
trItem.setFont(self._colIdx[nwOutline.TITLE], self._hFonts[iLevel])
|
||||||
trItem.setText(self._colIdx[nwOutline.LEVEL], novIdx.level)
|
trItem.setText(self._colIdx[nwOutline.LEVEL], novIdx.level)
|
||||||
trItem.setIcon(self._colIdx[nwOutline.LABEL], self._dIcon[dLevel])
|
trItem.setIcon(self._colIdx[nwOutline.LABEL], self._dIcon[nwItem.mainHeading])
|
||||||
trItem.setText(self._colIdx[nwOutline.LABEL], nwItem.itemName)
|
trItem.setText(self._colIdx[nwOutline.LABEL], nwItem.itemName)
|
||||||
trItem.setText(self._colIdx[nwOutline.LINE], sTitle[1:].lstrip("0"))
|
trItem.setText(self._colIdx[nwOutline.LINE], sTitle[1:].lstrip("0"))
|
||||||
trItem.setText(self._colIdx[nwOutline.SYNOP], novIdx.synopsis)
|
trItem.setText(self._colIdx[nwOutline.SYNOP], novIdx.synopsis)
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
# Collect some information about the selected item that
|
# Collect some information about the selected item that
|
||||||
pItem = self.theProject.tree[sHandle]
|
pItem = self.theProject.tree[sHandle]
|
||||||
qItem = self._getTreeItem(sHandle)
|
qItem = self._getTreeItem(sHandle)
|
||||||
sLevel = nwHeaders.H_LEVEL.get(self.theProject.index.getHandleHeaderLevel(sHandle), 0)
|
sLevel = nwHeaders.H_LEVEL.get(pItem.mainHeading, 0)
|
||||||
sIsParent = False if qItem is None else qItem.childCount() > 0
|
sIsParent = False if qItem is None else qItem.childCount() > 0
|
||||||
|
|
||||||
if self.theProject.tree.isTrash(sHandle):
|
if self.theProject.tree.isTrash(sHandle):
|
||||||
@@ -897,7 +897,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
itemStatus, statusIcon = nwItem.getImportStatus()
|
itemStatus, statusIcon = nwItem.getImportStatus()
|
||||||
hLevel = self.theProject.index.getHandleHeaderLevel(tHandle)
|
hLevel = nwItem.mainHeading
|
||||||
itemIcon = self.mainTheme.getItemIcon(
|
itemIcon = self.mainTheme.getItemIcon(
|
||||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user