aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/views/listview
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/views/listview')
-rw-r--r--examples/quick/views/listview/content/PetsModel.qml53
-rw-r--r--examples/quick/views/listview/content/PressAndHoldButton.qml55
-rw-r--r--examples/quick/views/listview/content/RecipesModel.qml85
-rw-r--r--examples/quick/views/listview/content/SmallText.qml55
-rw-r--r--examples/quick/views/listview/content/TextButton.qml55
-rw-r--r--examples/quick/views/listview/content/ToggleButton.qml53
-rw-r--r--examples/quick/views/listview/displaymargin.qml59
-rw-r--r--examples/quick/views/listview/dynamiclist.qml153
-rw-r--r--examples/quick/views/listview/expandingdelegates.qml161
-rw-r--r--examples/quick/views/listview/highlight.qml99
-rw-r--r--examples/quick/views/listview/highlightranges.qml117
-rw-r--r--examples/quick/views/listview/sections.qml154
12 files changed, 368 insertions, 731 deletions
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