Add test coverage of template feature

This commit is contained in:
Veronica Berglyd Olsen
2024-02-08 23:10:20 +01:00
parent 4113be7a4c
commit 8ff292fec8
3 changed files with 139 additions and 10 deletions
+6 -4
View File
@@ -659,7 +659,10 @@ class GuiProjectTree(QTreeWidget):
# Set default label and determine if new item is to be added
# as child or sibling to the selected item
if itemType == nwItemType.FILE:
if isNote:
if copyDoc and (cItem := SHARED.project.tree[copyDoc]):
newLabel = cItem.itemName
asChild = sIsParent and pItem.isDocumentLayout()
elif isNote:
newLabel = self.tr("New Note")
asChild = sIsParent
elif hLevel == 2:
@@ -804,8 +807,7 @@ class GuiProjectTree(QTreeWidget):
def renameTreeItem(self, tHandle: str, name: str = "") -> None:
"""Open a dialog to edit the label of an item."""
tItem = SHARED.project.tree[tHandle]
if tItem:
if tItem := SHARED.project.tree[tHandle]:
newLabel, dlgOk = GuiEditLabel.getLabel(self, text=name or tItem.itemName)
if dlgOk:
tItem.setName(newLabel)
@@ -1707,7 +1709,7 @@ class _UpdatableMenu(QMenu):
if action := self._map.pop(tHandle, None):
self.removeAction(action)
if not self._map:
self.setActionsVisible(True)
self.setActionsVisible(False)
return
def clearMenu(self) -> None: