Add tag value for novel docs in Outline and Novel View (#2428)
This commit is contained in:
@@ -708,17 +708,19 @@ class Index:
|
|||||||
return 0, 0, 0
|
return 0, 0, 0
|
||||||
|
|
||||||
def getReferences(self, tHandle: str, sTitle: str | None = None) -> dict[str, list[str]]:
|
def getReferences(self, tHandle: str, sTitle: str | None = None) -> dict[str, list[str]]:
|
||||||
"""Extract all references made in a file, and optionally title
|
"""Extract all tags and references made in a file, and
|
||||||
section.
|
optionally title section.
|
||||||
"""
|
"""
|
||||||
tRefs = {x: [] for x in nwKeyWords.VALID_KEYS}
|
refs = {x: [] for x in nwKeyWords.VALID_KEYS}
|
||||||
for rTitle, hItem in self._itemIndex.iterItemHeaders(tHandle):
|
for rTitle, hItem in self._itemIndex.iterItemHeaders(tHandle):
|
||||||
if sTitle is None or sTitle == rTitle:
|
if sTitle is None or sTitle == rTitle:
|
||||||
for aTag, refTypes in hItem.references.items():
|
for aTag, refTypes in hItem.references.items():
|
||||||
for refType in refTypes:
|
for refType in refTypes:
|
||||||
if refType in tRefs:
|
if refType in refs:
|
||||||
tRefs[refType].append(self._tagsIndex.tagName(aTag))
|
refs[refType].append(self._tagsIndex.tagName(aTag))
|
||||||
return tRefs
|
if tag := hItem.tag:
|
||||||
|
refs[nwKeyWords.TAG_KEY] = [self._tagsIndex.tagName(tag)]
|
||||||
|
return refs
|
||||||
|
|
||||||
def getReferenceForHeader(self, tHandle: str, nHead: int, keyClass: str) -> list[str]:
|
def getReferenceForHeader(self, tHandle: str, nHead: int, keyClass: str) -> list[str]:
|
||||||
"""Get the display names for a tags class for insertion into a
|
"""Get the display names for a tags class for insertion into a
|
||||||
|
|||||||
@@ -342,12 +342,14 @@ class IndexHeading:
|
|||||||
##
|
##
|
||||||
|
|
||||||
def getReferences(self) -> dict[str, list[str]]:
|
def getReferences(self) -> dict[str, list[str]]:
|
||||||
"""Extract all references for this heading."""
|
"""Extract all tags and references for this heading."""
|
||||||
refs = {x: [] for x in nwKeyWords.VALID_KEYS}
|
refs = {x: [] for x in nwKeyWords.VALID_KEYS}
|
||||||
for tag, types in self._refs.items():
|
for tag, types in self._refs.items():
|
||||||
for keyword in types:
|
for keyword in types:
|
||||||
if keyword in refs and (name := self._cache.tags.tagName(tag)):
|
if keyword in refs and (name := self._cache.tags.tagName(tag)):
|
||||||
refs[keyword].append(name)
|
refs[keyword].append(name)
|
||||||
|
if tag := self._tag:
|
||||||
|
refs[nwKeyWords.TAG_KEY] = [self._cache.tags.tagName(tag)]
|
||||||
return refs
|
return refs
|
||||||
|
|
||||||
def getReferencesByKeyword(self, keyword: str) -> list[str]:
|
def getReferencesByKeyword(self, keyword: str) -> list[str]:
|
||||||
|
|||||||
@@ -593,6 +593,7 @@ class GuiNovelTree(NTreeView):
|
|||||||
lines = []
|
lines = []
|
||||||
if head := SHARED.project.index.getItemHeading(tHandle, sTitle):
|
if head := SHARED.project.index.getItemHeading(tHandle, sTitle):
|
||||||
tags = head.getReferences()
|
tags = head.getReferences()
|
||||||
|
appendTags(tags, nwKeyWords.TAG_KEY, lines)
|
||||||
appendTags(tags, nwKeyWords.POV_KEY, lines)
|
appendTags(tags, nwKeyWords.POV_KEY, lines)
|
||||||
appendTags(tags, nwKeyWords.FOCUS_KEY, lines)
|
appendTags(tags, nwKeyWords.FOCUS_KEY, lines)
|
||||||
appendTags(tags, nwKeyWords.CHAR_KEY, lines)
|
appendTags(tags, nwKeyWords.CHAR_KEY, lines)
|
||||||
|
|||||||
Reference in New Issue
Block a user