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:
parent
b329bcebd0
commit
a3d2c4947e
|
|
@ -572,9 +572,9 @@ ListView {
|
||||||
Item {
|
Item {
|
||||||
id: dragProxy
|
id: dragProxy
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
Drag.active: false
|
|
||||||
Drag.dragType: Drag.Automatic
|
Drag.dragType: Drag.Automatic
|
||||||
Drag.supportedActions: Qt.MoveAction
|
Drag.supportedActions: Qt.MoveAction
|
||||||
|
Drag.proposedAction: Qt.MoveAction
|
||||||
Drag.keys: ["ork-section"]
|
Drag.keys: ["ork-section"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -591,22 +591,23 @@ ListView {
|
||||||
if (started) return
|
if (started) return
|
||||||
started = true
|
started = true
|
||||||
// Record the drag source in the model (survives a
|
// 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)
|
docModel.beginDrag(del.index)
|
||||||
outline.dragActive = true
|
outline.dragActive = true
|
||||||
dragProxy.Drag.mimeData = {
|
dragProxy.Drag.mimeData = {
|
||||||
"text/plain": docModel.dragSourceDoc()
|
"text/plain": docModel.dragSourceDoc()
|
||||||
+ "\t" + docModel.dragSourceId()
|
+ "\t" + docModel.dragSourceId()
|
||||||
}
|
}
|
||||||
dragProxy.Drag.active = true
|
|
||||||
dragProxy.Drag.startDrag()
|
dragProxy.Drag.startDrag()
|
||||||
}
|
}
|
||||||
onReleased: {
|
onReleased: {
|
||||||
// If the drag never produced a drop, clean up.
|
// startDrag() blocks until the OS drag finishes, so
|
||||||
if (outline.dragActive && !started) {
|
// by here the drop (if any) has been handled by a
|
||||||
outline.dragActive = false
|
// DropArea. Clear any drag state that a drop didn't.
|
||||||
docModel.endDrag()
|
if (outline.dragActive)
|
||||||
}
|
outline.commitDrop()
|
||||||
started = false
|
started = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue