diff options
author | Mikko Gronoff <mikko.gronoff@qt.io> | 2018-08-24 11:10:54 +0300 |
---|---|---|
committer | Mikko Gronoff <mikko.gronoff@qt.io> | 2018-08-24 11:11:38 +0300 |
commit | 75addc77b361384b018ec28bde26e5880887c80f (patch) | |
tree | 38d58d5737dda597a6a69f2c931672575e5ed217 /basicsuite/qtquickcontrols2/pages/DelegatePage.qml | |
parent | 22cdfdd27aaa885ac5b7b450c8fb82b87853250d (diff) | |
parent | 1ff81b46a37550bb4430cc032b6d5504525af53f (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
* origin/5.11:
1ff81b4 Merge remote-tracking branch 'origin/5.9' into 5.11
3594ea2 Fix scaling, video path & focusing issues on mediaplayer demo
e81384c Remove confusing highlighting on media player file browser
4aa85d7 Use QSettings for color definitions
a60eb67 Disable graphical effect from imx7 boards
83bffe9 Move color definitions to QSettings
57bc95f Fix qtquickcontrols2 demo image paths & controls theme
a5ba671 Doc: Bump version to 5.11.2
1510d96 Doc: bump version to 5.9.7
cc9de37 Fix mediaplayer slider color definitions
c20966f Move info button to mediaplayer-demo footer
0b0d77e Fix mediaplayer color definitions
a607978 Update Boot2Qt Launcher demo icons & doc images
773a661 Disable webbrowser demo from all imx7 boards
9f18bb7 Doc: Bump version to 5.11.1
4fa8854 Doc: remove outdate doc folder under qtquickcontrols2 example
054a2ea doc: add missing doc images for e-bike & quickcontrols2 demo
173d934 Update Boot2Qt demos appearing in QtCreator
a70868f Enable ebike demo
6ed3d30 Temporarily disable e-bike from the basicsuite demo set
28e9fdf Fix Media Player demo color definitions
6b5a6d0 Fix paths for demos.xml
783ca94 Doc: bump version to 5.9.6
d083365 Add new Ebike demo to basicsuite
da60352 Move common definitions to shared settings
e513aed Update QtWebBrowser demo to new UI theme
f5c4c3a Remove qtwebbrowser submodule
3fa5796 Replace existing controls demos with controls 2 gallery example
04e4798 Update Mediaplayer demo to new UI theme
2e8942f Update GraphicalEffects demo to new UI theme
e365074 Add new fonts
7c41444 Update Charts demo to new UI theme
2a50d49 Comment out 7 demos from demos.xml file
9e941af Doc: Bump version to 5.9.5
0909f9b Doc: Bump version to 5.11.0
55fee3b Doc: Bump version to 5.9.4
89033ce Doc: Bump version to 5.9.3
Change-Id: I17ac5f2e2ef94535458b07cf8db38688e25ca21c
Diffstat (limited to 'basicsuite/qtquickcontrols2/pages/DelegatePage.qml')
-rw-r--r-- | basicsuite/qtquickcontrols2/pages/DelegatePage.qml | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/basicsuite/qtquickcontrols2/pages/DelegatePage.qml b/basicsuite/qtquickcontrols2/pages/DelegatePage.qml new file mode 100644 index 0000000..bf07e1b --- /dev/null +++ b/basicsuite/qtquickcontrols2/pages/DelegatePage.qml @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.1 + +Pane { + padding: 0 + + property var delegateComponentMap: { + "ItemDelegate": itemDelegateComponent, + "SwipeDelegate": swipeDelegateComponent, + "CheckDelegate": checkDelegateComponent, + "RadioDelegate": radioDelegateComponent, + "SwitchDelegate": switchDelegateComponent + } + + Component { + id: itemDelegateComponent + + ItemDelegate { + text: labelText + width: parent.width + } + } + + Component { + id: swipeDelegateComponent + + SwipeDelegate { + id: swipeDelegate + text: labelText + width: parent.width + + Component { + id: removeComponent + + Rectangle { + color: SwipeDelegate.pressed ? "#333" : "#444" + width: parent.width + height: parent.height + clip: true + + SwipeDelegate.onClicked: view.model.remove(ourIndex) + + Label { + font.pixelSize: swipeDelegate.font.pixelSize + text: "Remove" + color: "white" + anchors.centerIn: parent + } + } + } + + swipe.left: removeComponent + swipe.right: removeComponent + } + } + + Component { + id: checkDelegateComponent + + CheckDelegate { + text: labelText + width: parent.width + } + } + + ButtonGroup { + id: radioButtonGroup + } + + Component { + id: radioDelegateComponent + + RadioDelegate { + text: labelText + ButtonGroup.group: radioButtonGroup + } + } + + Component { + id: switchDelegateComponent + + SwitchDelegate { + text: labelText + } + } + + ColumnLayout { + id: column + spacing: 40 + anchors.fill: parent + anchors.topMargin: 20 + + Label { + Layout.fillWidth: true + wrapMode: Label.Wrap + horizontalAlignment: Qt.AlignHCenter + text: "Delegate controls are used as delegates in views such as ListView." + } + + ListView { + id: listView + Layout.fillWidth: true + Layout.fillHeight: true + clip: true + model: ListModel { + ListElement { type: "ItemDelegate"; text: "ItemDelegate" } + ListElement { type: "ItemDelegate"; text: "ItemDelegate" } + ListElement { type: "ItemDelegate"; text: "ItemDelegate" } + ListElement { type: "SwipeDelegate"; text: "SwipeDelegate" } + ListElement { type: "SwipeDelegate"; text: "SwipeDelegate" } + ListElement { type: "SwipeDelegate"; text: "SwipeDelegate" } + ListElement { type: "CheckDelegate"; text: "CheckDelegate" } + ListElement { type: "CheckDelegate"; text: "CheckDelegate" } + ListElement { type: "CheckDelegate"; text: "CheckDelegate" } + ListElement { type: "RadioDelegate"; text: "RadioDelegate" } + ListElement { type: "RadioDelegate"; text: "RadioDelegate" } + ListElement { type: "RadioDelegate"; text: "RadioDelegate" } + ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" } + ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" } + ListElement { type: "SwitchDelegate"; text: "SwitchDelegate" } + } + + section.property: "type" + section.delegate: Pane { + width: listView.width + height: sectionLabel.implicitHeight + 20 + + Label { + id: sectionLabel + text: section + anchors.centerIn: parent + } + } + + delegate: Loader { + id: delegateLoader + width: listView.width + sourceComponent: delegateComponentMap[text] + + property string labelText: text + property ListView view: listView + property int ourIndex: index + + // Can't find a way to do this in the SwipeDelegate component itself, + // so do it here instead. + ListView.onRemove: SequentialAnimation { + PropertyAction { + target: delegateLoader + property: "ListView.delayRemove" + value: true + } + NumberAnimation { + target: item + property: "height" + to: 0 + easing.type: Easing.InOutQuad + } + PropertyAction { + target: delegateLoader + property: "ListView.delayRemove" + value: false + } + } + } + } + } +} |