1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the examples of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
54 x: rootTarget.dragX - 10
55 y: rootTarget.dragY - 10
59 text: rootTarget.dragData.display
72 sourceComponent: rootTarget.containsDrag ? draggedText : undefined
81 anchors.left: parent.left
82 anchors.verticalCenter: parent.verticalCenter
91 ListElement { display: "1" }
92 ListElement { display: "2" }
93 ListElement { display: "3" }
94 ListElement { display: "4" }
95 ListElement { display: "5" }
96 ListElement { display: "6" }
97 ListElement { display: "7" }
98 ListElement { display: "8" }
99 ListElement { display: "9" }
100 ListElement { display: "10" }
101 ListElement { display: "11" }
102 ListElement { display: "12" }
103 ListElement { display: "13" }
104 ListElement { display: "14" }
105 ListElement { display: "15" }
106 ListElement { display: "16" }
107 ListElement { display: "17" }
108 ListElement { display: "18" }
109 ListElement { display: "19" }
110 ListElement { display: "20" }
111 ListElement { display: "21" }
112 ListElement { display: "22" }
113 ListElement { display: "23" }
114 ListElement { display: "24" }
117 delegate: Rectangle {
127 color: draggable.drag.active ? "gold" : "white"
130 verticalAlignment: Text.AlignVCenter
131 horizontalAlignment: Text.AlignHCenter
137 property int initialIndex
144 drag.target: draggable
147 when: !draggable.drag.active
148 PropertyChanges { target: draggable; x: 0; y: 0 }
158 var index = gridView.indexAt(drag.x, drag.y)
160 gridModel.move(drag.data.index, index, 1)
165 property int dragIndex
170 dragIndex = gridView.indexAt(drag.x, drag.y)
171 if (dragIndex != -1) {
172 gridModel.insert(dragIndex, { "display": drag.data.display })
174 event.accepted = false
178 var index = gridView.indexAt(drag.x, drag.y);
180 gridModel.move(dragIndex, index, 1)
184 onExited: gridModel.remove(dragIndex, 1)
194 anchors.right: parent.right
195 anchors.verticalCenter: parent.verticalCenter
201 ListElement { display: "a" }
202 ListElement { display: "b" }
203 ListElement { display: "c" }
204 ListElement { display: "d"}
205 ListElement { display: "e" }
206 ListElement { display: "f" }
207 ListElement { display: "g" }
208 ListElement { display: "h" }
209 ListElement { display: "i" }
210 ListElement { display: "j" }
211 ListElement { display: "k" }
212 ListElement { display: "l" }
213 ListElement { display: "m" }
214 ListElement { display: "n" }
215 ListElement { display: "o" }
216 ListElement { display: "p" }
217 ListElement { display: "q" }
218 ListElement { display: "r" }
219 ListElement { display: "s" }
220 ListElement { display: "t" }
221 ListElement { display: "u" }
222 ListElement { display: "v" }
223 ListElement { display: "w" }
224 ListElement { display: "x" }
227 delegate: Rectangle {
237 color: draggable.drag.active ? "gold" : "white"
240 verticalAlignment: Text.AlignVCenter
241 horizontalAlignment: Text.AlignHCenter
252 drag.target: draggable
255 when: !draggable.drag.active
256 PropertyChanges { target: draggable; x: 0; y: 0 }
266 var index = listView.indexAt(drag.x, drag.y)
268 listModel.move(drag.data.index, index, 1)
273 property int dragIndex
279 dragIndex = listView.indexAt(drag.x, drag.y)
280 if (dragIndex != -1) {
281 listModel.insert(dragIndex, { "display": drag.data.display })
283 event.accepted = false
287 var index = listView.indexAt(drag.x, drag.y);
289 listModel.move(dragIndex, index, 1)
293 onExited: listModel.remove(dragIndex, 1)