From 90b4528b846542bfa6f0723487315140b9de17b4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Sep 2019 18:10:59 +0200 Subject: Avoid discouraged patterns in examples In particular, use required properties where applicable, explicitly import QtQml where we use it, avoid unqualified access into the root scope of a component, use JavaScript functions with explicit parameters as signal handlers. Change-Id: I3eaaba47cc3c7a2a12d488e36f9eec145cedbb0e Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- .../externaldraganddrop/DragAndDropTextItem.qml | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'examples/quick/externaldraganddrop') diff --git a/examples/quick/externaldraganddrop/DragAndDropTextItem.qml b/examples/quick/externaldraganddrop/DragAndDropTextItem.qml index 9858a961c9..605dc07434 100644 --- a/examples/quick/externaldraganddrop/DragAndDropTextItem.qml +++ b/examples/quick/externaldraganddrop/DragAndDropTextItem.qml @@ -71,14 +71,18 @@ Rectangle { id: dropArea anchors.fill: parent keys: ["text/plain"] - onEntered: if (!acceptDropCB.checked) { - drag.accepted = false - rejectAnimation.start() + onEntered: (drag) => { + if (!acceptDropCB.checked) { + drag.accepted = false + rejectAnimation.start() + } } - onDropped: if (drop.hasText && acceptDropCB.checked) { - if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) { - item.display = drop.text - drop.acceptProposedAction() + onDropped: (drop) => { + if (drop.hasText && acceptDropCB.checked) { + if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) { + item.display = drop.text + drop.acceptProposedAction() + } } } } @@ -95,7 +99,10 @@ Rectangle { Drag.hotSpot.y: 0 Drag.mimeData: { "text/plain": item.display } Drag.dragType: Drag.Automatic - Drag.onDragFinished: if (dropAction == Qt.MoveAction) item.display = "" + Drag.onDragFinished: (dropAction) => { + if (dropAction == Qt.MoveAction) + item.display = "" + } } Examples.CheckBox { id: acceptDropCB -- cgit v1.2.3