From 5a30426e079a220b8257aab6edcc6bab5cc16a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Thu, 7 Mar 2013 01:08:55 +0100 Subject: [PATCH] test mimedata attachment and transport from drag to drop area Works for me. --- .../draganddrop/DeclarativeDropArea.cpp | 2 +- .../contents/ui/DragPage.qml | 43 ++++++++++++++++--- .../contents/ui/testcomponents.qml | 8 ++-- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/declarativeimports/draganddrop/DeclarativeDropArea.cpp b/src/declarativeimports/draganddrop/DeclarativeDropArea.cpp index ff1c9ef4f..ea23dd266 100644 --- a/src/declarativeimports/draganddrop/DeclarativeDropArea.cpp +++ b/src/declarativeimports/draganddrop/DeclarativeDropArea.cpp @@ -57,7 +57,7 @@ void DeclarativeDropArea::dragLeaveEvent(QDragLeaveEvent *event) void DeclarativeDropArea::dragMoveEvent(QDragMoveEvent *event) { DeclarativeDragDropEvent dde(event, this); - qDebug() << "move."; + //qDebug() << "move."; event->accept(); emit dragMove(&dde); } diff --git a/src/shell/applets/testcomponentsapplet/contents/ui/DragPage.qml b/src/shell/applets/testcomponentsapplet/contents/ui/DragPage.qml index 7eb1f97af..337fd2b6a 100644 --- a/src/shell/applets/testcomponentsapplet/contents/ui/DragPage.qml +++ b/src/shell/applets/testcomponentsapplet/contents/ui/DragPage.qml @@ -45,28 +45,57 @@ PlasmaComponents.Page { DragAndDrop.DragArea { width: parent.width / 2 - delegate: Rectangle { width: 64; height: 64; color: "yellow"; opacity: 0.6; } anchors { left: parent.left; bottom: parent.bottom; top: parent.top; } - Rectangle { anchors.fill: parent; color: "blue"; opacity: 0.2; } + + mimeData.text: "Clownfish" + mimeData.html: "

Swimming in a sea of cheese

" + mimeData.color: "orange" + mimeData.url: "http://plasma.kde.org" + mimeData.urls: ["http://planetkde.org", "http://fsfe.org", "http://techbase.kde.org", "http://qt-project.org"] + + //delegate: Rectangle { width: 64; height: 64; color: "yellow"; opacity: 0.6; } + onDragStarted: print("started"); onDrop: print("drop: " + action); + + Rectangle { anchors.fill: parent; color: "blue"; opacity: 1; } } DragAndDrop.DropArea { width: parent.width / 2 + //visible: false anchors { right: parent.right; bottom: parent.bottom; top: parent.top; } - Rectangle { anchors.fill: parent; color: "green"; opacity: 0.2; } + Rectangle { id: clr; anchors.fill: parent; color: "green"; opacity: 1; } - onDrop: slabel.text = "item dropped" - onDragEnter: slabel.text = "drop item here" - onDragLeave: slabel.text = "drop left" + onDragEnter: { + slabel.text = "drop item here"; + clr.color = "turquoise"; + } + onDragLeave: { + slabel.text = "drop left"; + clr.color = "green"; + } + onDrop: { + var txt = event.mimeData.html; + txt += event.mimeData.text; + txt += "
Url: " + event.mimeData.url; + var i = 0; + var u; + for (u in event.mimeData.urls) { + i++; + txt += "
Url " + i + " : " + event.mimeData.urls[i]; + } + clr.color = event.mimeData.color; + slabel.text = txt + "
(item dropped)"; + } } PlasmaExtras.Heading { id: slabel level: 3 text: "drag from left to right field." onTextChanged: print("droparea changed to " + text) - anchors { right: parent.right; bottom: parent.bottom; } + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; } + horizontalAlignment: Text.AlignRight } } // QtExtras.MouseEventListener { diff --git a/src/shell/applets/testcomponentsapplet/contents/ui/testcomponents.qml b/src/shell/applets/testcomponentsapplet/contents/ui/testcomponents.qml index b5e6e7587..ce062ec7e 100644 --- a/src/shell/applets/testcomponentsapplet/contents/ui/testcomponents.qml +++ b/src/shell/applets/testcomponentsapplet/contents/ui/testcomponents.qml @@ -46,12 +46,12 @@ Item { } height: _h + PlasmaComponents.TabButton { tab: dragPage; iconSource: "preferences-desktop-mouse"} PlasmaComponents.TabButton { tab: dialogsPage; iconSource: "preferences-system-windows"} PlasmaComponents.TabButton { tab: buttonsPage; iconSource: "preferences-desktop-theme"} PlasmaComponents.TabButton { tab: iconsPage; iconSource: "preferences-desktop-icons"} PlasmaComponents.TabButton { tab: plasmoidPage; iconSource: "plasma"} PlasmaComponents.TabButton { tab: mousePage; iconSource: "preferences-desktop-mouse"} - PlasmaComponents.TabButton { tab: dragPage; iconSource: "preferences-desktop-mouse"} } PlasmaComponents.TabGroup { @@ -65,6 +65,9 @@ Item { //currentTab: tabBar.currentTab + DragPage { + id: dragPage + } DialogsPage { id: dialogsPage } @@ -85,9 +88,6 @@ Item { id: mousePage } - DragPage { - id: dragPage - } } Component.onCompleted: {