2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-09-12 04:17:08 +00:00
|
|
|
|
2023-03-03 06:34:21 +00:00
|
|
|
pragma ComponentBehavior: Bound
|
2021-09-06 09:25:52 +00:00
|
|
|
import QtQml
|
|
|
|
import QtQuick
|
|
|
|
import QtQml.Models
|
2011-09-12 04:17:08 +00:00
|
|
|
|
|
|
|
GridView {
|
|
|
|
id: root
|
2023-03-03 06:34:21 +00:00
|
|
|
width: 320
|
|
|
|
height: 480
|
|
|
|
cellWidth: 80
|
|
|
|
cellHeight: 80
|
2011-09-12 04:17:08 +00:00
|
|
|
|
2012-02-28 02:00:26 +00:00
|
|
|
displaced: Transition {
|
2023-03-03 06:34:21 +00:00
|
|
|
NumberAnimation {
|
|
|
|
properties: "x,y"
|
|
|
|
easing.type: Easing.OutQuad
|
|
|
|
}
|
2012-02-28 02:00:26 +00:00
|
|
|
}
|
|
|
|
|
2012-04-27 06:35:12 +00:00
|
|
|
//! [0]
|
2013-01-23 22:08:58 +00:00
|
|
|
model: DelegateModel {
|
2012-04-27 06:35:12 +00:00
|
|
|
//! [0]
|
2011-09-12 04:17:08 +00:00
|
|
|
id: visualModel
|
|
|
|
model: ListModel {
|
|
|
|
id: colorModel
|
|
|
|
ListElement { color: "blue" }
|
|
|
|
ListElement { color: "green" }
|
|
|
|
ListElement { color: "red" }
|
|
|
|
ListElement { color: "yellow" }
|
|
|
|
ListElement { color: "orange" }
|
|
|
|
ListElement { color: "purple" }
|
|
|
|
ListElement { color: "cyan" }
|
|
|
|
ListElement { color: "magenta" }
|
|
|
|
ListElement { color: "chartreuse" }
|
|
|
|
ListElement { color: "aquamarine" }
|
|
|
|
ListElement { color: "indigo" }
|
|
|
|
ListElement { color: "black" }
|
2012-02-28 01:33:51 +00:00
|
|
|
ListElement { color: "lightsteelblue" }
|
2011-09-12 04:17:08 +00:00
|
|
|
ListElement { color: "violet" }
|
|
|
|
ListElement { color: "grey" }
|
|
|
|
ListElement { color: "springgreen" }
|
2012-02-28 01:33:51 +00:00
|
|
|
ListElement { color: "salmon" }
|
|
|
|
ListElement { color: "blanchedalmond" }
|
|
|
|
ListElement { color: "forestgreen" }
|
|
|
|
ListElement { color: "pink" }
|
|
|
|
ListElement { color: "navy" }
|
|
|
|
ListElement { color: "goldenrod" }
|
|
|
|
ListElement { color: "crimson" }
|
|
|
|
ListElement { color: "teal" }
|
2011-09-12 04:17:08 +00:00
|
|
|
}
|
2012-04-27 06:35:12 +00:00
|
|
|
//! [1]
|
2016-07-18 12:22:15 +00:00
|
|
|
delegate: DropArea {
|
2011-09-12 04:17:08 +00:00
|
|
|
id: delegateRoot
|
2023-03-03 06:34:21 +00:00
|
|
|
required property color color
|
2011-09-12 04:17:08 +00:00
|
|
|
|
2023-03-03 06:34:21 +00:00
|
|
|
width: 80
|
|
|
|
height: 80
|
2016-07-18 12:22:15 +00:00
|
|
|
|
2019-11-15 14:06:44 +00:00
|
|
|
onEntered: function(drag) {
|
|
|
|
visualModel.items.move((drag.source as Icon).visualIndex, icon.visualIndex)
|
|
|
|
}
|
|
|
|
|
2016-07-18 12:22:15 +00:00
|
|
|
property int visualIndex: DelegateModel.itemsIndex
|
2011-09-12 04:17:08 +00:00
|
|
|
|
2019-11-15 14:06:44 +00:00
|
|
|
Icon {
|
2011-09-12 04:17:08 +00:00
|
|
|
id: icon
|
2019-11-15 14:06:44 +00:00
|
|
|
dragParent: root
|
|
|
|
visualIndex: delegateRoot.visualIndex
|
|
|
|
color: delegateRoot.color
|
2011-09-12 04:17:08 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-27 06:35:12 +00:00
|
|
|
//! [1]
|
2011-09-12 04:17:08 +00:00
|
|
|
}
|
|
|
|
}
|