Reworked the way the outline is built with the new index in place
This commit is contained in:
+33
-51
@@ -14,6 +14,7 @@ import logging
|
|||||||
import nw
|
import nw
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
from time import time
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
@@ -86,6 +87,8 @@ class GuiProjectOutline(QWidget):
|
|||||||
self.outerBox = QVBoxLayout()
|
self.outerBox = QVBoxLayout()
|
||||||
self.mainTree = QTreeWidget()
|
self.mainTree = QTreeWidget()
|
||||||
self.treeCols = self.COL_ORDER
|
self.treeCols = self.COL_ORDER
|
||||||
|
self.lastBuild = 0
|
||||||
|
self.treeMap = {}
|
||||||
|
|
||||||
self.outerBox.addWidget(self.mainTree)
|
self.outerBox.addWidget(self.mainTree)
|
||||||
self.outerBox.setContentsMargins(0,0,0,0)
|
self.outerBox.setContentsMargins(0,0,0,0)
|
||||||
@@ -113,20 +116,20 @@ class GuiProjectOutline(QWidget):
|
|||||||
currChapter = None
|
currChapter = None
|
||||||
currScene = None
|
currScene = None
|
||||||
|
|
||||||
theTitles = self.theIndex.getNovelStructure()
|
for titleKey in self.theIndex.getNovelStructure():
|
||||||
|
|
||||||
for tHandle in self.theProject.treeOrder:
|
tHandle = titleKey[:13]
|
||||||
|
sTitle = titleKey[14:]
|
||||||
|
|
||||||
if tHandle not in self.theIndex.novelIndex:
|
if tHandle not in self.theIndex.novelIndex:
|
||||||
continue
|
continue
|
||||||
|
if sTitle not in self.theIndex.novelIndex[tHandle]:
|
||||||
|
continue
|
||||||
|
|
||||||
for sTitle in self.theIndex.novelIndex[tHandle]:
|
|
||||||
|
|
||||||
nwItem = self.theProject.getItem(tHandle)
|
|
||||||
tTitle = self.theIndex.novelIndex[tHandle][sTitle]["title"]
|
|
||||||
tLevel = self.theIndex.novelIndex[tHandle][sTitle]["level"]
|
tLevel = self.theIndex.novelIndex[tHandle][sTitle]["level"]
|
||||||
tLabel = nwItem.itemName
|
tTime = self.theIndex.novelIndex[tHandle][sTitle]["updated"]
|
||||||
tItem = self._createTreeItem(tHandle, sTitle, tTitle, tLevel, tLabel)
|
tItem = self._createTreeItem(tHandle, sTitle)
|
||||||
|
self.treeMap[titleKey] = tItem
|
||||||
|
|
||||||
if tLevel == "H1":
|
if tLevel == "H1":
|
||||||
currTitle = tItem
|
currTitle = tItem
|
||||||
@@ -160,62 +163,41 @@ class GuiProjectOutline(QWidget):
|
|||||||
|
|
||||||
tItem.setExpanded(True)
|
tItem.setExpanded(True)
|
||||||
|
|
||||||
|
self.lastBuild = time()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
def _createTreeItem(self, tHandle, sTitle, tTitle, tLevel, tLabel):
|
def _createTreeItem(self, tHandle, sTitle):
|
||||||
|
|
||||||
|
nwItem = self.theProject.getItem(tHandle)
|
||||||
|
novIdx = self.theIndex.novelIndex[tHandle][sTitle]
|
||||||
|
|
||||||
newItem = QTreeWidgetItem()
|
newItem = QTreeWidgetItem()
|
||||||
newItem.setText(self.I_TITLE, tTitle)
|
newItem.setText(self.I_TITLE, novIdx["title"])
|
||||||
newItem.setText(self.I_LEVEL, tLevel)
|
newItem.setText(self.I_LEVEL, novIdx["level"])
|
||||||
newItem.setText(self.I_LABEL, tLabel)
|
newItem.setText(self.I_LABEL, nwItem.itemName)
|
||||||
newItem.setText(self.I_LINE, sTitle)
|
newItem.setText(self.I_LINE, sTitle[1:])
|
||||||
|
|
||||||
cC, wC, pC = self.theIndex.getCounts(tHandle, sTitle)
|
newItem.setText(self.I_CCOUNT, str(novIdx["cCount"]))
|
||||||
newItem.setText(self.I_CCOUNT, str(cC))
|
newItem.setText(self.I_WCOUNT, str(novIdx["wCount"]))
|
||||||
newItem.setText(self.I_WCOUNT, str(wC))
|
newItem.setText(self.I_PCOUNT, str(novIdx["pCount"]))
|
||||||
newItem.setText(self.I_PCOUNT, str(pC))
|
|
||||||
newItem.setTextAlignment(self.I_CCOUNT,Qt.AlignRight)
|
newItem.setTextAlignment(self.I_CCOUNT,Qt.AlignRight)
|
||||||
newItem.setTextAlignment(self.I_WCOUNT,Qt.AlignRight)
|
newItem.setTextAlignment(self.I_WCOUNT,Qt.AlignRight)
|
||||||
newItem.setTextAlignment(self.I_PCOUNT,Qt.AlignRight)
|
newItem.setTextAlignment(self.I_PCOUNT,Qt.AlignRight)
|
||||||
|
|
||||||
povList = []
|
theRefs = self.theIndex.getReferences(tHandle, sTitle)
|
||||||
charList = []
|
newItem.setText(self.I_POV, ", ".join(theRefs[nwKeyWords.POV_KEY]))
|
||||||
plotList = []
|
newItem.setText(self.I_CHAR, ", ".join(theRefs[nwKeyWords.CHAR_KEY]))
|
||||||
timeList = []
|
newItem.setText(self.I_PLOT, ", ".join(theRefs[nwKeyWords.PLOT_KEY]))
|
||||||
worldList = []
|
newItem.setText(self.I_TIME, ", ".join(theRefs[nwKeyWords.TIME_KEY]))
|
||||||
objectList = []
|
newItem.setText(self.I_WORLD, ", ".join(theRefs[nwKeyWords.WORLD_KEY]))
|
||||||
entityList = []
|
newItem.setText(self.I_OBJECT, ", ".join(theRefs[nwKeyWords.OBJECT_KEY]))
|
||||||
customList = []
|
newItem.setText(self.I_ENTITY, ", ".join(theRefs[nwKeyWords.ENTITY_KEY]))
|
||||||
for tKey, tTag in self.theIndex.getReferences(tHandle, sTitle):
|
newItem.setText(self.I_CUSTOM, ", ".join(theRefs[nwKeyWords.CUSTOM_KEY]))
|
||||||
if tKey == nwKeyWords.POV_KEY:
|
|
||||||
povList.append(tTag)
|
|
||||||
elif tKey == nwKeyWords.CHAR_KEY:
|
|
||||||
charList.append(tTag)
|
|
||||||
elif tKey == nwKeyWords.PLOT_KEY:
|
|
||||||
plotList.append(tTag)
|
|
||||||
elif tKey == nwKeyWords.TIME_KEY:
|
|
||||||
timeList.append(tTag)
|
|
||||||
elif tKey == nwKeyWords.WORLD_KEY:
|
|
||||||
worldList.append(tTag)
|
|
||||||
elif tKey == nwKeyWords.OBJECT_KEY:
|
|
||||||
objectList.append(tTag)
|
|
||||||
elif tKey == nwKeyWords.ENTITY_KEY:
|
|
||||||
entityList.append(tTag)
|
|
||||||
elif tKey == nwKeyWords.CUSTOM_KEY:
|
|
||||||
customList.append(tTag)
|
|
||||||
|
|
||||||
newItem.setText(self.I_POV, ", ".join(povList))
|
|
||||||
newItem.setText(self.I_CHAR, ", ".join(charList))
|
|
||||||
newItem.setText(self.I_PLOT, ", ".join(plotList))
|
|
||||||
newItem.setText(self.I_TIME, ", ".join(timeList))
|
|
||||||
newItem.setText(self.I_WORLD, ", ".join(worldList))
|
|
||||||
newItem.setText(self.I_OBJECT, ", ".join(objectList))
|
|
||||||
newItem.setText(self.I_ENTITY, ", ".join(entityList))
|
|
||||||
newItem.setText(self.I_CUSTOM, ", ".join(customList))
|
|
||||||
|
|
||||||
return newItem
|
return newItem
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -528,14 +528,21 @@ class NWIndex():
|
|||||||
section. tTitle must be a string.
|
section. tTitle must be a string.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
theRefs = []
|
theRefs = {}
|
||||||
|
for tKey in self.TAG_CLASS:
|
||||||
|
theRefs[tKey] = []
|
||||||
|
|
||||||
if tHandle not in self.refIndex:
|
if tHandle not in self.refIndex:
|
||||||
return theRefs
|
return theRefs
|
||||||
|
|
||||||
|
try:
|
||||||
for sTitle in self.refIndex[tHandle]:
|
for sTitle in self.refIndex[tHandle]:
|
||||||
for nLine, tKey, tTag in self.refIndex[tHandle][sTitle]["tags"]:
|
for nLine, tKey, tTag in self.refIndex[tHandle][sTitle]["tags"]:
|
||||||
if tTitle is None or tTitle == sTitle:
|
if tTitle is None or tTitle == sTitle:
|
||||||
theRefs.append((tKey, tTag))
|
theRefs[tKey].append(tTag)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Failed to generate reference list")
|
||||||
|
logger.error(str(e))
|
||||||
|
|
||||||
return theRefs
|
return theRefs
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user