Merge release 2.7.1 into 2.8a0

This commit is contained in:
Veronica Berglyd Olsen
2025-06-10 00:10:20 +02:00
33 changed files with 2184 additions and 2150 deletions
@@ -3,6 +3,8 @@
"Short Description": "Krátký popis",
"Footnotes": "Poznámky pod čarou",
"Comment": "Komentář",
"Story Structure": "Struktura příběhu",
"Note": "Poznámka",
"Notes": "Poznámka",
"Tag": "Štítek",
"Point of View": "Úhel pohledu",
+4
View File
@@ -185,6 +185,10 @@ class nwKeyWords:
POV_KEY, FOCUS_KEY, CHAR_KEY, PLOT_KEY, TIME_KEY, WORLD_KEY,
OBJECT_KEY, ENTITY_KEY, CUSTOM_KEY,
]
CAN_LOOKUP: Final[list[str]] = [
POV_KEY, FOCUS_KEY, CHAR_KEY, PLOT_KEY, TIME_KEY, WORLD_KEY,
OBJECT_KEY, ENTITY_KEY, CUSTOM_KEY, STORY_KEY, MENTION_KEY,
]
# Set of Valid Keys
VALID_KEYS: Final[set[str]] = set(ALL_KEYS)
+16 -10
View File
@@ -131,12 +131,6 @@ class Index:
self._novelExtra = extra
return
def setItemClass(self, tHandle: str, itemClass: nwItemClass) -> None:
"""Update the class for all tags of a handle."""
logger.info("Updating class for '%s'", tHandle)
self._tagsIndex.updateClass(tHandle, itemClass.name)
return
##
# Public Methods
##
@@ -183,6 +177,16 @@ class Index:
self.scanText(tHandle, self._project.storage.getDocumentText(tHandle))
return
def refreshHandle(self, tHandle: str) -> None:
"""Update the class for all tags of a handle."""
if item := self._project.tree[tHandle]:
logger.info("Updating class for '%s'", tHandle)
if item.isInactiveClass():
self.deleteHandle(tHandle)
else:
self._tagsIndex.updateClass(tHandle, item.itemClass.name)
return
def indexChangedSince(self, checkTime: int | float) -> bool:
"""Check if the index has changed since a given time."""
return self._indexChange > float(checkTime)
@@ -753,10 +757,12 @@ class Index:
"""Return all tags used by a specific document."""
return self._itemIndex.allItemTags(tHandle) if tHandle else []
def getClassTags(self, itemClass: nwItemClass | None) -> list[str]:
"""Return all tags based on itemClass."""
name = None if itemClass is None else itemClass.name
return self._tagsIndex.filterTagNames(name)
def getKeyWordTags(self, keyWord: str) -> list[str]:
"""Return all tags usable for a specific keyword."""
if keyWord in nwKeyWords.CAN_LOOKUP:
itemClass = nwKeyWords.KEY_CLASS.get(keyWord)
return self._tagsIndex.filterTagNames(itemClass.name if itemClass else None)
return []
def getTagsData(
self, activeOnly: bool = True
+1 -1
View File
@@ -439,7 +439,7 @@ class NWItem:
self.setClass(itemClass)
if self._type == nwItemType.FILE:
# Notify the index of the class change
self._project.index.setItemClass(self._handle, itemClass)
self._project.index.refreshHandle(self._handle)
if self._layout == nwItemLayout.NO_LAYOUT:
# If no layout is set, pick one
+8 -7
View File
@@ -1090,11 +1090,14 @@ class GuiDocEditor(QPlainTextEdit):
show = self._completer.updateMetaText(text, bPos)
else:
show = self._completer.updateCommentText(text, bPos)
point = self.cursorRect().bottomRight()
self._completer.move(viewport.mapToGlobal(point))
self._completer.setVisible(show)
if show:
point = self.cursorRect().bottomRight()
self._completer.move(viewport.mapToGlobal(point))
self._completer.show()
else:
self._completer.close()
else:
self._completer.setVisible(False)
self._completer.close()
if self._doReplace and added == 1:
cursor = self.textCursor()
@@ -2113,9 +2116,7 @@ class CommandCompleter(QMenu):
length = len(lookup)
suffix = ""
options = sorted(filter(
lambda x: lookup in x.lower(), SHARED.project.index.getClassTags(
nwKeyWords.KEY_CLASS.get(kw.strip())
)
lambda x: lookup in x.lower(), SHARED.project.index.getKeyWordTags(kw.strip())
))[:15]
if not options: