Update Project Tree (#847)
* Rename index textCounts to fileMeta and add main header level * Add new icons for document layouts * Add function in NWItem to describe the item * Use the icons and description in the project tree and details panel * Remove flags column and add status column with optional full text * Update handling and display of header level in editor * Fix potential bug in project tree * Update tests
This commit is contained in:
committed by
GitHub
parent
cf7cd5502c
commit
97aebc5b84
@@ -7,7 +7,10 @@ guidark = False
|
||||
guifont =
|
||||
guifontsize = 11
|
||||
lastnotes = 0x0
|
||||
guilang = en-GB
|
||||
guilang = en_GB
|
||||
hidevscroll = False
|
||||
hidehscroll = False
|
||||
fullstatus = True
|
||||
|
||||
[Sizes]
|
||||
geometry = 1200, 650
|
||||
@@ -20,8 +23,6 @@ docpane = 400, 400
|
||||
viewpane = 500, 150
|
||||
outlinepane = 500, 150
|
||||
fullscreen = False
|
||||
hidevscroll = False
|
||||
hidehscroll = False
|
||||
|
||||
[Project]
|
||||
autosaveproject = 60
|
||||
|
||||
@@ -79,21 +79,21 @@
|
||||
"T000001": {"level": "H1", "title": "Ancient Europe", "layout": "NOTE", "cCount": 1770, "wCount": 259, "pCount": 3, "synopsis": ""}
|
||||
}
|
||||
},
|
||||
"textCounts": {
|
||||
"7a992350f3eb6": [230, 40, 3],
|
||||
"8c58a65414c23": [1058, 176, 2],
|
||||
"88d59a277361b": [584, 92, 1],
|
||||
"db7e733775d4d": [35, 6, 1],
|
||||
"fb609cd8319dc": [419, 67, 1],
|
||||
"88243afbe5ed8": [2758, 404, 4],
|
||||
"f96ec11c6a3da": [4043, 600, 6],
|
||||
"846352075de7d": [631, 109, 3],
|
||||
"441420a886d82": [477, 70, 1],
|
||||
"eb103bc70c90c": [3006, 439, 4],
|
||||
"f8c0562e50f1b": [3839, 563, 6],
|
||||
"47666c91c7ccf": [3644, 543, 5],
|
||||
"4c4f28287af27": [1864, 284, 3],
|
||||
"2426c6f0ca922": [1369, 195, 2],
|
||||
"04468803b92e1": [1770, 259, 3]
|
||||
"fileMeta": {
|
||||
"7a992350f3eb6": ["H1", 230, 40, 3],
|
||||
"8c58a65414c23": ["H0", 1058, 176, 2],
|
||||
"88d59a277361b": ["H2", 584, 92, 1],
|
||||
"db7e733775d4d": ["H1", 35, 6, 1],
|
||||
"fb609cd8319dc": ["H2", 419, 67, 1],
|
||||
"88243afbe5ed8": ["H3", 2758, 404, 4],
|
||||
"f96ec11c6a3da": ["H3", 4043, 600, 6],
|
||||
"846352075de7d": ["H2", 631, 109, 3],
|
||||
"441420a886d82": ["H2", 477, 70, 1],
|
||||
"eb103bc70c90c": ["H3", 3006, 439, 4],
|
||||
"f8c0562e50f1b": ["H3", 3839, 563, 6],
|
||||
"47666c91c7ccf": ["H3", 3644, 543, 5],
|
||||
"4c4f28287af27": ["H1", 1864, 284, 3],
|
||||
"2426c6f0ca922": ["H1", 1369, 195, 2],
|
||||
"04468803b92e1": ["H1", 1770, 259, 3]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ guidark = True
|
||||
guifont = Sans
|
||||
guifontsize = 12
|
||||
lastnotes = 0x0
|
||||
guilang = en-GB
|
||||
guilang = en_GB
|
||||
hidevscroll = True
|
||||
hidehscroll = True
|
||||
fullstatus = True
|
||||
|
||||
[Sizes]
|
||||
geometry = 1200, 650
|
||||
@@ -20,8 +23,6 @@ docpane = 400, 400
|
||||
viewpane = 500, 150
|
||||
outlinepane = 500, 150
|
||||
fullscreen = False
|
||||
hidevscroll = True
|
||||
hidehscroll = True
|
||||
|
||||
[Project]
|
||||
autosaveproject = 40
|
||||
|
||||
@@ -72,25 +72,25 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, mockGUI, outDir, refDir):
|
||||
tagIndex = str(theIndex._tagIndex)
|
||||
refIndex = str(theIndex._refIndex)
|
||||
fileIndex = str(theIndex._fileIndex)
|
||||
textCounts = str(theIndex._textCounts)
|
||||
textCounts = str(theIndex._fileMeta)
|
||||
|
||||
# Delete a handle
|
||||
assert theIndex._tagIndex.get("Bod", None) is not None
|
||||
assert theIndex._refIndex.get("4c4f28287af27", None) is not None
|
||||
assert theIndex._fileIndex.get("4c4f28287af27", None) is not None
|
||||
assert theIndex._textCounts.get("4c4f28287af27", None) is not None
|
||||
assert theIndex._fileMeta.get("4c4f28287af27", None) is not None
|
||||
theIndex.deleteHandle("4c4f28287af27")
|
||||
assert theIndex._tagIndex.get("Bod", None) is None
|
||||
assert theIndex._refIndex.get("4c4f28287af27", None) is None
|
||||
assert theIndex._fileIndex.get("4c4f28287af27", None) is None
|
||||
assert theIndex._textCounts.get("4c4f28287af27", None) is None
|
||||
assert theIndex._fileMeta.get("4c4f28287af27", None) is None
|
||||
|
||||
# Clear the index
|
||||
theIndex.clearIndex()
|
||||
assert theIndex._tagIndex == {}
|
||||
assert theIndex._refIndex == {}
|
||||
assert theIndex._fileIndex == {}
|
||||
assert theIndex._textCounts == {}
|
||||
assert theIndex._fileMeta == {}
|
||||
|
||||
# Make the load fail
|
||||
with monkeypatch.context() as mp:
|
||||
@@ -103,7 +103,7 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, mockGUI, outDir, refDir):
|
||||
assert str(theIndex._tagIndex) == tagIndex
|
||||
assert str(theIndex._refIndex) == refIndex
|
||||
assert str(theIndex._fileIndex) == fileIndex
|
||||
assert str(theIndex._textCounts) == textCounts
|
||||
assert str(theIndex._fileMeta) == textCounts
|
||||
|
||||
# Break the index and check that we notice
|
||||
assert theIndex.indexBroken is False
|
||||
@@ -1162,58 +1162,66 @@ def testCoreIndex_CheckFileIndex(mockGUI):
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreIndex_CheckTextCounts(mockGUI):
|
||||
"""Test the text counts checker.
|
||||
def testCoreIndex_CheckFileMeta(mockGUI):
|
||||
"""Test the file meta checker.
|
||||
"""
|
||||
theProject = NWProject(mockGUI)
|
||||
theIndex = NWIndex(theProject)
|
||||
|
||||
# Valid Index
|
||||
theIndex._textCounts = {
|
||||
"53b69b83cdafc": [72, 15, 2],
|
||||
"974e400180a99": [210, 40, 2],
|
||||
theIndex._fileMeta = {
|
||||
"53b69b83cdafc": ["H0", 72, 15, 2],
|
||||
"974e400180a99": ["H0", 210, 40, 2],
|
||||
}
|
||||
assert theIndex._checkTextCounts() is None
|
||||
assert theIndex._checkFileMeta() is None
|
||||
|
||||
# Invalid Handle
|
||||
theIndex._textCounts = {
|
||||
"53b69b83cdafc": [72, 15, 2],
|
||||
"h74e400180a99": [210, 40, 2],
|
||||
theIndex._fileMeta = {
|
||||
"53b69b83cdafc": ["H0", 72, 15, 2],
|
||||
"h74e400180a99": ["H0", 210, 40, 2],
|
||||
}
|
||||
with pytest.raises(KeyError):
|
||||
theIndex._checkTextCounts()
|
||||
theIndex._checkFileMeta()
|
||||
|
||||
# Wrong Length
|
||||
theIndex._textCounts = {
|
||||
"53b69b83cdafc": [72, 15, 2],
|
||||
"974e400180a99": [210, 40, 2, 8],
|
||||
theIndex._fileMeta = {
|
||||
"53b69b83cdafc": ["H0", 72, 15, 2],
|
||||
"974e400180a99": ["H0", 210, 40, 2, 8],
|
||||
}
|
||||
with pytest.raises(IndexError):
|
||||
theIndex._checkTextCounts()
|
||||
theIndex._checkFileMeta()
|
||||
|
||||
# Type of Entry 0
|
||||
theIndex._textCounts = {
|
||||
"53b69b83cdafc": [72, 15, 2],
|
||||
"974e400180a99": ["210", 40, 2],
|
||||
# Content of Entry 0
|
||||
theIndex._fileMeta = {
|
||||
"53b69b83cdafc": ["H0", 72, 15, 2],
|
||||
"974e400180a99": ["XXX", 210, 40, 2],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkTextCounts()
|
||||
theIndex._checkFileMeta()
|
||||
|
||||
# Type of Entry 1
|
||||
theIndex._textCounts = {
|
||||
"53b69b83cdafc": [72, 15, 2],
|
||||
"974e400180a99": [210, "40", 2],
|
||||
theIndex._fileMeta = {
|
||||
"53b69b83cdafc": ["H0", 72, 15, 2],
|
||||
"974e400180a99": ["H0", "210", 40, 2],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkTextCounts()
|
||||
theIndex._checkFileMeta()
|
||||
|
||||
# Type of Entry 2
|
||||
theIndex._textCounts = {
|
||||
"53b69b83cdafc": [72, 15, 2],
|
||||
"974e400180a99": [210, 40, "2"],
|
||||
theIndex._fileMeta = {
|
||||
"53b69b83cdafc": ["H0", 72, 15, 2],
|
||||
"974e400180a99": ["H0", 210, "40", 2],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkTextCounts()
|
||||
theIndex._checkFileMeta()
|
||||
|
||||
# Type of Entry 3
|
||||
theIndex._fileMeta = {
|
||||
"53b69b83cdafc": ["H0", 72, 15, 2],
|
||||
"974e400180a99": ["H0", 210, 40, "2"],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkFileMeta()
|
||||
|
||||
# END Test testCoreIndex_CheckTextCounts
|
||||
|
||||
|
||||
@@ -166,6 +166,39 @@ def testCoreItem_Setters(mockGUI):
|
||||
# END Test testCoreItem_Setters
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreItem_Methods(mockGUI):
|
||||
"""Test the simple methods of the NWItem class.
|
||||
"""
|
||||
theProject = NWProject(mockGUI)
|
||||
theItem = NWItem(theProject)
|
||||
|
||||
# Describe Me
|
||||
# ===========
|
||||
|
||||
assert theItem.describeMe() == "None"
|
||||
|
||||
theItem.setType("ROOT")
|
||||
assert theItem.describeMe() == "Root Folder"
|
||||
|
||||
theItem.setType("FOLDER")
|
||||
assert theItem.describeMe() == "Folder"
|
||||
|
||||
theItem.setType("FILE")
|
||||
theItem.setLayout("DOCUMENT")
|
||||
assert theItem.describeMe() == "Novel Document"
|
||||
assert theItem.describeMe("H0") == "Novel Document"
|
||||
assert theItem.describeMe("H1") == "Novel Title Page"
|
||||
assert theItem.describeMe("H2") == "Novel Chapter"
|
||||
assert theItem.describeMe("H3") == "Novel Scene"
|
||||
assert theItem.describeMe("H4") == "Novel Document"
|
||||
|
||||
theItem.setLayout("NOTE")
|
||||
assert theItem.describeMe() == "Project Note"
|
||||
|
||||
# END Test testCoreItem_Methods
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreItem_TypeSetter(mockGUI):
|
||||
"""Test the setter for all the nwItemType values for the NWItem
|
||||
|
||||
@@ -248,7 +248,7 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
||||
testFile = os.path.join(outDir, "guiPreferences_novelwriter.conf")
|
||||
compFile = os.path.join(refDir, "guiPreferences_novelwriter.conf")
|
||||
copyfile(projFile, testFile)
|
||||
ignoreLines = [2, 9, 10, 13, 14, 15, 16, 17, 18, 19, 20, 7, 30, 31]
|
||||
ignoreLines = [2, 7, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23, 24, 32, 33]
|
||||
assert cmpFiles(testFile, compFile, ignoreLines)
|
||||
|
||||
# Clean up
|
||||
|
||||
Reference in New Issue
Block a user