From 0f67e9b97114645f0c64eed0289869a2f80dbb50 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 23 Oct 2019 20:32:12 +0200 Subject: [PATCH] Improve the error messages when adding a new file or folder without selecting a location --- nw/gui/doctree.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py index 48898952..1d47bcee 100644 --- a/nw/gui/doctree.py +++ b/nw/gui/doctree.py @@ -98,8 +98,16 @@ class GuiDocTree(QTreeWidget): if itemClass is None and pHandle is not None: itemClass = self.theProject.getItem(pHandle).itemClass + if itemClass is None: - self.makeAlert("Failed to find an appropriate item class for item %s" % pHandle, nwAlert.BUG) + if itemType is not None: + if itemType == nwItemType.FILE: + self.makeAlert("Please select a location in the tree to add a document.", nwAlert.ERROR) + return False + elif itemType == nwItemType.FOLDER: + self.makeAlert("Please select a location in the tree to add a folder.", nwAlert.ERROR) + return False + self.makeAlert("Failed to add new item.", nwAlert.BUG) return False logger.verbose("Adding new item of type %s and class %s to handle %s" % (