diff options
Diffstat (limited to 'examples/quick/views/delegatemodel/dragselection.qml')
-rw-r--r-- | examples/quick/views/delegatemodel/dragselection.qml | 116 |
1 files changed, 93 insertions, 23 deletions
diff --git a/examples/quick/views/delegatemodel/dragselection.qml b/examples/quick/views/delegatemodel/dragselection.qml index 1a66264e1d..57a769fb29 100644 --- a/examples/quick/views/delegatemodel/dragselection.qml +++ b/examples/quick/views/delegatemodel/dragselection.qml @@ -5,6 +5,8 @@ import QtQml import QtQuick import QtQml.Models +pragma ComponentBehavior: Bound + Item { id: root @@ -15,6 +17,7 @@ Item { Component { id: packageDelegate +//![0] Package { id: packageRoot @@ -33,19 +36,39 @@ Item { Item { id: draggable + Drag.active: visibleContainer.drag.active +//![0] + width: 64 height: 64 - Drag.active: visibleContainer.drag.active - - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } states: State { when: visibleContainer.drag.active - AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} } - ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 } - PropertyChanges { root.dragging: true } - ParentChange { target: draggable; parent: root } + AnchorChanges { + target: draggable + anchors { + horizontalCenter: undefined + verticalCenter: undefined + } + } + ParentChange { + target: selectionView + parent: draggable + x: 0 + y: 0 + } + PropertyChanges { + root.dragging: true + } + ParentChange { + target: draggable + parent: root + } } } DropArea { @@ -72,8 +95,16 @@ Item { radius: 8 gradient: Gradient { - GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" } - GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" } + GradientStop { + id: gradientStart + position: 0.0 + color: "#8AC953" + } + GradientStop { + id: gradientEnd + position: 1.0 + color: "#8BC953" + } } border.width: 2 @@ -91,8 +122,13 @@ Item { } Rectangle { - anchors { right: parent.right; top: parent.top; margins: 3 } - width: 12; height: 12 + anchors { + right: parent.right + top: parent.top + margins: 3 + } + width: 12 + height: 12 color: packageRoot.DelegateModel.inSelected ? "black" : "white" radius: 6 @@ -108,27 +144,55 @@ Item { states: [ State { name: "selected" - ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } + ParentChange { + target: content + parent: selectionContainer + x: 3 + y: 3 + } PropertyChanges { packageRoot.DelegateModel.inItems: visibleContainer.drag.active gradientStart.color: "#017423" } - PropertyChanges { gradientStart.color: "#007423" } + PropertyChanges { + gradientStart.color: "#007423" + } }, State { name: "visible" - PropertyChanges { packageRoot.DelegateModel.inItems: true } - ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } - PropertyChanges { gradientStart.color: "#8AC953" } - PropertyChanges { gradientStart.color: "#8BC953" } + PropertyChanges { + packageRoot.DelegateModel.inItems: true + } + ParentChange { + target: content + parent: visibleContainer + x: 3 + y: 3 + } + PropertyChanges { + gradientStart.color: "#8AC953" + } + PropertyChanges { + gradientStart.color: "#8BC953" + } } ] transitions: Transition { - PropertyAction { target: packageRoot; properties: "DelegateModel.inItems" } + PropertyAction { + target: packageRoot + properties: "DelegateModel.inItems" + } ParentAnimation { target: content - NumberAnimation { target: content; properties: "x,y"; duration: 500 } + NumberAnimation { + target: content + properties: "x,y" + duration: 500 + } + } + ColorAnimation { + targets: [gradientStart, gradientEnd] + duration: 500 } - ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 } } } } @@ -139,7 +203,10 @@ Item { model: 35 delegate: packageDelegate - groups: DelegateModelGroup { id: selectedItems; name: "selected" } + groups: DelegateModelGroup { + id: selectedItems + name: "selected" + } Component.onCompleted: parts.selection.filterOnGroup = "selected" } @@ -155,13 +222,16 @@ Item { path: Path { startX: 0 startY: 0 - PathLine { x: 64; y: 64 } + PathLine { + x: 64 + y: 64 + } } } GridView { id: itemsView - anchors { fill: parent } + anchors.fill: parent cellWidth: 64 cellHeight: 64 model: visualModel.parts.visible |