Commit f1bbe63e authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

use DelegateModel/Package to move tile around

parent 5af4da80
import QtQml.Models 2.15
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
Window {
......@@ -6,4 +9,96 @@ Window {
height: 480
visible: true
title: qsTr("Hello World")
ListModel {
id: tileListModel
ListElement { name: "A" }
ListElement { name: "B" }
ListElement { name: "C" }
ListElement { name: "D" }
ListElement { name: "E" }
ListElement { name: "F" }
ListElement { name: "G" }
ListElement { name: "H" }
ListElement { name: "I" }
ListElement { name: "J" }
}
DelegateModel {
id: tileContentModel
model: tileListModel
delegate: Package {
id: tile
required property int index
required property string name
Pane {
id: leftPane
Package.name: "left"
visible: tile.index < 5
}
Pane {
id: rightPane
Package.name: "right"
visible: tile.index >= 5
}
GridLayout {
parent: tile.index < 5 ? leftPane.contentItem : rightPane.contentItem
anchors.fill: parent
columns: 2
Component.onCompleted: {
dummyField.text = tile.name + ": " + tile.index;
}
Label { text: "name:" }
Label {
Layout.fillWidth: true
text: tile.name
}
Label { text: "index:" }
SpinBox {
editable: true
value: tile.index
onValueModified: {
dummyField.text += " " + value;
tileListModel.move(tile.index, value, 1);
}
}
Label { text: "dummyField:" }
TextField {
id: dummyField
selectByMouse: true
}
}
}
}
RowLayout {
anchors.fill: parent
SplitView {
Layout.fillWidth: true
Layout.fillHeight: true
orientation: Qt.Horizontal
SplitView {
SplitView.preferredWidth: parent.width / 2
orientation: Qt.Vertical
Repeater {
model: tileContentModel.parts.left
}
}
SplitView {
SplitView.preferredWidth: parent.width / 2
orientation: Qt.Vertical
Repeater {
model: tileContentModel.parts.right
}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment