Some final tweaks to the drag and drop feature
This commit is contained in:
+15
-7
@@ -837,7 +837,6 @@ class GuiProjectTree(QTreeWidget):
|
||||
return
|
||||
|
||||
sItem = self._getTreeItem(sHandle)
|
||||
pItem = sItem.parent()
|
||||
dItem = self.itemFromIndex(dIndex)
|
||||
dHandle = dItem.data(self.C_NAME, Qt.UserRole)
|
||||
snItem = self.theProject.projTree[sHandle]
|
||||
@@ -846,16 +845,25 @@ class GuiProjectTree(QTreeWidget):
|
||||
self.makeAlert("The item cannot be moved to that location.", nwAlert.ERROR)
|
||||
return
|
||||
|
||||
pItem = sItem.parent()
|
||||
pIndex = 0
|
||||
if pItem is not None:
|
||||
pIndex = pItem.indexOfChild(sItem)
|
||||
|
||||
wCount = int(sItem.data(self.C_COUNT, Qt.UserRole))
|
||||
isFile = snItem.itemType == nwItemType.FILE
|
||||
isRoot = snItem.itemType == nwItemType.ROOT
|
||||
onFile = dnItem.itemType == nwItemType.FILE
|
||||
|
||||
isSame = snItem.itemClass == dnItem.itemClass
|
||||
isNone = snItem.itemClass == nwItemClass.NO_CLASS
|
||||
isNote = snItem.itemLayout == nwItemLayout.NOTE
|
||||
isRoot = snItem.itemType == nwItemType.ROOT
|
||||
isFile = snItem.itemType == nwItemType.FILE
|
||||
onFile = dnItem.itemType == nwItemType.FILE
|
||||
onFree = dnItem.itemClass in nwLists.FREE_CLASS and isFile
|
||||
isOnTop = self.dropIndicatorPosition() == QAbstractItemView.OnItem
|
||||
if (isSame or isNone or isNote or onFree) and not (onFile and isOnTop) and not isRoot:
|
||||
|
||||
allowDrop = isSame or isNone or isNote or onFree
|
||||
allowDrop &= not (self.dropIndicatorPosition() == QAbstractItemView.OnItem and onFile)
|
||||
|
||||
if allowDrop and not isRoot:
|
||||
logger.debug("Drag'n'drop of item %s accepted" % sHandle)
|
||||
self.propagateCount(sHandle, 0)
|
||||
QTreeWidget.dropEvent(self, theEvent)
|
||||
@@ -871,7 +879,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
self.setTreeItemValues(sHandle)
|
||||
|
||||
self.propagateCount(sHandle, wCount)
|
||||
self._recordLastMove(sItem, pItem, pItem.indexOfChild(sItem))
|
||||
self._recordLastMove(sItem, pItem, pIndex)
|
||||
|
||||
# The items dropped into archive or trash should be removed
|
||||
# from the project index, for all other items, we rescan the
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="1.1rc1" hexVersion="0x010100c1" fileVersion="1.2" timeStamp="2021-01-31 18:12:05">
|
||||
<novelWriterXML appVersion="1.2a0" hexVersion="0x010200a0" fileVersion="1.2" timeStamp="2021-01-31 22:28:54">
|
||||
<project>
|
||||
<name>Sample Project</name>
|
||||
<title>Sample Project</title>
|
||||
<author>Jane Smith</author>
|
||||
<author>Jay Doh</author>
|
||||
<saveCount>874</saveCount>
|
||||
<saveCount>881</saveCount>
|
||||
<autoCount>157</autoCount>
|
||||
<editTime>42533</editTime>
|
||||
<editTime>42668</editTime>
|
||||
</project>
|
||||
<settings>
|
||||
<doBackup>False</doBackup>
|
||||
@@ -117,7 +117,7 @@
|
||||
<status>1st Draft</status>
|
||||
<exported>True</exported>
|
||||
<layout>SCENE</layout>
|
||||
<charCount>1811</charCount>
|
||||
<charCount>1810</charCount>
|
||||
<wordCount>318</wordCount>
|
||||
<paraCount>8</paraCount>
|
||||
<cursorPos>1880</cursorPos>
|
||||
|
||||
Reference in New Issue
Block a user