Fix drag start: let startDrag() activate the automatic drag

The grip set dragProxy.Drag.active = true and then called startDrag().
For a Drag.Automatic drag that is wrong — startDrag() is what activates
the drag — so it raised "startDrag() drag must be active", the OS drag
never began, and every target showed the no-drop cursor.

Remove the manual active assignment; call startDrag() alone (it runs the
platform drag and blocks until it completes). Add Drag.proposedAction =
MoveAction. Do the drag cleanup in onReleased via commitDrop(), which
commits when the drop landed on a valid outline target and otherwise just
clears the drag state.

GUI builds clean.
This commit is contained in:
Levi Neely 2026-10-05 09:44:30 +02:00
parent b329bcebd0
commit a3d2c4947e
1 changed files with 9 additions and 8 deletions

View File

@ -572,9 +572,9 @@ ListView {
Item {
id: dragProxy
anchors.fill: parent
Drag.active: false
Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.MoveAction
Drag.proposedAction: Qt.MoveAction
Drag.keys: ["ork-section"]
}
@ -591,22 +591,23 @@ ListView {
if (started) return
started = true
// Record the drag source in the model (survives a
// later file switch) and begin the OS drag.
// later file switch) and begin the OS drag. For a
// Drag.Automatic drag, startDrag() activates it —
// do NOT set Drag.active manually first.
docModel.beginDrag(del.index)
outline.dragActive = true
dragProxy.Drag.mimeData = {
"text/plain": docModel.dragSourceDoc()
+ "\t" + docModel.dragSourceId()
}
dragProxy.Drag.active = true
dragProxy.Drag.startDrag()
}
onReleased: {
// If the drag never produced a drop, clean up.
if (outline.dragActive && !started) {
outline.dragActive = false
docModel.endDrag()
}
// startDrag() blocks until the OS drag finishes, so
// by here the drop (if any) has been handled by a
// DropArea. Clear any drag state that a drop didn't.
if (outline.dragActive)
outline.commitDrop()
started = false
}
}