Add status column to project outline (#2088)
This commit is contained in:
@@ -301,6 +301,7 @@ class nwLabels:
|
|||||||
nwOutline.LEVEL: QT_TRANSLATE_NOOP("Constant", "Level"),
|
nwOutline.LEVEL: QT_TRANSLATE_NOOP("Constant", "Level"),
|
||||||
nwOutline.LABEL: QT_TRANSLATE_NOOP("Constant", "Document"),
|
nwOutline.LABEL: QT_TRANSLATE_NOOP("Constant", "Document"),
|
||||||
nwOutline.LINE: QT_TRANSLATE_NOOP("Constant", "Line"),
|
nwOutline.LINE: QT_TRANSLATE_NOOP("Constant", "Line"),
|
||||||
|
nwOutline.STATUS: QT_TRANSLATE_NOOP("Constant", "Status"),
|
||||||
nwOutline.CCOUNT: QT_TRANSLATE_NOOP("Constant", "Chars"),
|
nwOutline.CCOUNT: QT_TRANSLATE_NOOP("Constant", "Chars"),
|
||||||
nwOutline.WCOUNT: QT_TRANSLATE_NOOP("Constant", "Words"),
|
nwOutline.WCOUNT: QT_TRANSLATE_NOOP("Constant", "Words"),
|
||||||
nwOutline.PCOUNT: QT_TRANSLATE_NOOP("Constant", "Pars"),
|
nwOutline.PCOUNT: QT_TRANSLATE_NOOP("Constant", "Pars"),
|
||||||
|
|||||||
+16
-15
@@ -162,21 +162,22 @@ class nwOutline(Enum):
|
|||||||
LEVEL = 1
|
LEVEL = 1
|
||||||
LABEL = 2
|
LABEL = 2
|
||||||
LINE = 3
|
LINE = 3
|
||||||
CCOUNT = 4
|
STATUS = 4
|
||||||
WCOUNT = 5
|
CCOUNT = 5
|
||||||
PCOUNT = 6
|
WCOUNT = 6
|
||||||
POV = 7
|
PCOUNT = 7
|
||||||
FOCUS = 8
|
POV = 8
|
||||||
CHAR = 9
|
FOCUS = 9
|
||||||
PLOT = 10
|
CHAR = 10
|
||||||
TIME = 11
|
PLOT = 11
|
||||||
WORLD = 12
|
TIME = 12
|
||||||
OBJECT = 13
|
WORLD = 13
|
||||||
ENTITY = 14
|
OBJECT = 14
|
||||||
CUSTOM = 15
|
ENTITY = 15
|
||||||
STORY = 16
|
CUSTOM = 16
|
||||||
MENTION = 17
|
STORY = 17
|
||||||
SYNOP = 18
|
MENTION = 18
|
||||||
|
SYNOP = 19
|
||||||
|
|
||||||
|
|
||||||
class nwBuildFmt(Enum):
|
class nwBuildFmt(Enum):
|
||||||
|
|||||||
@@ -318,6 +318,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
nwOutline.LEVEL: 40,
|
nwOutline.LEVEL: 40,
|
||||||
nwOutline.LABEL: 150,
|
nwOutline.LABEL: 150,
|
||||||
nwOutline.LINE: 40,
|
nwOutline.LINE: 40,
|
||||||
|
nwOutline.STATUS: 100,
|
||||||
nwOutline.CCOUNT: 50,
|
nwOutline.CCOUNT: 50,
|
||||||
nwOutline.WCOUNT: 50,
|
nwOutline.WCOUNT: 50,
|
||||||
nwOutline.PCOUNT: 50,
|
nwOutline.PCOUNT: 50,
|
||||||
@@ -340,6 +341,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
nwOutline.LEVEL: True,
|
nwOutline.LEVEL: True,
|
||||||
nwOutline.LABEL: False,
|
nwOutline.LABEL: False,
|
||||||
nwOutline.LINE: True,
|
nwOutline.LINE: True,
|
||||||
|
nwOutline.STATUS: True,
|
||||||
nwOutline.CCOUNT: True,
|
nwOutline.CCOUNT: True,
|
||||||
nwOutline.WCOUNT: False,
|
nwOutline.WCOUNT: False,
|
||||||
nwOutline.PCOUNT: False,
|
nwOutline.PCOUNT: False,
|
||||||
@@ -471,8 +473,10 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def refreshTree(self, rootHandle: str | None = None,
|
def refreshTree(
|
||||||
overRide: bool = False, novelChanged: bool = False) -> None:
|
self, rootHandle: str | None = None,
|
||||||
|
overRide: bool = False, novelChanged: bool = False
|
||||||
|
) -> None:
|
||||||
"""Called whenever the Outline tab is activated and controls
|
"""Called whenever the Outline tab is activated and controls
|
||||||
what data to load, and if necessary, force a rebuild of the
|
what data to load, and if necessary, force a rebuild of the
|
||||||
tree.
|
tree.
|
||||||
@@ -659,6 +663,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
is fast and doesn't require a rebuild of the tree.
|
is fast and doesn't require a rebuild of the tree.
|
||||||
"""
|
"""
|
||||||
logger.debug("Rebuilding Outline tree")
|
logger.debug("Rebuilding Outline tree")
|
||||||
|
tStart = time()
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
if self._firstView:
|
if self._firstView:
|
||||||
@@ -691,6 +696,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
nwItem = SHARED.project.tree[tHandle]
|
nwItem = SHARED.project.tree[tHandle]
|
||||||
if iLevel == 0 or nwItem is None:
|
if iLevel == 0 or nwItem is None:
|
||||||
continue
|
continue
|
||||||
|
sLabel, sIcon = nwItem.getImportStatus()
|
||||||
|
|
||||||
item = QTreeWidgetItem()
|
item = QTreeWidgetItem()
|
||||||
hDec = SHARED.theme.getHeaderDecoration(iLevel)
|
hDec = SHARED.theme.getHeaderDecoration(iLevel)
|
||||||
@@ -704,6 +710,8 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
item.setIcon(self._colIdx[nwOutline.LABEL], self._dIcon[nwItem.mainHeading])
|
item.setIcon(self._colIdx[nwOutline.LABEL], self._dIcon[nwItem.mainHeading])
|
||||||
item.setText(self._colIdx[nwOutline.LABEL], nwItem.itemName)
|
item.setText(self._colIdx[nwOutline.LABEL], nwItem.itemName)
|
||||||
item.setText(self._colIdx[nwOutline.LINE], f"{novIdx.line:n}")
|
item.setText(self._colIdx[nwOutline.LINE], f"{novIdx.line:n}")
|
||||||
|
item.setText(self._colIdx[nwOutline.STATUS], sLabel)
|
||||||
|
item.setIcon(self._colIdx[nwOutline.STATUS], sIcon)
|
||||||
item.setText(self._colIdx[nwOutline.SYNOP], novIdx.synopsis)
|
item.setText(self._colIdx[nwOutline.SYNOP], novIdx.synopsis)
|
||||||
item.setText(self._colIdx[nwOutline.CCOUNT], f"{novIdx.charCount:n}")
|
item.setText(self._colIdx[nwOutline.CCOUNT], f"{novIdx.charCount:n}")
|
||||||
item.setText(self._colIdx[nwOutline.WCOUNT], f"{novIdx.wordCount:n}")
|
item.setText(self._colIdx[nwOutline.WCOUNT], f"{novIdx.wordCount:n}")
|
||||||
@@ -728,6 +736,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
self.addTopLevelItem(item)
|
self.addTopLevelItem(item)
|
||||||
|
|
||||||
self._lastBuild = time()
|
self._lastBuild = time()
|
||||||
|
logger.debug("Project outline built in %.3f ms", 1000.0*(time() - tStart))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -166,12 +166,12 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, projPath):
|
|||||||
|
|
||||||
# Current Order
|
# Current Order
|
||||||
order = [outlineTree._colIdx[col] for col in outlineTree._treeOrder]
|
order = [outlineTree._colIdx[col] for col in outlineTree._treeOrder]
|
||||||
assert order == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
|
assert order == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
|
||||||
|
|
||||||
# Move 3 to 0
|
# Move 3 to 0
|
||||||
outlineTree._columnMoved(0, 3, 0)
|
outlineTree._columnMoved(0, 3, 0)
|
||||||
order = [outlineTree._colIdx[col] for col in outlineTree._treeOrder]
|
order = [outlineTree._colIdx[col] for col in outlineTree._treeOrder]
|
||||||
assert order == [3, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
|
assert order == [3, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user