Add importance column to document viewer panel (#1620)
This commit is contained in:
@@ -334,13 +334,14 @@ class _ViewPanelBackRefs(QTreeWidget):
|
|||||||
|
|
||||||
class _ViewPanelKeyWords(QTreeWidget):
|
class _ViewPanelKeyWords(QTreeWidget):
|
||||||
|
|
||||||
C_DATA = 0
|
C_DATA = 0
|
||||||
C_NAME = 0
|
C_NAME = 0
|
||||||
C_EDIT = 1
|
C_EDIT = 1
|
||||||
C_VIEW = 2
|
C_VIEW = 2
|
||||||
C_DOC = 3
|
C_IMPORT = 3
|
||||||
C_TITLE = 4
|
C_DOC = 4
|
||||||
C_SHORT = 5
|
C_TITLE = 5
|
||||||
|
C_SHORT = 6
|
||||||
|
|
||||||
D_TAG = Qt.ItemDataRole.UserRole
|
D_TAG = Qt.ItemDataRole.UserRole
|
||||||
|
|
||||||
@@ -355,7 +356,7 @@ class _ViewPanelKeyWords(QTreeWidget):
|
|||||||
cMg = CONFIG.pxInt(6)
|
cMg = CONFIG.pxInt(6)
|
||||||
|
|
||||||
self.setHeaderLabels([
|
self.setHeaderLabels([
|
||||||
self.tr("Tag"), "", "", self.tr("Document"),
|
self.tr("Tag"), "", "", self.tr("Importance"), self.tr("Document"),
|
||||||
self.tr("Heading"), self.tr("Short Description")
|
self.tr("Heading"), self.tr("Short Description")
|
||||||
])
|
])
|
||||||
self.setIndentation(0)
|
self.setIndentation(0)
|
||||||
@@ -371,7 +372,6 @@ class _ViewPanelKeyWords(QTreeWidget):
|
|||||||
treeHeader = self.header()
|
treeHeader = self.header()
|
||||||
treeHeader.setStretchLastSection(True)
|
treeHeader.setStretchLastSection(True)
|
||||||
treeHeader.setMinimumSectionSize(iPx + cMg) # See Issue #1627
|
treeHeader.setMinimumSectionSize(iPx + cMg) # See Issue #1627
|
||||||
treeHeader.setSectionResizeMode(self.C_NAME, QHeaderView.ResizeMode.ResizeToContents)
|
|
||||||
treeHeader.setSectionResizeMode(self.C_EDIT, QHeaderView.ResizeMode.Fixed)
|
treeHeader.setSectionResizeMode(self.C_EDIT, QHeaderView.ResizeMode.Fixed)
|
||||||
treeHeader.setSectionResizeMode(self.C_VIEW, QHeaderView.ResizeMode.Fixed)
|
treeHeader.setSectionResizeMode(self.C_VIEW, QHeaderView.ResizeMode.Fixed)
|
||||||
treeHeader.resizeSection(self.C_EDIT, iPx + cMg)
|
treeHeader.resizeSection(self.C_EDIT, iPx + cMg)
|
||||||
@@ -417,6 +417,7 @@ class _ViewPanelKeyWords(QTreeWidget):
|
|||||||
nwItem.itemType, nwItem.itemClass,
|
nwItem.itemType, nwItem.itemClass,
|
||||||
nwItem.itemLayout, nwItem.mainHeading
|
nwItem.itemLayout, nwItem.mainHeading
|
||||||
)
|
)
|
||||||
|
impLabel, impIcon = nwItem.getImportStatus(incIcon=True)
|
||||||
iLevel = nwHeaders.H_LEVEL.get(hItem.level, 0) if nwItem.isDocumentLayout() else 5
|
iLevel = nwHeaders.H_LEVEL.get(hItem.level, 0) if nwItem.isDocumentLayout() else 5
|
||||||
hDec = SHARED.theme.getHeaderDecorationNarrow(iLevel)
|
hDec = SHARED.theme.getHeaderDecorationNarrow(iLevel)
|
||||||
|
|
||||||
@@ -424,10 +425,12 @@ class _ViewPanelKeyWords(QTreeWidget):
|
|||||||
# instance of the QTreeWidgetItem, which has some weird side effects
|
# instance of the QTreeWidgetItem, which has some weird side effects
|
||||||
trItem = self._treeMap[tag] if tag in self._treeMap else QTreeWidgetItem()
|
trItem = self._treeMap[tag] if tag in self._treeMap else QTreeWidgetItem()
|
||||||
|
|
||||||
trItem.setText(self.C_NAME, name)
|
|
||||||
trItem.setIcon(self.C_NAME, self._classIcon)
|
trItem.setIcon(self.C_NAME, self._classIcon)
|
||||||
|
trItem.setText(self.C_NAME, name)
|
||||||
trItem.setIcon(self.C_EDIT, self._editIcon)
|
trItem.setIcon(self.C_EDIT, self._editIcon)
|
||||||
trItem.setIcon(self.C_VIEW, self._viewIcon)
|
trItem.setIcon(self.C_VIEW, self._viewIcon)
|
||||||
|
trItem.setIcon(self.C_IMPORT, impIcon)
|
||||||
|
trItem.setText(self.C_IMPORT, impLabel)
|
||||||
trItem.setIcon(self.C_DOC, docIcon)
|
trItem.setIcon(self.C_DOC, docIcon)
|
||||||
trItem.setText(self.C_DOC, nwItem.itemName)
|
trItem.setText(self.C_DOC, nwItem.itemName)
|
||||||
trItem.setText(self.C_TITLE, hItem.title)
|
trItem.setText(self.C_TITLE, hItem.title)
|
||||||
@@ -451,14 +454,18 @@ class _ViewPanelKeyWords(QTreeWidget):
|
|||||||
|
|
||||||
def setColumnWidths(self, widths: list[int]) -> None:
|
def setColumnWidths(self, widths: list[int]) -> None:
|
||||||
"""Set the column widths."""
|
"""Set the column widths."""
|
||||||
if isinstance(widths, list) and len(widths) >= 2:
|
if isinstance(widths, list) and len(widths) >= 4:
|
||||||
self.setColumnWidth(self.C_DOC, CONFIG.pxInt(checkInt(widths[0], 100)))
|
self.setColumnWidth(self.C_NAME, CONFIG.pxInt(checkInt(widths[0], 100)))
|
||||||
self.setColumnWidth(self.C_TITLE, CONFIG.pxInt(checkInt(widths[1], 100)))
|
self.setColumnWidth(self.C_IMPORT, CONFIG.pxInt(checkInt(widths[1], 100)))
|
||||||
|
self.setColumnWidth(self.C_DOC, CONFIG.pxInt(checkInt(widths[2], 100)))
|
||||||
|
self.setColumnWidth(self.C_TITLE, CONFIG.pxInt(checkInt(widths[3], 100)))
|
||||||
return
|
return
|
||||||
|
|
||||||
def getColumnWidths(self) -> list[int]:
|
def getColumnWidths(self) -> list[int]:
|
||||||
"""Get the widths of the user-adjustable columns."""
|
"""Get the widths of the user-adjustable columns."""
|
||||||
return [
|
return [
|
||||||
|
CONFIG.rpxInt(self.columnWidth(self.C_NAME)),
|
||||||
|
CONFIG.rpxInt(self.columnWidth(self.C_IMPORT)),
|
||||||
CONFIG.rpxInt(self.columnWidth(self.C_DOC)),
|
CONFIG.rpxInt(self.columnWidth(self.C_DOC)),
|
||||||
CONFIG.rpxInt(self.columnWidth(self.C_TITLE)),
|
CONFIG.rpxInt(self.columnWidth(self.C_TITLE)),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user