From 574a4bd63ca728c1c97d289fa789275fb3422894 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Fri, 3 May 2019 22:43:56 +0200 Subject: [PATCH] Drag and drop files into folders now works (didn't set parent item properly) --- nw/gui/doctree.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nw/gui/doctree.py b/nw/gui/doctree.py index a7b09a8c..1edc84c7 100644 --- a/nw/gui/doctree.py +++ b/nw/gui/doctree.py @@ -265,6 +265,18 @@ class GuiDocTree(QTreeWidget): self.orphRoot = None return + def _updateItemParent(self, tHandle): + trItemS = self.theMap[tHandle] + nwItemS = self.theProject.getItem(tHandle) + trItemP = trItemS.parent() + if trItemP is None: + logger.error("Failed to find new parent item of %s" % tHandle) + return + pHandle = trItemP.text(self.C_HANDLE) + nwItemS.setParent(pHandle) + self.setTreeItemValues(tHandle) + return + def _moveOrphanedItem(self, tHandle, dHandle): trItemS = self.theMap[tHandle] nwItemS = self.theProject.getItem(tHandle) @@ -372,6 +384,8 @@ class GuiDocTree(QTreeWidget): if isNone: self._moveOrphanedItem(sHandle, dHandle) self._cleanOrphanedRoot() + else: + self._updateItemParent(sHandle) elif isRoot and (isAbove or isBelow) and onRoot: logger.verbose("Drag'n'drop of item %s accepted" % sHandle) QTreeWidget.dropEvent(self, theEvent)