Allow folders in Outtakes root folder as it seems to be working as intended with the current logic
This commit is contained in:
+30
-21
@@ -59,6 +59,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.theTheme = theParent.theTheme
|
self.theTheme = theParent.theTheme
|
||||||
self.theProject = theParent.theProject
|
self.theProject = theParent.theProject
|
||||||
|
self.theIndex = theParent.theIndex
|
||||||
|
|
||||||
# Tree Settings
|
# Tree Settings
|
||||||
self.theMap = None
|
self.theMap = None
|
||||||
@@ -145,6 +146,9 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if not self.theParent.hasProject:
|
if not self.theParent.hasProject:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# The item needs to be assigned an item class, so one must be
|
||||||
|
# provided, or it must be possible to extract it from the parent
|
||||||
|
# item of the new item.
|
||||||
if itemClass is None and pHandle is not None:
|
if itemClass is None and pHandle is not None:
|
||||||
pItem = self.theProject.projTree[pHandle]
|
pItem = self.theProject.projTree[pHandle]
|
||||||
if pItem is not None:
|
if pItem is not None:
|
||||||
@@ -167,6 +171,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.makeAlert("Failed to add new item.", nwAlert.BUG)
|
self.makeAlert("Failed to add new item.", nwAlert.BUG)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Everything is fine, we have what we need, so we proceed
|
||||||
logger.verbose("Adding new item of type %s and class %s to handle %s" % (
|
logger.verbose("Adding new item of type %s and class %s to handle %s" % (
|
||||||
itemType.name, itemClass.name, str(pHandle))
|
itemType.name, itemClass.name, str(pHandle))
|
||||||
)
|
)
|
||||||
@@ -182,7 +187,9 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
# If still nothing, give up
|
# If still nothing, give up
|
||||||
if pHandle is None:
|
if pHandle is None:
|
||||||
logger.error("Did not find anywhere to add the item!")
|
self.makeAlert(
|
||||||
|
"Did not find anywhere to add the file or folder!", nwAlert.ERROR
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Now check if the selected item is a file, in which case
|
# Now check if the selected item is a file, in which case
|
||||||
@@ -207,14 +214,6 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if pItem.itemClass == nwItemClass.ARCHIVE:
|
|
||||||
self.makeAlert(
|
|
||||||
"Cannot add new files or folders to the %s folder." % (
|
|
||||||
nwLabels.CLASS_NAME[nwItemClass.ARCHIVE]
|
|
||||||
), nwAlert.ERROR
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
# If we're still here, add the file or folder
|
# If we're still here, add the file or folder
|
||||||
if itemType == nwItemType.FILE:
|
if itemType == nwItemType.FILE:
|
||||||
tHandle = self.theProject.newFile("New File", itemClass, pHandle)
|
tHandle = self.theProject.newFile("New File", itemClass, pHandle)
|
||||||
@@ -226,7 +225,6 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
# Add the new item to the tree
|
# Add the new item to the tree
|
||||||
self.revealTreeItem(tHandle, nHandle)
|
self.revealTreeItem(tHandle, nHandle)
|
||||||
self.theParent.editItem()
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -332,7 +330,9 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
logger.debug("Emptying Trash folder")
|
logger.debug("Emptying Trash folder")
|
||||||
if trashHandle is None:
|
if trashHandle is None:
|
||||||
self.makeAlert("There is no Trash folder.", nwAlert.INFO)
|
self.makeAlert(
|
||||||
|
"There is currently no Trash folder in this project.", nwAlert.INFO
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
theTrash = self.getTreeFromHandle(trashHandle)
|
theTrash = self.getTreeFromHandle(trashHandle)
|
||||||
@@ -341,13 +341,13 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
nTrash = len(theTrash)
|
nTrash = len(theTrash)
|
||||||
if nTrash == 0:
|
if nTrash == 0:
|
||||||
self.makeAlert("The Trash folder is empty.", nwAlert.INFO)
|
self.makeAlert("The Trash folder is already empty.", nwAlert.INFO)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgRes = msgBox.question(
|
msgRes = msgBox.question(
|
||||||
self, "Empty Trash", "Permanently delete %d file%s from Trash?" % (
|
self, "Empty Trash", "Permanently delete %d file%s from Trash?" % (
|
||||||
nTrash, "s"*int(nTrash > 1)
|
nTrash, "s" if nTrash > 1 else ""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if msgRes != QMessageBox.Yes:
|
if msgRes != QMessageBox.Yes:
|
||||||
@@ -420,7 +420,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
theDoc = NWDoc(self.theProject, self.theParent)
|
theDoc = NWDoc(self.theProject, self.theParent)
|
||||||
theDoc.deleteDocument(tHandle)
|
theDoc.deleteDocument(tHandle)
|
||||||
del self.theProject.projTree[tHandle]
|
del self.theProject.projTree[tHandle]
|
||||||
self.theParent.theIndex.deleteHandle(tHandle)
|
self.theIndex.deleteHandle(tHandle)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# The file is not already in the trash folder, so we
|
# The file is not already in the trash folder, so we
|
||||||
@@ -448,7 +448,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.propagateCount(tHandle, wCount)
|
self.propagateCount(tHandle, wCount)
|
||||||
|
|
||||||
self._setTreeChanged(True)
|
self._setTreeChanged(True)
|
||||||
self.theParent.theIndex.deleteHandle(tHandle)
|
self.theIndex.deleteHandle(tHandle)
|
||||||
|
|
||||||
elif nwItemS.itemType == nwItemType.FOLDER:
|
elif nwItemS.itemType == nwItemType.FOLDER:
|
||||||
logger.debug("User requested folder %s deleted" % tHandle)
|
logger.debug("User requested folder %s deleted" % tHandle)
|
||||||
@@ -461,7 +461,11 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
trItemP.takeChild(tIndex)
|
trItemP.takeChild(tIndex)
|
||||||
del self.theProject.projTree[tHandle]
|
del self.theProject.projTree[tHandle]
|
||||||
else:
|
else:
|
||||||
self.makeAlert("Cannot delete folder. It is not empty.", nwAlert.ERROR)
|
self.makeAlert((
|
||||||
|
"Cannot delete folder. It is not empty. "
|
||||||
|
"Recursive deletion is not supported. "
|
||||||
|
"Please delete the content first."
|
||||||
|
), nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif nwItemS.itemType == nwItemType.ROOT:
|
elif nwItemS.itemType == nwItemType.ROOT:
|
||||||
@@ -473,7 +477,11 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.theParent.mainMenu.setAvailableRoot()
|
self.theParent.mainMenu.setAvailableRoot()
|
||||||
self._setTreeChanged(True)
|
self._setTreeChanged(True)
|
||||||
else:
|
else:
|
||||||
self.makeAlert("Cannot delete root folder. It is not empty.", nwAlert.ERROR)
|
self.makeAlert((
|
||||||
|
"Cannot delete root folder. It is not empty. "
|
||||||
|
"Recursive deletion is not supported. "
|
||||||
|
"Please delete the content first."
|
||||||
|
), nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -710,11 +718,12 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.propagateCount(sHandle, wCount)
|
self.propagateCount(sHandle, wCount)
|
||||||
|
|
||||||
# The items dropped into archive or trash should be removed
|
# The items dropped into archive or trash should be removed
|
||||||
# from the project index
|
# from the project index, for all other items, we rescan the
|
||||||
|
# file to ensure the index is up to date.
|
||||||
if onFree:
|
if onFree:
|
||||||
self.theParent.theIndex.deleteHandle(sHandle)
|
self.theIndex.deleteHandle(sHandle)
|
||||||
else:
|
else:
|
||||||
self.theParent.theIndex.reIndexHandle(sHandle)
|
self.theIndex.reIndexHandle(sHandle)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.debug("Drag'n'drop of item %s not accepted" % sHandle)
|
logger.debug("Drag'n'drop of item %s not accepted" % sHandle)
|
||||||
@@ -964,7 +973,7 @@ class GuiProjectTreeMenu(QMenu):
|
|||||||
showEdit = not isTrash and not isOrph
|
showEdit = not isTrash and not isOrph
|
||||||
showExport = isFile and not inTrash and not isOrph
|
showExport = isFile and not inTrash and not isOrph
|
||||||
showNewFile = not isTrash and not inTrash and not isOrph and not isArch
|
showNewFile = not isTrash and not inTrash and not isOrph and not isArch
|
||||||
showNewFolder = not isTrash and not inTrash and not isOrph and not isArch
|
showNewFolder = not isTrash and not inTrash and not isOrph
|
||||||
showDelete = not isTrash
|
showDelete = not isTrash
|
||||||
showEmpty = isTrash
|
showEmpty = isTrash
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user