diff options
Diffstat (limited to 'examples/quick/views/delegatemodel')
-rw-r--r-- | examples/quick/views/delegatemodel/delegatemodel.qmlproject | 17 | ||||
-rw-r--r-- | examples/quick/views/delegatemodel/dragselection.qml | 116 | ||||
-rw-r--r-- | examples/quick/views/delegatemodel/flipable.pro | 9 | ||||
-rw-r--r-- | examples/quick/views/delegatemodel/flipable.qrc | 9 | ||||
-rw-r--r-- | examples/quick/views/delegatemodel/main.cpp | 4 | ||||
-rw-r--r-- | examples/quick/views/delegatemodel/slideshow.qml | 121 |
6 files changed, 93 insertions, 183 deletions
diff --git a/examples/quick/views/delegatemodel/delegatemodel.qmlproject b/examples/quick/views/delegatemodel/delegatemodel.qmlproject deleted file mode 100644 index e78ddcb187..0000000000 --- a/examples/quick/views/delegatemodel/delegatemodel.qmlproject +++ /dev/null @@ -1,17 +0,0 @@ -import QmlProject 1.0 - -Project { - mainFile: "slideshow.qml" - importPaths: [ "../../" ] - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} 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 diff --git a/examples/quick/views/delegatemodel/flipable.pro b/examples/quick/views/delegatemodel/flipable.pro deleted file mode 100644 index ba00bf792c..0000000000 --- a/examples/quick/views/delegatemodel/flipable.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp - -RESOURCES += flipable.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/flipable -INSTALLS += target diff --git a/examples/quick/views/delegatemodel/flipable.qrc b/examples/quick/views/delegatemodel/flipable.qrc deleted file mode 100644 index 7918ccf00e..0000000000 --- a/examples/quick/views/delegatemodel/flipable.qrc +++ /dev/null @@ -1,9 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>flipable.qml</file> - <file>content/5_heart.png</file> - <file>content/9_club.png</file> - <file>content/back.png</file> - <file>content/Card.qml</file> - </qresource> -</RCC> diff --git a/examples/quick/views/delegatemodel/main.cpp b/examples/quick/views/delegatemodel/main.cpp deleted file mode 100644 index 8eb2fc72c3..0000000000 --- a/examples/quick/views/delegatemodel/main.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -#include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(flipable) diff --git a/examples/quick/views/delegatemodel/slideshow.qml b/examples/quick/views/delegatemodel/slideshow.qml deleted file mode 100644 index c11a72147f..0000000000 --- a/examples/quick/views/delegatemodel/slideshow.qml +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQml.Models -import shared as Shared - -Rectangle { - id: root - - property Item displayItem: null - - width: 300; height: 400 - - color: "black" - - Shared.FlickrRssModel { - id: flickrModel - tags: "fjords,mountains" - } - DelegateModel { - id: visualModel - - model: flickrModel - delegate: Item { - id: delegateItem - - width: 76; height: 76 - - required property string thumbnail - - Rectangle { - id: image - x: 0; y: 0; width: 76; height: 76 - border.width: 1 - border.color: "white" - color: "black" - - Image { - anchors.fill: parent - anchors.leftMargin: 1 - anchors.topMargin: 1 - - source: delegateItem.thumbnail - fillMode: Image.PreserveAspectFit - } - - MouseArea { - id: clickArea - anchors.fill: parent - - onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null - } - - states: [ - State { - when: root.displayItem === delegateItem - name: "inDisplay"; - ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 } - PropertyChanges { - image.z: 2 - delegateItem.DelegateModel.inItems: false - } - }, - State { - when: root.displayItem !== delegateItem - name: "inList"; - ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 } - PropertyChanges { - image.z: 1 - delegateItem.DelegateModel.inItems: true - } - } - ] - - transitions: [ - Transition { - from: "inList" - SequentialAnimation { - PropertyAction { target: delegateItem; property: "DelegateModel.inPersistedItems"; value: true } - ParentAnimation { - target: image; - via: root - NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } - } - } - }, Transition { - from: "inDisplay" - SequentialAnimation { - ParentAnimation { - target: image - NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } - } - PropertyAction { target: delegateItem; property: "DelegateModel.inPersistedItems"; value: false } - } - } - ] - } - } - } - - - PathView { - id: imagePath - - anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom } - model: visualModel - - pathItemCount: 7 - path: Path { - startX: -50; startY: 0 - PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 } - PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 } - } - } - - Item { - id: imageContainer - anchors { fill: parent; bottomMargin: 100 } - } -} |