From a02d08afa3363413af6ba8ab82d638c2ac35b232 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Thu, 31 Oct 2019 12:37:13 +0100 Subject: [PATCH] Block adding new items to Trash or Orphaned root folders --- nw/gui/doctree.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py index cdef8d3f..1ef4f5fa 100644 --- a/nw/gui/doctree.py +++ b/nw/gui/doctree.py @@ -134,10 +134,18 @@ class GuiDocTree(QTreeWidget): # If we again has no home, give up 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 - # If we're still here, add the file + if pHandle == self.theProject.trashRoot: + self.makeAlert("Cannot add new files or folders to the trash folder.", nwAlert.ERROR) + return False + + if pHandle == self.orphRoot: + self.makeAlert("Cannot add new files or folders to the orphaned folder.", nwAlert.ERROR) + return False + + # If we're still here, add the file or folder if itemType == nwItemType.FILE: tHandle = self.theProject.newFile("New File", itemClass, pHandle) elif itemType == nwItemType.FOLDER: