-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.qml
102 lines (92 loc) · 2.58 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* listviewdragitem
*
* An example of reordering items in a ListView via drag'n'drop.
*
* Author: Aurélien Gâteau
* License: BSD
*/
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
Window {
visible: true
width: 500
height: 300
ListModel {
id: myModel
ListElement {
text: "The Phantom Menace"
}
ListElement {
text: "Attack of the Clones"
}
ListElement {
text: "Revenge of the Siths"
}
ListElement {
text: "A New Hope"
}
ListElement {
text: "The Empire Strikes Back"
}
ListElement {
text: "Return of the Jedi"
}
ListElement {
text: "The Force Awakens"
}
}
Item {
id: mainContent
anchors.fill: parent
ColumnLayout {
anchors.fill: parent
spacing: 0
Rectangle {
color: "lightblue"
height: 50
Layout.fillWidth: true
Text {
anchors.centerIn: parent
text: "A fake toolbar"
}
}
ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
ListView {
id: listView
model: myModel
delegate: DraggableItem {
Rectangle {
height: textLabel.height * 2
width: listView.width
color: "white"
Text {
id: textLabel
anchors.centerIn: parent
text: model.text
}
// Bottom line border
Rectangle {
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
height: 1
color: "lightgrey"
}
}
draggedItemParent: mainContent
onMoveItemRequested: {
myModel.move(from, to, 1);
}
}
}
}
}
}
}