Added some extra checks for deleting files when the file is brand new, and updated the test to check it works
This commit is contained in:
+11
-7
@@ -152,15 +152,19 @@ class NWProject():
|
||||
self.projTree.append(None, pHandle, newItem)
|
||||
return newItem.itemHandle
|
||||
|
||||
def addTrash(self):
|
||||
def trashFolder(self):
|
||||
"""Add the special trash root folder to the project.
|
||||
"""
|
||||
newItem = NWItem(self)
|
||||
newItem.setName("Trash")
|
||||
newItem.setType(nwItemType.TRASH)
|
||||
newItem.setClass(nwItemClass.TRASH)
|
||||
self.projTree.append(None, None, newItem)
|
||||
return newItem.itemHandle
|
||||
trashHandle = self.projTree.trashRoot()
|
||||
if trashHandle is None:
|
||||
newItem = NWItem(self)
|
||||
newItem.setName("Trash")
|
||||
newItem.setType(nwItemType.TRASH)
|
||||
newItem.setClass(nwItemClass.TRASH)
|
||||
self.projTree.append(None, None, newItem)
|
||||
return newItem.itemHandle
|
||||
|
||||
return trashHandle
|
||||
|
||||
##
|
||||
# Project Methods
|
||||
|
||||
@@ -200,8 +200,8 @@ class GuiDocTree(QTreeWidget):
|
||||
def revealTreeItem(self, tHandle):
|
||||
"""Reveal a newly added project item in the project tree.
|
||||
"""
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
trItem = self._addTreeItem(nwItem)
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
trItem = self._addTreeItem(nwItem)
|
||||
pHandle = nwItem.parHandle
|
||||
if pHandle is not None and pHandle in self.theMap.keys():
|
||||
self.theMap[pHandle].setExpanded(True)
|
||||
@@ -608,15 +608,15 @@ class GuiDocTree(QTreeWidget):
|
||||
"""Adds the trash root folder if it doesn't already exist in the
|
||||
project tree.
|
||||
"""
|
||||
trashHandle = self.theProject.projTree.trashRoot()
|
||||
trashHandle = self.theProject.trashFolder()
|
||||
if trashHandle is None:
|
||||
self.theProject.addTrash()
|
||||
return None
|
||||
trItem = self._getTreeItem(trashHandle)
|
||||
if trItem is None:
|
||||
trItem = self._addTreeItem(
|
||||
self.theProject.projTree[trashHandle]
|
||||
)
|
||||
trItem.setExpanded(True)
|
||||
else:
|
||||
trItem = self._getTreeItem(trashHandle)
|
||||
return trItem
|
||||
|
||||
def _addOrphanedRoot(self):
|
||||
|
||||
Reference in New Issue
Block a user