From 1e8da2a350ed25ce6cddfc93e287e5bafa633f0f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 25 Jan 2017 18:36:36 +0100 Subject: Implement move to folder per D&D We have to trigger the drop explicitly in onReleased. Interestingly if we use "Drag.dragType: Drag.Automatic" then we don't need to explicitly call drop() and the drag and drop behaviour works as expected, but we end up no longer dragging the actual item from the listview, which is what we wanted to do (although we'll have to deal with the item reappering in the list only to then vanish from the actual move). It seems Drag.Automatic triggers a new style of drag that is now recommended but entirely undocumented, and we're doing some old-style/ backwardscompatible drag... --- components/package/contents/ui/FolderListView.qml | 6 ++++++ components/package/contents/ui/MailListView.qml | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'components/package/contents') diff --git a/components/package/contents/ui/FolderListView.qml b/components/package/contents/ui/FolderListView.qml index e7db2905..bc2932de 100644 --- a/components/package/contents/ui/FolderListView.qml +++ b/components/package/contents/ui/FolderListView.qml @@ -135,6 +135,12 @@ Rectangle { visible: parent.containsDrag } + onDropped: { + folderController.folder = model.domainObject + folderController.mail = drop.source.mail + folderController.moveToFolderAction.execute() + drop.accept(Qt.MoveAction) + } } Text { diff --git a/components/package/contents/ui/MailListView.qml b/components/package/contents/ui/MailListView.qml index 63d285e8..a26dcc2b 100644 --- a/components/package/contents/ui/MailListView.qml +++ b/components/package/contents/ui/MailListView.qml @@ -141,6 +141,8 @@ Item { Item { id: delegateRoot + property variant mail : model.domainObject + width: scrollbar.visible ? listView.width - scrollbar.width : listView.width height: Kirigami.Units.gridUnit * 5 @@ -185,6 +187,7 @@ Item { Drag.active: mouseArea.drag.active Drag.hotSpot.x: mouseArea.mouseX Drag.hotSpot.y: mouseArea.mouseY + Drag.source: delegateRoot MouseArea { id: mouseArea @@ -197,6 +200,7 @@ Item { onClicked: { listView.currentIndex = index } + onReleased: parent.Drag.drop() } Rectangle { -- cgit v1.2.3