From 1a47bbaf8c1f1bd95979e3cc109842c1ccc69fe0 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 23 Apr 2022 15:53:14 +0200 Subject: [PATCH] Allow files to have child items --- novelwriter/gui/projtree.py | 9 ++--- sample/nwProject.nwx | 68 ++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index 23238b84..c912bb18 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -793,17 +793,12 @@ class GuiProjectTree(QTreeWidget): # - Files can be moved anywhere # - Folders can only be moved within the same root folder # - Root folders cannot be moved at all - # - Items cannot be dropped on top of a file (moved inside) isFile = snItem.itemType == nwItemType.FILE isRoot = snItem.itemType == nwItemType.ROOT - onFile = dnItem.itemType == nwItemType.FILE inSame = snItem.itemRoot == dnItem.itemRoot - allowDrop = inSame or isFile - allowDrop &= not (self.dropIndicatorPosition() == QAbstractItemView.OnItem and onFile) - - if allowDrop and not isRoot: + if (inSame or isFile) and not isRoot: logger.debug("Drag'n'drop of item '%s' accepted", sHandle) wCount = int(sItem.data(self.C_COUNT, Qt.UserRole)) @@ -1057,7 +1052,7 @@ class GuiProjectTreeMenu(QMenu): trashHandle = self.theTree.theProject.projTree.trashRoot() - inTrash = theItem.itemParent == trashHandle and trashHandle is not None + inTrash = self.theTree.theProject.projTree.isTrash(theItem.itemHandle) isTrash = theItem.itemHandle == trashHandle and trashHandle is not None isFile = theItem.itemType == nwItemType.FILE diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx index 23660870..6bb6fdd4 100644 --- a/sample/nwProject.nwx +++ b/sample/nwProject.nwx @@ -1,13 +1,13 @@ - + Sample Project Sample Project Jane Smith Jay Doh - 1306 - 199 - 65149 + 1308 + 201 + 65350 False @@ -54,47 +54,47 @@ Novel - + Title Page - + Page - + Part One A Folder - - - Chapter One - - - - Making a Scene - - - - Another Scene - - - + + Interlude - - + + + Chapter One + + + + Making a Scene + + + + Another Scene + + + A Note on Structure - - + + Chapter Two - - + + We Found John! @@ -106,11 +106,11 @@ Main Characters - + John Smith - + Jane Smith @@ -118,15 +118,15 @@ Locations - + Earth - + Space - + Mars @@ -138,7 +138,7 @@ Scenes - + Old File @@ -146,7 +146,7 @@ Trash - + Delete Me!