Fix a couple of issues with the project tree context menu where the new file/folder was not showing if the trash folder was None, and isArch was wrong for files in subfolders

This commit is contained in:
Veronica K. B. Olsen
2020-09-20 12:39:35 +02:00
parent b9f983a348
commit 3b1c03329a
+11 -8
View File
@@ -985,23 +985,26 @@ class GuiProjectTreeMenu(QMenu):
"""Update item settings from the nwItem. """Update item settings from the nwItem.
""" """
self.theItem = theItem self.theItem = theItem
trashHandle = self.theTree.theProject.projTree.trashRoot() theRoot = self.theTree.theProject.projTree.getRootItem(theItem.itemHandle)
if theItem is None: if theItem is None or theRoot is None:
logger.error("Failed to extract information to build tree context menu")
return False return False
inTrash = theItem.parHandle == trashHandle trashHandle = self.theTree.theProject.projTree.trashRoot()
isTrash = theItem.itemHandle == trashHandle
inTrash = theItem.parHandle == trashHandle and trashHandle is not None
isTrash = theItem.itemHandle == trashHandle and trashHandle is not None
isFile = theItem.itemType == nwItemType.FILE isFile = theItem.itemType == nwItemType.FILE
isArch = theItem.itemClass == nwItemClass.ARCHIVE isArch = theRoot.itemClass == nwItemClass.ARCHIVE
isOrph = isFile and theItem.parHandle is None isOrph = isFile and theItem.parHandle is None
showOpen = isFile showOpen = isFile
showView = isFile showView = isFile
showEdit = not isTrash and not isOrph showEdit = not isTrash and not isOrph
showExport = isFile and not inTrash and not isOrph showExport = isFile
showNewFile = not isTrash and not inTrash and not isOrph and not isArch showNewFile = not (isTrash or inTrash or isOrph or isArch)
showNewFolder = not isTrash and not inTrash and not isOrph showNewFolder = not (isTrash or inTrash or isOrph)
showDelete = not isTrash showDelete = not isTrash
showEmpty = isTrash showEmpty = isTrash