Removed the context menu code.

This commit is contained in:
Veronica K. B. Olsen
2019-04-28 13:25:41 +02:00
parent af9aa08fe6
commit d11a01d6a1
3 changed files with 1 additions and 287 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ logger = logging.getLogger(__name__)
class NWItem():
MAX_DEPTH = 8
MAX_DEPTH = 8
def __init__(self):
-71
View File
@@ -272,77 +272,6 @@ class NWProject():
return self.projTree[aRoot].itemHandle
return None
def getActionList(self, tHandle):
"""Returns a dictionary of possible actions to perform on a give handle.
"""
validActions = {}
# If we're at root, or didn't select an item, all we can add is root stuff
if tHandle is None:
validActions[nwItemAction.ADD_ROOT] = {
"Type" : nwItemType.ROOT,
"Class" : [x for x in nwItemClass if self.checkRootUnique(x)]
}
return validActions
# Otherwise, the options depend on the item we had selected
tItem = self.getItem(tHandle)
tType = tItem.itemType
tClass = tItem.itemClass
tDepth = tItem.itemDepth
# Trash items can only be moved or permanently deleted
if tType == nwItemType.TRASHFOLDER or tType == nwItemType.TRASHFILE:
validActions[nwItemAction.MOVE_TO] = {}
validActions[nwItemAction.DELETE] = {}
validActions[nwItemAction.EMPTY_TRASH] = {}
return validActions
# Adding folders or files
# - Novels can only have folders under root
# - Files can only be 1 or 2 levels deep
# - Non-novel roots have only have a restriction on max depth
if tClass == nwItemClass.NOVEL:
if tType == nwItemType.ROOT:
validActions[nwItemAction.ADD_FOLDER] = {
"Type" : nwItemType.FOLDER,
"Class" : nwItemClass.NOVEL
}
if tDepth < 2:
validActions[nwItemAction.ADD_FILE] = {
"Type" : nwItemType.FILE,
"Class" : nwItemClass.NOVEL
}
if tType == nwItemType.FOLDER:
validActions[nwItemAction.MERGE] = {}
if tType == nwItemType.FILE:
validActions[nwItemAction.SPLIT] = {}
else:
if tDepth < NWItem.MAX_DEPTH-1 and (
tType == nwItemType.ROOT or tType == nwItemType.FOLDER
):
validActions[nwItemAction.ADD_FOLDER] = {
"Type" : nwItemType.FOLDER,
"Class" : tClass
}
if tDepth < NWItem.MAX_DEPTH:
validActions[nwItemAction.ADD_FILE] = {
"Type" : nwItemType.FILE,
"Class" : tClass
}
# Other actions available to novel or plot items
validActions[nwItemAction.RENAME] = {}
validActions[nwItemAction.MOVE_UP] = {}
validActions[nwItemAction.MOVE_DOWN] = {}
if tType == nwItemType.ROOT:
validActions[nwItemAction.DELETE_ROOT] = {}
else:
validActions[nwItemAction.MOVE_TO] = {}
validActions[nwItemAction.MOVE_TRASH] = {}
return validActions
def checkRootUnique(self, theClass):
"""Checks if there already is a root entry of class 'theClass' in the
root of the project tree.