diff options
Diffstat (limited to 'examples/quick/views')
29 files changed, 764 insertions, 1647 deletions
diff --git a/examples/quick/views/CMakeLists.txt b/examples/quick/views/CMakeLists.txt index 9951bd48ff..6800983c6e 100644 --- a/examples/quick/views/CMakeLists.txt +++ b/examples/quick/views/CMakeLists.txt @@ -1,170 +1,94 @@ -# Generated from views.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(views LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/views") +qt_standard_project_setup(REQUIRES 6.5) -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +add_subdirectory("../shared" "shared") -qt_add_executable(views +qt_add_executable(viewsexample + WIN32 + MACOSX_BUNDLE main.cpp ) -set_target_properties(views PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(views PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - -# Resources: -set(views_resource_files - "delegatemodel/dragselection.qml" - "delegatemodel/slideshow.qml" - "gridview/gridview-example.qml" - "gridview/pics/AddressBook_48.png" - "gridview/pics/AudioPlayer_48.png" - "gridview/pics/Camera_48.png" - "gridview/pics/DateBook_48.png" - "gridview/pics/EMail_48.png" - "gridview/pics/TodoList_48.png" - "gridview/pics/VideoPlayer_48.png" - "listview/content/PetsModel.qml" - "listview/content/PressAndHoldButton.qml" - "listview/content/RecipesModel.qml" - "listview/content/SmallText.qml" - "listview/content/TextButton.qml" - "listview/content/ToggleButton.qml" - "listview/content/pics/arrow-down.png" - "listview/content/pics/arrow-up.png" - "listview/content/pics/fruit-salad.jpg" - "listview/content/pics/hamburger.jpg" - "listview/content/pics/lemonade.jpg" - "listview/content/pics/list-delete.png" - "listview/content/pics/minus-sign.png" - "listview/content/pics/moreDown.png" - "listview/content/pics/moreUp.png" - "listview/content/pics/pancakes.jpg" - "listview/content/pics/plus-sign.png" - "listview/content/pics/vegetable-soup.jpg" - "listview/displaymargin.qml" - "listview/dynamiclist.qml" - "listview/expandingdelegates.qml" - "listview/highlight.qml" - "listview/highlightranges.qml" - "listview/sections.qml" - "objectmodel/objectmodel.qml" - "package/Delegate.qml" - "package/view.qml" - "pathview/pathview-example.qml" - "pathview/pics/AddressBook_48.png" - "pathview/pics/AudioPlayer_48.png" - "pathview/pics/Camera_48.png" - "pathview/pics/DateBook_48.png" - "pathview/pics/EMail_48.png" - "pathview/pics/TodoList_48.png" - "pathview/pics/VideoPlayer_48.png" - "views.qml" +target_link_libraries(viewsexample PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Qml + Qt6::Quick ) -qt6_add_resources(views "views" - PREFIX - "/views" - FILES - ${views_resource_files} -) -set_source_files_properties("../shared/Button.qml" - PROPERTIES QT_RESOURCE_ALIAS "Button.qml" -) -set_source_files_properties("../shared/CheckBox.qml" - PROPERTIES QT_RESOURCE_ALIAS "CheckBox.qml" -) -set_source_files_properties("../shared/FlickrRssModel.qml" - PROPERTIES QT_RESOURCE_ALIAS "FlickrRssModel.qml" -) -set_source_files_properties("../shared/Label.qml" - PROPERTIES QT_RESOURCE_ALIAS "Label.qml" -) -set_source_files_properties("../shared/LauncherList.qml" - PROPERTIES QT_RESOURCE_ALIAS "LauncherList.qml" -) -set_source_files_properties("../shared/SimpleLauncherDelegate.qml" - PROPERTIES QT_RESOURCE_ALIAS "SimpleLauncherDelegate.qml" -) -set_source_files_properties("../shared/Slider.qml" - PROPERTIES QT_RESOURCE_ALIAS "Slider.qml" -) -set_source_files_properties("../shared/TabSet.qml" - PROPERTIES QT_RESOURCE_ALIAS "TabSet.qml" -) -set_source_files_properties("../shared/TextField.qml" - PROPERTIES QT_RESOURCE_ALIAS "TextField.qml" -) -set_source_files_properties("../shared/images/back.png" - PROPERTIES QT_RESOURCE_ALIAS "images/back.png" -) -set_source_files_properties("../shared/images/checkmark.png" - PROPERTIES QT_RESOURCE_ALIAS "images/checkmark.png" -) -set_source_files_properties("../shared/images/next.png" - PROPERTIES QT_RESOURCE_ALIAS "images/next.png" -) -set_source_files_properties("../shared/images/qt-logo.png" - PROPERTIES QT_RESOURCE_ALIAS "images/qt-logo.png" -) -set_source_files_properties("../shared/images/slider_handle.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_handle.png" -) -set_source_files_properties("../shared/images/tab.png" - PROPERTIES QT_RESOURCE_ALIAS "images/tab.png" -) -set(shared_resource_files - "Button.qml" - "CheckBox.qml" - "FlickrRssModel.qml" - "Label.qml" - "LauncherList.qml" - "SimpleLauncherDelegate.qml" - "Slider.qml" - "TabSet.qml" - "TextField.qml" - "images/back.png" - "images/checkmark.png" - "images/next.png" - "images/qt-logo.png" - "images/slider_handle.png" - "images/tab.png" -) +add_dependencies(viewsexample views_shared) -qt6_add_resources(views "shared" - PREFIX - "/shared" - BASE - "../shared" - FILES - ${shared_resource_files} +qt_add_qml_module(viewsexample + URI views + QML_FILES + "delegatemodel/dragselection.qml" + "gridview/gridview-example.qml" + "listview/content/PetsModel.qml" + "listview/content/PressAndHoldButton.qml" + "listview/content/RecipesModel.qml" + "listview/content/SmallText.qml" + "listview/content/TextButton.qml" + "listview/content/ToggleButton.qml" + "listview/displaymargin.qml" + "listview/dynamiclist.qml" + "listview/expandingdelegates.qml" + "listview/highlight.qml" + "listview/highlightranges.qml" + "listview/sections.qml" + "objectmodel/objectmodel.qml" + "package/Delegate.qml" + "package/view.qml" + "pathview/pathview-example.qml" + "views.qml" + RESOURCES + "gridview/pics/AddressBook_48.png" + "gridview/pics/AudioPlayer_48.png" + "gridview/pics/Camera_48.png" + "gridview/pics/DateBook_48.png" + "gridview/pics/EMail_48.png" + "gridview/pics/TodoList_48.png" + "gridview/pics/VideoPlayer_48.png" + "listview/content/pics/arrow-down.png" + "listview/content/pics/arrow-up.png" + "listview/content/pics/fruit-salad.jpg" + "listview/content/pics/hamburger.jpg" + "listview/content/pics/lemonade.jpg" + "listview/content/pics/list-delete.png" + "listview/content/pics/minus-sign.png" + "listview/content/pics/moreDown.png" + "listview/content/pics/moreUp.png" + "listview/content/pics/pancakes.jpg" + "listview/content/pics/plus-sign.png" + "listview/content/pics/vegetable-soup.jpg" + "pathview/pics/AddressBook_48.png" + "pathview/pics/AudioPlayer_48.png" + "pathview/pics/Camera_48.png" + "pathview/pics/DateBook_48.png" + "pathview/pics/EMail_48.png" + "pathview/pics/TodoList_48.png" + "pathview/pics/VideoPlayer_48.png" ) -install(TARGETS views - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +install(TARGETS viewsexample + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) + +qt_generate_deploy_qml_app_script( + TARGET viewsexample + OUTPUT_SCRIPT deploy_script + MACOS_BUNDLE_POST_BUILD + NO_UNSUPPORTED_PLATFORM_ERROR + DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM +) +install(SCRIPT ${deploy_script}) diff --git a/examples/quick/views/delegatemodel/delegatemodel.qmlproject b/examples/quick/views/delegatemodel/delegatemodel.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/quick/views/delegatemodel/delegatemodel.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* 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 f9a0d37311..57a769fb29 100644 --- a/examples/quick/views/delegatemodel/dragselection.qml +++ b/examples/quick/views/delegatemodel/dragselection.qml @@ -1,56 +1,11 @@ -/**************************************************************************** -** -** 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 QtQml 2.0 -import QtQuick 2.0 -import QtQml.Models 2.1 +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQml +import QtQuick +import QtQml.Models + +pragma ComponentBehavior: Bound Item { id: root @@ -62,6 +17,7 @@ Item { Component { id: packageDelegate +//![0] Package { id: packageRoot @@ -80,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 { target: 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 { @@ -119,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 @@ -138,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 @@ -155,25 +144,55 @@ Item { states: [ State { name: "selected" - ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } - PropertyChanges { target: packageRoot; DelegateModel.inItems: visibleContainer.drag.active } - PropertyChanges { target: gradientStart; color: "#017423" } - PropertyChanges { target: gradientStart; color: "#007423" } + ParentChange { + target: content + parent: selectionContainer + x: 3 + y: 3 + } + PropertyChanges { + packageRoot.DelegateModel.inItems: visibleContainer.drag.active + gradientStart.color: "#017423" + } + PropertyChanges { + gradientStart.color: "#007423" + } }, State { name: "visible" - PropertyChanges { target: packageRoot; DelegateModel.inItems: true } - ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } - PropertyChanges { target: gradientStart; color: "#8AC953" } - PropertyChanges { target: 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 } } } } @@ -184,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" } @@ -200,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 a0f0d67d45..0000000000 --- a/examples/quick/views/delegatemodel/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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$ -** -****************************************************************************/ -#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 638c8bf10f..0000000000 --- a/examples/quick/views/delegatemodel/slideshow.qml +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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.12 -import QtQml.Models 2.12 -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 { target: image; z: 2 } - PropertyChanges { target: 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 { target: image; z: 1 } - PropertyChanges { target: 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 } - } -} diff --git a/examples/quick/views/doc/src/views.qdoc b/examples/quick/views/doc/src/views.qdoc index 3e23f7657a..7e73ce31d7 100644 --- a/examples/quick/views/doc/src/views.qdoc +++ b/examples/quick/views/doc/src/views.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \title Qt Quick Examples - Views @@ -31,6 +7,7 @@ \brief This is a collection of QML model-view examples. \image qml-modelviews-example.png \ingroup qtquickexamples + \examplecategory {Graphics} \e Views is a collection of small QML examples relating to model and view functionality. They demonstrate how to show data from a model using the @@ -87,7 +64,7 @@ \section1 Using Packages - \e Packages use the \l [QML]{Package} type to transition delegates between + \e Packages uses the \l [QML]{Package} type to transition delegates between two views. It has a Package object which defines delegate items for each view and an @@ -100,6 +77,11 @@ \snippet views/package/view.qml 0 + \e{Draggable Selections} demonstrates the use of Package to group together + multiple selected delegates for drag-and-drop within an item view. + + \snippet views/delegatemodel/dragselection.qml 0 + \section1 Using ObjectModel \e ObjectModel uses an ObjectModel for the model instead of a \l ListModel. diff --git a/examples/quick/views/gridview/gridview-example.qml b/examples/quick/views/gridview/gridview-example.qml index 4cc30d3736..f340a97b4c 100644 --- a/examples/quick/views/gridview/gridview-example.qml +++ b/examples/quick/views/gridview/gridview-example.qml @@ -1,57 +1,11 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick Rectangle { - width: 300; height: 400 + width: 300 + height: 400 color: "white" ListModel { @@ -67,26 +21,36 @@ Rectangle { //! [0] GridView { anchors.fill: parent - cellWidth: 100; cellHeight: 100 + cellWidth: 100 + cellHeight: 100 focus: true model: appModel - highlight: Rectangle { width: 80; height: 80; color: "lightsteelblue" } + highlight: Rectangle { + width: 80 + height: 80 + color: "lightsteelblue" + } delegate: Item { required property string icon required property string name required property int index - width: 100; height: 100 + width: 100 + height: 100 Image { id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter + y: 20 + anchors.horizontalCenter: parent.horizontalCenter source: parent.icon } Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + anchors { + top: myIcon.bottom + horizontalCenter: parent.horizontalCenter + } text: parent.name } MouseArea { diff --git a/examples/quick/views/listview/content/PetsModel.qml b/examples/quick/views/listview/content/PetsModel.qml index bc8751f00a..acdab53c20 100644 --- a/examples/quick/views/listview/content/PetsModel.qml +++ b/examples/quick/views/listview/content/PetsModel.qml @@ -1,54 +1,7 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick ListModel { ListElement { diff --git a/examples/quick/views/listview/content/PressAndHoldButton.qml b/examples/quick/views/listview/content/PressAndHoldButton.qml index 6d633c0264..51ab9435d2 100644 --- a/examples/quick/views/listview/content/PressAndHoldButton.qml +++ b/examples/quick/views/listview/content/PressAndHoldButton.qml @@ -1,61 +1,14 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick Image { id: container property int repeatDelay: 300 property int repeatDuration: 75 - property bool pressed: false + property bool pressed signal clicked diff --git a/examples/quick/views/listview/content/RecipesModel.qml b/examples/quick/views/listview/content/RecipesModel.qml index 05f6d8a472..14b374a4c7 100644 --- a/examples/quick/views/listview/content/RecipesModel.qml +++ b/examples/quick/views/listview/content/RecipesModel.qml @@ -1,75 +1,28 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick ListModel { ListElement { title: "Pancakes" picture: "content/pics/pancakes.jpg" - ingredients: "<html> + ingredients: `<html> <ul> <li> 1 cup (150g) self-raising flour <li> 1 tbs caster sugar <li> 3/4 cup (185ml) milk <li> 1 egg </ul> - </html>" - method: "<html> + </html>` + method: `<html> <ol> <li> Sift flour and sugar together into a bowl. Add a pinch of salt. <li> Beat milk and egg together, then add to dry ingredients. Beat until smooth. <li> Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. <li> Turn over and cook other side until golden. </ol> - </html>" + </html>` } ListElement { title: "Fruit Salad" @@ -80,7 +33,7 @@ ListModel { ListElement { title: "Vegetable Soup" picture: "content/pics/vegetable-soup.jpg" - ingredients: "<html> + ingredients: `<html> <ul> <li> 1 onion <li> 1 turnip @@ -89,51 +42,51 @@ ListModel { <li> 1 head of celery <li> 1 1/2 litres of water </ul> - </html>" - method: "<html> + </html>` + method: `<html> <ol> <li> Chop vegetables. <li> Boil in water until vegetables soften. <li> Season with salt and pepper to taste. </ol> - </html>" + </html>` } ListElement { title: "Hamburger" picture: "content/pics/hamburger.jpg" - ingredients: "<html> + ingredients: `<html> <ul> <li> 500g minced beef <li> Seasoning <li> lettuce, tomato, onion, cheese <li> 1 hamburger bun for each burger </ul> - </html>" - method: "<html> + </html>` + method: `<html> <ol> <li> Mix the beef, together with seasoning, in a food processor. <li> Shape the beef into burgers. <li> Grill the burgers for about 5 mins on each side (until cooked through) <li> Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. </ol> - </html>" + </html>` } ListElement { title: "Lemonade" picture: "content/pics/lemonade.jpg" - ingredients: "<html> + ingredients: `<html> <ul> <li> 1 cup Lemon Juice <li> 1 cup Sugar <li> 6 Cups of Water (2 cups warm water, 4 cups cold water) </ul> - </html>" - method: "<html> + </html>` + method: `<html> <ol> <li> Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. <li> Pour in lemon juice, stir again, and add 4 cups of cold water. <li> Chill or serve over ice cubes. </ol> - </html>" + </html>` } } diff --git a/examples/quick/views/listview/content/SmallText.qml b/examples/quick/views/listview/content/SmallText.qml index 21dc46d676..756610f4b3 100644 --- a/examples/quick/views/listview/content/SmallText.qml +++ b/examples/quick/views/listview/content/SmallText.qml @@ -1,56 +1,9 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick Text { - font.pixelSize: 12 + font.pointSize: 9 } diff --git a/examples/quick/views/listview/content/TextButton.qml b/examples/quick/views/listview/content/TextButton.qml index ed95112d47..aef7aa79e0 100644 --- a/examples/quick/views/listview/content/TextButton.qml +++ b/examples/quick/views/listview/content/TextButton.qml @@ -1,54 +1,7 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick Rectangle { id: container @@ -80,7 +33,7 @@ Rectangle { states: State { name: "pressed" when: mouseArea.pressed - PropertyChanges { target: gradientStop; color: "#333333" } + PropertyChanges { gradientStop.color: "#333333" } } } diff --git a/examples/quick/views/listview/content/ToggleButton.qml b/examples/quick/views/listview/content/ToggleButton.qml index 890a94570b..19e2589f74 100644 --- a/examples/quick/views/listview/content/ToggleButton.qml +++ b/examples/quick/views/listview/content/ToggleButton.qml @@ -1,54 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick Rectangle { id: root diff --git a/examples/quick/views/listview/displaymargin.qml b/examples/quick/views/listview/displaymargin.qml index 19261caaa6..0030b82b55 100644 --- a/examples/quick/views/listview/displaymargin.qml +++ b/examples/quick/views/listview/displaymargin.qml @@ -1,53 +1,6 @@ -/**************************************************************************** -** -** 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.3 +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +import QtQuick Item { width: 480; height: 320 @@ -81,7 +34,8 @@ Item { Rectangle { id: header - width: parent.width; height: 40 + width: parent.width + height: 40 color: "#AAFF0000" Text { @@ -94,7 +48,8 @@ Item { Rectangle { id: footer anchors.bottom: parent.bottom - width: parent.width; height: 40 + width: parent.width + height: 40 color: "#AAFF0000" Text { diff --git a/examples/quick/views/listview/dynamiclist.qml b/examples/quick/views/listview/dynamiclist.qml index 973d3ce389..736088fbf7 100644 --- a/examples/quick/views/listview/dynamiclist.qml +++ b/examples/quick/views/listview/dynamiclist.qml @@ -1,61 +1,17 @@ -/**************************************************************************** -** -** 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.0 +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +import QtQuick import "content" // This example shows how items can be dynamically added to and removed from // a ListModel, and how these list modifications can be animated. +pragma ComponentBehavior: Bound + Rectangle { id: container - width: 500; height: 400 + width: 500 + height: 400 color: "#343434" // The model: @@ -63,30 +19,48 @@ Rectangle { id: fruitModel ListElement { - name: "Apple"; cost: 2.45 + name: "Apple" + cost: 2.45 attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } + ListElement { + description: "Core" + }, + ListElement { + description: "Deciduous" + } ] } ListElement { - name: "Banana"; cost: 1.95 + name: "Banana" + cost: 1.95 attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } + ListElement { + description: "Tropical" + }, + ListElement { + description: "Seedless" + } ] } ListElement { - name: "Cumquat"; cost: 3.25 + name: "Kumquat" + cost: 3.25 attributes: [ - ListElement { description: "Citrus" } + ListElement { + description: "Citrus" + } ] } ListElement { - name: "Durian"; cost: 9.95 + name: "Durian" + cost: 9.95 attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Smelly" } + ListElement { + description: "Tropical" + }, + ListElement { + description: "Smelly" + } ] } } @@ -98,7 +72,8 @@ Rectangle { Item { //! [0] id: delegateItem - width: listView.width; height: 80 + width: listView.width + height: 80 clip: true required property int index @@ -130,7 +105,7 @@ Rectangle { Column { anchors { left: arrows.right - horizontalCenter: parent.horizontalCenter; + horizontalCenter: parent.horizontalCenter bottom: parent.verticalCenter } @@ -202,18 +177,42 @@ Rectangle { //! [1] SequentialAnimation { id: addAnimation - PropertyAction { target: delegateItem; property: "height"; value: 0 } - NumberAnimation { target: delegateItem; property: "height"; to: 80; duration: 250; easing.type: Easing.InOutQuad } + PropertyAction { + target: delegateItem + property: "height" + value: 0 + } + NumberAnimation { + target: delegateItem + property: "height" + to: 80 + duration: 250 + easing.type: Easing.InOutQuad + } } ListView.onAdd: addAnimation.start() SequentialAnimation { id: removeAnimation - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + PropertyAction { + target: delegateItem + property: "ListView.delayRemove" + value: true + } + NumberAnimation { + target: delegateItem + property: "height" + to: 0 + duration: 250 + easing.type: Easing.InOutQuad + } // Make sure delayRemove is set back to false so that the item can be destroyed - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } + PropertyAction { + target: delegateItem + property: "ListView.delayRemove" + value: false + } } ListView.onRemove: removeAnimation.start() } @@ -224,8 +223,10 @@ Rectangle { ListView { id: listView anchors { - left: parent.left; top: parent.top; - right: parent.right; bottom: buttons.top; + left: parent.left + top: parent.top + right: parent.right + bottom: buttons.top margins: 20 } model: fruitModel @@ -234,11 +235,15 @@ Rectangle { Row { id: buttons - anchors { left: parent.left; bottom: parent.bottom; margins: 20 } + anchors { + left: parent.left + bottom: parent.bottom + margins: 20 + } spacing: 10 TextButton { - text: "Add an item" + text: qsTr("Add an item") onClicked: { fruitModel.append({ "name": "Pizza Margarita", @@ -249,7 +254,7 @@ Rectangle { } TextButton { - text: "Remove all items" + text: qsTr("Remove all items") onClicked: fruitModel.clear() } } diff --git a/examples/quick/views/listview/expandingdelegates.qml b/examples/quick/views/listview/expandingdelegates.qml index 6ed1d8c341..5c1811a00a 100644 --- a/examples/quick/views/listview/expandingdelegates.qml +++ b/examples/quick/views/listview/expandingdelegates.qml @@ -1,61 +1,15 @@ -/**************************************************************************** -** -** 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.0 +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick import "content" // This example illustrates expanding a list item to show a more detailed view. Rectangle { id: page - width: 400; height: 240 + width: 400 + height: 240 color: "black" // Delegate for the recipes. This delegate has two modes: @@ -78,13 +32,16 @@ Rectangle { // want to fade. property real detailsOpacity : 0 //! [0] - width: listView.width + width: ListView.view.width height: 70 // A simple rounded rectangle for the background Rectangle { id: background - x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + x: 2 + y: 2 + width: parent.width - x * 2 + height: parent.height - y * 2 color: "ivory" border.color: "orange" radius: 5 @@ -105,26 +62,32 @@ Rectangle { Row { id: topLayout - x: 10; y: 10; height: recipeImage.height; width: parent.width + x: 10 + y: 10 + height: recipeImage.height + width: parent.width spacing: 10 Image { id: recipeImage - width: 50; height: 50 + width: 50 + height: 50 source: recipe.picture } //! [1] Column { - width: background.width - recipeImage.width - 20; height: recipeImage.height + width: background.width - recipeImage.width - 20 + height: recipeImage.height spacing: 5 Text { text: recipe.title - font.bold: true; font.pointSize: 16 + font.bold: true + font.pointSize: 16 } SmallText { - text: "Ingredients" + text: qsTr("Ingredients") font.bold: true opacity: recipe.detailsOpacity } @@ -141,22 +104,32 @@ Rectangle { //! [2] Item { id: details - x: 10; width: parent.width - 20 - - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + x: 10 + width: parent.width - 20 + + anchors { + top: topLayout.bottom + topMargin: 10 + bottom: parent.bottom + bottomMargin: 10 + } opacity: recipe.detailsOpacity //! [2] SmallText { id: methodTitle anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true + text: qsTr("Method") + font.pointSize: 12 + font.bold: true } Flickable { id: flick width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } + anchors { + top: methodTitle.bottom + bottom: parent.bottom + } contentHeight: methodText.height clip: true @@ -169,13 +142,19 @@ Rectangle { } Image { - anchors { right: flick.right; top: flick.top } + anchors { + right: flick.right + top: flick.top + } source: "content/pics/moreUp.png" opacity: flick.atYBeginning ? 0 : 1 } Image { - anchors { right: flick.right; bottom: flick.bottom } + anchors { + right: flick.right + bottom: flick.bottom + } source: "content/pics/moreDown.png" opacity: flick.atYEnd ? 0 : 1 } @@ -185,9 +164,12 @@ Rectangle { // A button to close the detailed view, i.e. set the state back to default (''). TextButton { y: 10 - anchors { right: background.right; rightMargin: 10 } + anchors { + right: background.right + rightMargin: 10 + } opacity: recipe.detailsOpacity - text: "Close" + text: qsTr("Close") onClicked: recipe.state = ''; } @@ -195,23 +177,46 @@ Rectangle { states: State { name: "Details" - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger - PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view + PropertyChanges { + background.color: "white" + recipeImage { + // Make picture bigger + width: 130 + height: 130 + } + recipe { + // Make details visible + detailsOpacity: 1 + x: 0 + + // Fill the entire list area with the detailed view + height: listView.height + } + } // Move the list so that this item is at the top. - PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + PropertyChanges { + recipe.ListView.view.contentY: recipe.y + explicit: true; + } // Disallow flicking while we're in detailed view - PropertyChanges { target: recipe.ListView.view; interactive: false } + PropertyChanges { + recipe.ListView.view.interactive: false + } } transitions: Transition { // Make the state changes smooth ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } + ColorAnimation { + property: "color" + duration: 500 + } + NumberAnimation { + duration: 300 + properties: "detailsOpacity,x,contentY,height,width" + } } } } @@ -222,7 +227,7 @@ Rectangle { ListView { id: listView anchors.fill: parent - model: RecipesModel {} + model: RecipesModel { } delegate: recipeDelegate } } diff --git a/examples/quick/views/listview/highlight.qml b/examples/quick/views/listview/highlight.qml index 092b4d59bd..1f9b9c015c 100644 --- a/examples/quick/views/listview/highlight.qml +++ b/examples/quick/views/listview/highlight.qml @@ -1,68 +1,23 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause // This example shows how to create your own highlight delegate for a ListView // that uses a SpringAnimation to provide custom movement when the // highlight bar is moved between items. -import QtQuick 2.0 +import QtQuick import "content" Rectangle { - width: 200; height: 300 + width: 200 + height: 300 // Define a delegate component. The component will be // instantiated for each visible item in the list. component PetDelegate: Item { id: pet - width: 200; height: 55 + width: 200 + height: 55 required property int index required property string name @@ -70,18 +25,27 @@ Rectangle { required property int age Column { - SmallText { text: 'Name: ' + pet.name } - SmallText { text: 'Type: ' + pet.type } - SmallText { text: 'Age: ' + pet.age } + SmallText { + text: 'Name: ' + pet.name + } + SmallText { + text: 'Type: ' + pet.type + } + SmallText { + text: 'Age: ' + pet.age + } } // indent the item if it is the current item states: State { name: "Current" when: pet.ListView.isCurrentItem - PropertyChanges { target: pet; x: 20 } + PropertyChanges { pet.x: 20 } } transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } + NumberAnimation { + properties: "x" + duration: 200 + } } MouseArea { anchors.fill: parent @@ -92,24 +56,31 @@ Rectangle { //! [0] // Define a highlight with customized movement between items. component HighlightBar : Rectangle { - width: 200; height: 50 + width: 200 + height: 50 color: "#FFFF88" - y: listView.currentItem.y - Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } + y: ListView.view.currentItem.y + Behavior on y { + SpringAnimation { + spring: 2 + damping: 0.1 + } + } } ListView { id: listView - width: 200; height: parent.height + width: 200 + height: parent.height x: 30 - model: PetsModel {} - delegate: PetDelegate {} + model: PetsModel { } + delegate: PetDelegate { } focus: true // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem // to false so the highlight delegate can control how the highlight is moved. - highlight: HighlightBar {} + highlight: HighlightBar { } highlightFollowsCurrentItem: false } //! [0] diff --git a/examples/quick/views/listview/highlightranges.qml b/examples/quick/views/listview/highlightranges.qml index dafd064332..91304ae08b 100644 --- a/examples/quick/views/listview/highlightranges.qml +++ b/examples/quick/views/listview/highlightranges.qml @@ -1,56 +1,11 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick import "content" +pragma ComponentBehavior: Bound + //! [0] Rectangle { id: root @@ -77,17 +32,26 @@ Rectangle { } } - PauseAnimation { duration: 500 } + PauseAnimation { + duration: 500 + } } //! [0] - MouseArea{ + MouseArea { id: ma z: 1 anchors.fill: parent - onClicked: { z = 1 - z; if (anim.running) anim.stop(); else anim.restart();} + onClicked: function () { + z = 1 - z; + if (anim.running) + anim.stop(); + else + anim.restart(); + } } - width: 320; height: 480 + width: 320 + height: 480 // This example shows the same model in three different ListView items, // with different highlight ranges. The highlight ranges are set by the @@ -115,12 +79,16 @@ Rectangle { //! [1] ListView { id: list1 - height: 50; width: parent.width - model: PetsModel {id: aModel} + height: 50 + width: parent.width + model: PetsModel { + id: aModel + } delegate: petDelegate orientation: ListView.Horizontal - - highlight: Rectangle { color: "lightsteelblue" } + highlight: Rectangle { + color: "lightsteelblue" + } currentIndex: root.current onCurrentIndexChanged: root.current = currentIndex focus: true @@ -129,29 +97,33 @@ Rectangle { ListView { id: list2 y: 160 - height: 50; width: parent.width - model: PetsModel {} + height: 50 + width: parent.width + model: PetsModel { } delegate: petDelegate orientation: ListView.Horizontal - - highlight: Rectangle { color: "yellow" } + highlight: Rectangle { + color: "yellow" + } currentIndex: root.current - preferredHighlightBegin: 80; preferredHighlightEnd: 220 + preferredHighlightBegin: 80 + preferredHighlightEnd: 220 highlightRangeMode: ListView.ApplyRange } ListView { id: list3 y: 320 - height: 50; width: parent.width + height: 50 + width: parent.width model: PetsModel {} delegate: petDelegate orientation: ListView.Horizontal - highlight: Rectangle { color: "yellow" } currentIndex: root.current onCurrentIndexChanged: root.current = currentIndex - preferredHighlightBegin: 125; preferredHighlightEnd: 125 + preferredHighlightBegin: 125 + preferredHighlightEnd: 125 highlightRangeMode: ListView.StrictlyEnforceRange } //! [1] @@ -159,6 +131,7 @@ Rectangle { Component { id: petDelegate Item { + id: petDelegateItem width: 160 height: column.height @@ -169,9 +142,15 @@ Rectangle { Column { id: column - Text { text: 'Name: ' + parent.name } - Text { text: 'Type: ' + parent.type } - Text { text: 'Age: ' + parent.age } + Text { + text: 'Name: ' + petDelegateItem.name + } + Text { + text: 'Type: ' + petDelegateItem.type + } + Text { + text: 'Age: ' + petDelegateItem.age + } } MouseArea { diff --git a/examples/quick/views/listview/sections.qml b/examples/quick/views/listview/sections.qml index d51ed89789..83370958fa 100644 --- a/examples/quick/views/listview/sections.qml +++ b/examples/quick/views/listview/sections.qml @@ -1,58 +1,11 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause // This example shows how a ListView can be separated into sections using // the ListView.section attached property. -import QtQuick 2.0 -import "content" +import QtQuick +import QtQuick.Controls Rectangle { id: container @@ -61,21 +14,67 @@ Rectangle { ListModel { id: animalsModel - ListElement { name: "Ant"; size: "Tiny" } - ListElement { name: "Flea"; size: "Tiny" } - ListElement { name: "Parrot"; size: "Small" } - ListElement { name: "Guinea pig"; size: "Small" } - ListElement { name: "Rat"; size: "Small" } - ListElement { name: "Butterfly"; size: "Small" } - ListElement { name: "Dog"; size: "Medium" } - ListElement { name: "Cat"; size: "Medium" } - ListElement { name: "Pony"; size: "Medium" } - ListElement { name: "Koala"; size: "Medium" } - ListElement { name: "Horse"; size: "Large" } - ListElement { name: "Tiger"; size: "Large" } - ListElement { name: "Giraffe"; size: "Large" } - ListElement { name: "Elephant"; size: "Huge" } - ListElement { name: "Whale"; size: "Huge" } + + ListElement { + name: "Ant" + size: "Tiny" + } + ListElement { + name: "Flea" + size: "Tiny" + } + ListElement { + name: "Parrot" + size: "Small" + } + ListElement { + name: "Guinea pig" + size: "Small" + } + ListElement { + name: "Rat" + size: "Small" + } + ListElement { + name: "Butterfly" + size: "Small" + } + ListElement { + name: "Dog" + size: "Medium" + } + ListElement { + name: "Cat" + size: "Medium" + } + ListElement { + name: "Pony" + size: "Medium" + } + ListElement { + name: "Koala" + size: "Medium" + } + ListElement { + name: "Horse" + size: "Large" + } + ListElement { + name: "Tiger" + size: "Large" + } + ListElement { + name: "Giraffe" + size: "Large" + } + ListElement { + name: "Elephant" + size: "Huge" + } + ListElement { + name: "Whale" + size: "Huge" + } } //! [0] @@ -83,7 +82,7 @@ Rectangle { Component { id: sectionHeading Rectangle { - width: container.width + width: ListView.view.width height: childrenRect.height color: "lightsteelblue" @@ -105,6 +104,7 @@ Rectangle { model: animalsModel delegate: Text { required property string name + text: name font.pixelSize: 18 } @@ -120,19 +120,23 @@ Rectangle { anchors.bottom: parent.bottom anchors.bottomMargin: 1 spacing: 1 - ToggleButton { - label: "CurrentLabelAtStart" - onToggled: { - if (active) + + CheckBox { + id: labelAtStartCheckBox + text: qsTr("CurrentLabelAtStart") + onClicked: { + if (checked) view.section.labelPositioning |= ViewSection.CurrentLabelAtStart else view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart } } - ToggleButton { - label: "NextLabelAtEnd" - onToggled: { - if (active) + + CheckBox { + id: labelAtEndCheckBox + text: qsTr("NextLabelAtEnd") + onClicked: { + if (checked) view.section.labelPositioning |= ViewSection.NextLabelAtEnd else view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd diff --git a/examples/quick/views/main.cpp b/examples/quick/views/main.cpp index b09597e804..d724e59961 100644 --- a/examples/quick/views/main.cpp +++ b/examples/quick/views/main.cpp @@ -1,51 +1,4 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "../shared/shared.h" DECLARATIVE_EXAMPLE_MAIN(views/views) diff --git a/examples/quick/views/objectmodel/objectmodel.qml b/examples/quick/views/objectmodel/objectmodel.qml index c9e4b8a5cd..f0b116a247 100644 --- a/examples/quick/views/objectmodel/objectmodel.qml +++ b/examples/quick/views/objectmodel/objectmodel.qml @@ -1,58 +1,13 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause // This example demonstrates placing items in a view using // an ObjectModel -import QtQuick 2.0 -import QtQml.Models 2.1 +import QtQuick +import QtQml.Models + +pragma ComponentBehavior: Bound Rectangle { id: root @@ -66,42 +21,69 @@ Rectangle { id: itemModel Rectangle { - width: view.width; height: view.height + width: view.width + height: view.height color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + + Text { + anchors.centerIn: parent + text: qsTr("Page 1") + font.bold: true + } Component.onDestruction: if (root.printDestruction) print("destroyed 1") } Rectangle { - width: view.width; height: view.height + width: view.width + height: view.height color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + + Text { + anchors.centerIn: parent + text: qsTr("Page 2") + font.bold: true + } Component.onDestruction: if (root.printDestruction) print("destroyed 2") } Rectangle { - width: view.width; height: view.height + width: view.width + height: view.height color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - Component.onDestruction: if (root.activeFocusprintDestruction) print("destroyed 3") + Text { + anchors.centerIn: parent + text: qsTr("Page 3") + font.bold: true + } + + Component.onDestruction: if (root.printDestruction) print("destroyed 3") } } ListView { id: view - anchors { fill: parent; bottomMargin: 30 } + anchors { + fill: parent + bottomMargin: 30 + } model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 + preferredHighlightBegin: 0 + preferredHighlightEnd: 0 highlightRangeMode: ListView.StrictlyEnforceRange orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + snapMode: ListView.SnapOneItem + flickDeceleration: 2000 cacheBuffer: 200 } //! [0] Rectangle { - width: root.width; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } + width: root.width + height: 30 + anchors { + top: view.bottom + bottom: parent.bottom + } color: "gray" Row { @@ -110,17 +92,18 @@ Rectangle { Repeater { model: itemModel.count - - Rectangle { + delegate: Rectangle { required property int index - width: 5; height: 5 + width: 5 + height: 5 radius: 3 - color: view.currentIndex == index ? "blue" : "white" + color: view.currentIndex === index ? "blue" : "white" MouseArea { - width: 20; height: 20 anchors.centerIn: parent + width: 20 + height: 20 onClicked: view.currentIndex = parent.index } } diff --git a/examples/quick/views/package/Delegate.qml b/examples/quick/views/package/Delegate.qml index 9f4f1946d8..7f3eeaa833 100644 --- a/examples/quick/views/package/Delegate.qml +++ b/examples/quick/views/package/Delegate.qml @@ -1,54 +1,7 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick //! [0] Package { @@ -58,26 +11,50 @@ Package { required property int index required property string display - Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' } + Text { + id: listDelegate + width: parent.width + height: 25 + text: 'Empty' + Package.name: 'list' + } + + Text { + id: gridDelegate + width: parent.width / 2 + height: 50 + text: 'Empty' + Package.name: 'grid' + } Rectangle { id: wrapper - width: parent.width; height: 25 + width: parent?.width ?? 0 + height: 25 color: 'lightsteelblue' - Text { text: delegate.display; anchors.centerIn: parent } + Text { + text: delegate.display + anchors.centerIn: parent + } state: delegate.upTo > delegate.index ? 'inGrid' : 'inList' states: [ State { name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } + ParentChange { + target: wrapper + parent: listDelegate + } }, State { name: 'inGrid' ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + target: wrapper + parent: gridDelegate + x: 0 + y: 0 + width: gridDelegate.width + height: gridDelegate.height } } ] @@ -85,7 +62,10 @@ Package { transitions: [ Transition { ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + NumberAnimation { + properties: 'x,y,width,height' + duration: 300 + } } } ] diff --git a/examples/quick/views/package/view.qml b/examples/quick/views/package/view.qml index 632d27c724..a9a0c46198 100644 --- a/examples/quick/views/package/view.qml +++ b/examples/quick/views/package/view.qml @@ -1,66 +1,27 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 -import QtQml.Models 2.1 +import QtQuick +import QtQml.Models + +pragma ComponentBehavior: Bound Rectangle { id: root color: "white" width: 320 height: 480 - property int upTo: 0 + property int upTo SequentialAnimation on upTo { loops: -1 - NumberAnimation { to: 8; duration: 3500 } - NumberAnimation { to: 0; duration: 3500 } + NumberAnimation { + to: 8 + duration: 3500 + } + NumberAnimation { + to: 0 + duration: 3500 + } } ListModel { @@ -85,14 +46,14 @@ Rectangle { ListView { id: lv - height: parent.height/2 + height: parent.height / 2 width: parent.width model: visualModel.parts.list } GridView { - y: parent.height/2 - height: parent.height/2 + y: parent.height / 2 + height: parent.height / 2 width: parent.width cellWidth: width / 2 cellHeight: 50 diff --git a/examples/quick/views/pathview/pathview-example.qml b/examples/quick/views/pathview/pathview-example.qml index e42117dfae..f1ecd099c1 100644 --- a/examples/quick/views/pathview/pathview-example.qml +++ b/examples/quick/views/pathview/pathview-example.qml @@ -1,74 +1,50 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 +import QtQuick Rectangle { - width: 400; height: 240 + width: 400 + height: 240 color: "white" ListModel { id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + ListElement { + name: "Music" + icon: "pics/AudioPlayer_48.png" + } + ListElement { + name: "Movies" + icon: "pics/VideoPlayer_48.png" + } + ListElement { + name: "Camera" + icon: "pics/Camera_48.png" + } + ListElement { + name: "Calendar" + icon: "pics/DateBook_48.png" + } + ListElement { + name: "Messaging" + icon: "pics/EMail_48.png" + } + ListElement { + name: "Todo List" + icon: "pics/TodoList_48.png" + } + ListElement { + name: "Contacts" + icon: "pics/AddressBook_48.png" + } } Component { id: appDelegate Item { - width: 100; height: 100 + width: 100 + height: 100 scale: PathView.iconScale required property string name @@ -77,11 +53,15 @@ Rectangle { Image { id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter + y: 20 + anchors.horizontalCenter: parent.horizontalCenter source: parent.icon } Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + anchors { + top: myIcon.bottom + horizontalCenter: parent.horizontalCenter + } text: parent.name } @@ -94,7 +74,11 @@ Rectangle { Component { id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } + Rectangle { + width: 80 + height: 80 + color: "lightsteelblue" + } } PathView { @@ -109,11 +93,30 @@ Rectangle { path: Path { startX: 10 startY: 50 - PathAttribute { name: "iconScale"; value: 0.5 } - PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } - PathAttribute { name: "iconScale"; value: 1.0 } - PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } - PathAttribute { name: "iconScale"; value: 0.5 } + PathAttribute { + name: "iconScale" + value: 0.5 + } + PathQuad { + x: 200 + y: 150 + controlX: 50 + controlY: 200 + } + PathAttribute { + name: "iconScale" + value: 1.0 + } + PathQuad { + x: 390 + y: 50 + controlX: 350 + controlY: 200 + } + PathAttribute { + name: "iconScale" + value: 0.5 + } } } } diff --git a/examples/quick/views/views.qml b/examples/quick/views/views.qml index bdf05269ae..77b16fa6bb 100644 --- a/examples/quick/views/views.qml +++ b/examples/quick/views/views.qml @@ -1,56 +1,8 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.0 -import QtQml.Models 2.1 -import "../shared" as Examples +import QtQuick +import shared as Examples Item { height: 480 @@ -67,9 +19,8 @@ Item { addExample("Sections", "ListView section headers and footers", Qt.resolvedUrl("listview/sections.qml")) addExample("Packages", "Transitions between a ListView and GridView", Qt.resolvedUrl("package/view.qml")) addExample("PathView", "A simple PathView", Qt.resolvedUrl("pathview/pathview-example.qml")) - addExample("ObjectModel", "Using a ObjectModel", Qt.resolvedUrl("objectmodel/objectmodel.qml")) + addExample("ObjectModel", "Using an ObjectModel", Qt.resolvedUrl("objectmodel/objectmodel.qml")) addExample("Display Margins", "A ListView with display margins", Qt.resolvedUrl("listview/displaymargin.qml")) - addExample("DelegateModel", "A PathView using DelegateModel to instantiate delegates", Qt.resolvedUrl("delegatemodel/slideshow.qml")) addExample("Draggable Selections", "Enabling drag-and-drop on DelegateModel delegates", Qt.resolvedUrl("delegatemodel/dragselection.qml")) } } diff --git a/examples/quick/views/views.qmlproject b/examples/quick/views/views.qmlproject index 7e6baf0a7f..f0e49ad008 100644 --- a/examples/quick/views/views.qmlproject +++ b/examples/quick/views/views.qmlproject @@ -2,6 +2,7 @@ import QmlProject 1.1 Project { mainFile: "views.qml" + importPaths: [ "../" ] /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { diff --git a/examples/quick/views/views.qrc b/examples/quick/views/views.qrc index 1646c49e81..9b16e81321 100644 --- a/examples/quick/views/views.qrc +++ b/examples/quick/views/views.qrc @@ -1,5 +1,6 @@ <RCC> - <qresource prefix="/views"> + <qresource prefix="/qt/qml/views"> + <file>gridview/gridview-example.qml</file> <file>gridview/pics/AddressBook_48.png</file> <file>gridview/pics/AudioPlayer_48.png</file> @@ -41,7 +42,6 @@ <file>pathview/pics/EMail_48.png</file> <file>pathview/pics/TodoList_48.png</file> <file>pathview/pics/VideoPlayer_48.png</file> - <file>delegatemodel/slideshow.qml</file> <file>delegatemodel/dragselection.qml</file> <file>objectmodel/objectmodel.qml</file> <file>views.qml</file> |