aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/quickcontrols2/contactlist/ContactView.ui.qml6
-rw-r--r--examples/quickcontrols2/gallery/gallery.qml20
-rw-r--r--src/imports/controls/ComboBox.qml11
-rw-r--r--src/imports/controls/HorizontalHeaderView.qml59
-rw-r--r--src/imports/controls/VerticalHeaderView.qml59
-rw-r--r--src/imports/controls/controls.pri4
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml2
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-headerview-simple.qml123
-rw-r--r--src/imports/controls/doc/src/includes/customize-button-background.qdocinc25
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc120
-rw-r--r--src/imports/controls/fusion/ComboBox.qml15
-rw-r--r--src/imports/controls/fusion/HorizontalHeaderView.qml69
-rw-r--r--src/imports/controls/fusion/VerticalHeaderView.qml69
-rw-r--r--src/imports/controls/fusion/fusion.pri4
-rw-r--r--src/imports/controls/imagine/ComboBox.qml13
-rw-r--r--src/imports/controls/imagine/HorizontalHeaderView.qml59
-rw-r--r--src/imports/controls/imagine/VerticalHeaderView.qml59
-rw-r--r--src/imports/controls/imagine/imagine.pri4
-rw-r--r--src/imports/controls/material/ComboBox.qml15
-rw-r--r--src/imports/controls/material/CursorDelegate.qml2
-rw-r--r--src/imports/controls/material/HorizontalHeaderView.qml60
-rw-r--r--src/imports/controls/material/VerticalHeaderView.qml60
-rw-r--r--src/imports/controls/material/material.pri4
-rw-r--r--src/imports/controls/material/shaders/+qsb/RectangularGlow.fragbin2321 -> 2007 bytes
-rw-r--r--src/imports/controls/material/shaders/compile.bat40
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp4
-rw-r--r--src/imports/controls/universal/ComboBox.qml13
-rw-r--r--src/imports/controls/universal/HorizontalHeaderView.qml61
-rw-r--r--src/imports/controls/universal/VerticalHeaderView.qml61
-rw-r--r--src/imports/controls/universal/universal.pri4
-rw-r--r--src/imports/platform/qquickplatformdialog.cpp2
-rw-r--r--src/imports/platform/qquickplatformfiledialog.cpp2
-rw-r--r--src/imports/platform/qquickplatformfolderdialog.cpp2
-rw-r--r--src/imports/templates/qtquicktemplates2plugin.cpp8
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp10
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p_p.h4
-rw-r--r--src/quicktemplates2/qquickaction.cpp17
-rw-r--r--src/quicktemplates2/qquickaction_p_p.h6
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp2
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp135
-rw-r--r--src/quicktemplates2/qquickcombobox_p.h11
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp2
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp22
-rw-r--r--src/quicktemplates2/qquickcontrol_p_p.h6
-rw-r--r--src/quicktemplates2/qquickdeferredexecute.cpp10
-rw-r--r--src/quicktemplates2/qquickdial.cpp2
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp2
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox_p_p.h2
-rw-r--r--src/quicktemplates2/qquickgroupbox.cpp2
-rw-r--r--src/quicktemplates2/qquickheaderview.cpp500
-rw-r--r--src/quicktemplates2/qquickheaderview_p.h125
-rw-r--r--src/quicktemplates2/qquickheaderview_p_p.h136
-rw-r--r--src/quicktemplates2/qquicklabel.cpp2
-rw-r--r--src/quicktemplates2/qquickmenuitem.cpp2
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp8
-rw-r--r--src/quicktemplates2/qquickpopup.cpp2
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp4
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp2
-rw-r--r--src/quicktemplates2/qquickslider.cpp2
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp2
-rw-r--r--src/quicktemplates2/qquickstackelement.cpp6
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp2
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp2
-rw-r--r--src/quicktemplates2/quicktemplates2.pri3
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/controls/data/tst_combobox.qml16
-rw-r--r--tests/auto/controls/data/tst_spinbox.qml16
-rw-r--r--tests/auto/customization/data/styles/identified/AbstractButton.qml3
-rw-r--r--tests/auto/customization/tst_customization.cpp36
-rw-r--r--tests/auto/qquickheaderview/data/Window.qml121
-rw-r--r--tests/auto/qquickheaderview/qquickheaderview.pro15
-rw-r--r--tests/auto/qquickheaderview/tst_qquickheaderview.cpp354
-rw-r--r--tests/auto/qquickpopup/data/tabFence.qml97
-rw-r--r--tests/auto/qquickpopup/tst_qquickpopup.cpp61
-rw-r--r--tests/manual/headerview/headerview.pro10
-rw-r--r--tests/manual/headerview/main.cpp218
-rw-r--r--tests/manual/headerview/main.qml130
-rw-r--r--tests/manual/manual.pro1
80 files changed, 2984 insertions, 189 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 7db332a6..31431340 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -5,4 +5,4 @@ DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST
QQC2_SOURCE_TREE = $$PWD
-MODULE_VERSION = 5.14.2
+MODULE_VERSION = 5.15.0
diff --git a/examples/quickcontrols2/contactlist/ContactView.ui.qml b/examples/quickcontrols2/contactlist/ContactView.ui.qml
index 747f3042..984fc787 100644
--- a/examples/quickcontrols2/contactlist/ContactView.ui.qml
+++ b/examples/quickcontrols2/contactlist/ContactView.ui.qml
@@ -72,11 +72,7 @@ ListView {
delegate: ContactDelegate {
id: delegate
width: listView.width
-
- Connections {
- target: delegate
- onPressAndHold: listView.pressAndHold(index)
- }
+ onPressAndHold: listView.pressAndHold(index)
}
model: ContactModel {
diff --git a/examples/quickcontrols2/gallery/gallery.qml b/examples/quickcontrols2/gallery/gallery.qml
index 44987ada..44090b8a 100644
--- a/examples/quickcontrols2/gallery/gallery.qml
+++ b/examples/quickcontrols2/gallery/gallery.qml
@@ -62,6 +62,17 @@ ApplicationWindow {
visible: true
title: "Qt Quick Controls 2"
+ function help() {
+ let displayingControl = listView.currentIndex !== -1
+ let currentControlName = displayingControl
+ ? listView.model.get(listView.currentIndex).title.toLowerCase() : ""
+ let url = "https://doc.qt.io/qt-5/"
+ + (displayingControl
+ ? "qml-qtquick-controls2-" + currentControlName + ".html"
+ : "qtquick-controls2-qmlmodule.html");
+ Qt.openUrlExternally(url)
+ }
+
Settings {
id: settings
property string style: "Default"
@@ -73,6 +84,11 @@ ApplicationWindow {
onActivated: navigateBackAction.trigger()
}
+ Shortcut {
+ sequence: StandardKey.HelpContents
+ onActivated: help()
+ }
+
Action {
id: navigateBackAction
icon.name: stackView.depth > 1 ? "back" : "drawer"
@@ -131,6 +147,10 @@ ApplicationWindow {
onTriggered: settingsDialog.open()
}
Action {
+ text: "Help"
+ onTriggered: help()
+ }
+ Action {
text: "About"
onTriggered: aboutDialog.open()
}
diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml
index 8eefc686..b30293f5 100644
--- a/src/imports/controls/ComboBox.qml
+++ b/src/imports/controls/ComboBox.qml
@@ -34,11 +34,11 @@
**
****************************************************************************/
-import QtQuick 2.14
-import QtQuick.Window 2.14
-import QtQuick.Controls 2.14
-import QtQuick.Controls.impl 2.14
-import QtQuick.Templates 2.14 as T
+import QtQuick 2.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Controls.impl 2.15
+import QtQuick.Templates 2.15 as T
T.ComboBox {
id: control
@@ -84,6 +84,7 @@ T.ComboBox {
readOnly: control.down
inputMethodHints: control.inputMethodHints
validator: control.validator
+ selectByMouse: control.selectTextByMouse
font: control.font
color: control.editable ? control.palette.text : control.palette.buttonText
diff --git a/src/imports/controls/HorizontalHeaderView.qml b/src/imports/controls/HorizontalHeaderView.qml
new file mode 100644
index 00000000..946d3a75
--- /dev/null
+++ b/src/imports/controls/HorizontalHeaderView.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+
+T.HorizontalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: "#f6f6f6"
+ border.color: "#e4e4e4"
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "#ff26282a"
+ }
+ }
+}
diff --git a/src/imports/controls/VerticalHeaderView.qml b/src/imports/controls/VerticalHeaderView.qml
new file mode 100644
index 00000000..67d4c1ce
--- /dev/null
+++ b/src/imports/controls/VerticalHeaderView.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+
+T.VerticalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: "#f6f6f6"
+ border.color: "#e4e4e4"
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "#ff26282a"
+ }
+ }
+}
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index fbf5d075..03fc0f4b 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -32,6 +32,7 @@ QML_FILES += \
$$PWD/Drawer.qml \
$$PWD/Frame.qml \
$$PWD/GroupBox.qml \
+ $$PWD/HorizontalHeaderView.qml \
$$PWD/ItemDelegate.qml \
$$PWD/Label.qml \
$$PWD/Menu.qml \
@@ -67,4 +68,5 @@ QML_FILES += \
$$PWD/ToolButton.qml \
$$PWD/ToolSeparator.qml \
$$PWD/ToolTip.qml \
- $$PWD/Tumbler.qml
+ $$PWD/Tumbler.qml \
+ $$PWD/VerticalHeaderView.qml
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml
index 1bb68bdf..b902dab1 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-combobox-custom.qml
@@ -55,7 +55,7 @@ ComboBox {
Connections {
target: control
- onPressedChanged: canvas.requestPaint()
+ function onPressedChanged() { canvas.requestPaint(); }
}
onPaint: {
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml
index 86c6a0b7..4bcbaa67 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-delaybutton-custom.qml
@@ -62,7 +62,7 @@ DelayButton {
Connections {
target: control
- onProgressChanged: canvas.requestPaint()
+ function onProgressChanged() { canvas.requestPaint(); }
}
onPaint: {
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-headerview-simple.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-headerview-simple.qml
new file mode 100644
index 00000000..bea46bf3
--- /dev/null
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-headerview-simple.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation 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$
+**
+****************************************************************************/
+
+//![file]
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import Qt.labs.qmlmodels 1.0
+
+ApplicationWindow {
+ visible: true
+ width: 640
+ height: 480
+
+ //! [horizontal]
+ HorizontalHeaderView {
+ id: horizontalHeader
+ syncView: tableView
+ anchors.left: tableView.left
+ width: parent.width
+ height: contentHeight
+ }
+ //! [horizontal]
+
+ //! [vertical]
+ VerticalHeaderView {
+ id: verticalHeader
+ syncView: tableView
+ anchors.top: tableView.top
+ width: contentWidth
+ height: parent.height
+ }
+ //! [vertical]
+
+ TableView {
+ id: tableView
+ anchors.fill: parent
+ anchors.topMargin: horizontalHeader.height
+ anchors.leftMargin: verticalHeader.width
+ columnSpacing: 1
+ rowSpacing: 1
+ clip: true
+
+ model: TableModel {
+ TableModelColumn { display: "name" }
+ TableModelColumn { display: "color" }
+
+ rows: [
+ {
+ "name": "cat",
+ "color": "black"
+ },
+ {
+ "name": "dog",
+ "color": "brown"
+ },
+ {
+ "name": "bird",
+ "color": "white"
+ }
+ ]
+ }
+
+ delegate: Rectangle {
+ implicitWidth: 100
+ implicitHeight: 50
+ border.width: 1
+
+ Text {
+ text: display
+ anchors.centerIn: parent
+ }
+ }
+ }
+}
+
+//![file]
diff --git a/src/imports/controls/doc/src/includes/customize-button-background.qdocinc b/src/imports/controls/doc/src/includes/customize-button-background.qdocinc
new file mode 100644
index 00000000..59df7d8e
--- /dev/null
+++ b/src/imports/controls/doc/src/includes/customize-button-background.qdocinc
@@ -0,0 +1,25 @@
+//! [file]
+\qml \QtMinorVersion
+import QtQuick 2.\1
+import QtQuick.Controls 2.\1
+
+ApplicationWindow {
+ width: 400
+ height: 400
+ visible: true
+
+ Button {
+ id: button
+ text: "A Special Button"
+ background: Rectangle {
+ implicitWidth: 100
+ implicitHeight: 40
+ color: button.down ? "#d6d6d6" : "#f6f6f6"
+ border.color: "#26282a"
+ border.width: 1
+ radius: 4
+ }
+ }
+}
+\endqml
+//! [file]
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
index ca1ecf48..5901663a 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc
@@ -48,29 +48,7 @@
can override the \l {Control::}{background} item and set the radius
property of Rectangle:
- \qml \QtMinorVersion
- import QtQuick 2.\1
- import QtQuick.Controls 2.\1
-
- ApplicationWindow {
- width: 400
- height: 400
- visible: true
-
- Button {
- id: button
- text: "A Special Button"
- background: Rectangle {
- implicitWidth: 100
- implicitHeight: 40
- color: button.down ? "#d6d6d6" : "#f6f6f6"
- border.color: "#26282a"
- border.width: 1
- radius: 4
- }
- }
- }
- \endqml
+ \include customize-button-background.qdocinc file
The second way to create the button is good if you plan to use your rounded
button in several places. It involves moving the code into its own QML file
@@ -214,6 +192,102 @@
files.
\endlist
+ \section3 Considerations for custom styles
+
+ When implementing your own style and customizing controls, there are some
+ points to keep in mind to ensure that your application is as performant as
+ possible.
+
+ \section4 Avoid assigning an id to styles' implementations of item delegates
+
+ As explained in \l {Definition of a Style}, when you implement your
+ own style for a control, you start off with the relevant template for
+ that control. For example, a style's \c Button.qml will be structured
+ similarly to this:
+
+ \qml
+ T.Button {
+ // ...
+
+ background: Rectangle {
+ // ...
+ }
+
+ contentItem: Text {
+ // ...
+ }
+
+ // ...
+ }
+ \endqml
+
+ When you use a Button in your application, the \c background and
+ \c contentItem items will be created and parented to the root \c Button
+ item:
+
+ \qml
+ // Creates the Button root item, the Rectangle background,
+ // and the Text contentItem.
+ Button {
+ text: qsTr("Confirm")
+ }
+ \endqml
+
+ Suppose you then needed to do a one-off customization of the Button (as
+ explained in \l {Customizing a Control}):
+
+ \include customize-button-background.qdocinc file
+
+ In QML, this would normally result in both the default \c background
+ implementation and the one-off, custom \c background items being created.
+ Qt Quick Controls uses a technique that avoids creating both items, and
+ instead only creates the custom \c background, greatly improving the
+ creation performance of controls.
+
+ This technique relies on the absence of an \l {The id Attribute}{id} in the
+ style's implementation of that item. If an id is assigned, the technique
+ cannot work, and both items will be created. For example, it can be
+ tempting to assign an id to the \c background or \c contentItem so that
+ other objects within the file can refer to those items:
+
+ \qml
+ T.Button {
+ // ...
+
+ background: Rectangle {
+ id: backgroundRect
+ // ...
+ }
+
+ contentItem: Text {
+ // Use backgroundRect in some way...
+ }
+
+ // ...
+ }
+ \endqml
+
+ With this code, every time a Button instance with a customized background
+ is created, both backgrounds will be created, resulting in sub-optimal
+ creation performance.
+
+ Prior to Qt 5.15, the old, unused background would be deleted to release
+ the resources associated with it. However, as the control does not own the
+ items, it should not delete them. As of Qt 5.15, old items are no longer
+ deleted, and so the \c backgroundRect item will live longer than it needs
+ to—typically until the application exits. Although the old item will be
+ hidden, visually unparented from the control, and removed from the
+ accessibility tree, it is important to keep the creation time and memory
+ usage of these unused items in mind when assigning an id in this context.
+
+ \section4 Avoid imperative assignments of custom items
+
+ The technique mentioned in the section above only works when an item is
+ \l {Prefer Declarative Bindings Over Imperative Assignments}{declaratively}
+ assigned for the first time, and so imperative assignments will result in
+ orphaned items. Always use declarative bindings to assign custom items
+ when possible.
+
\section3 Attached properties
It is common for a style to have certain properties or attributes that
diff --git a/src/imports/controls/fusion/ComboBox.qml b/src/imports/controls/fusion/ComboBox.qml
index e9b836ef..d8ef1888 100644
--- a/src/imports/controls/fusion/ComboBox.qml
+++ b/src/imports/controls/fusion/ComboBox.qml
@@ -34,13 +34,13 @@
**
****************************************************************************/
-import QtQuick 2.14
-import QtQuick.Window 2.14
-import QtQuick.Templates 2.14 as T
-import QtQuick.Controls 2.14
-import QtQuick.Controls.impl 2.14
-import QtQuick.Controls.Fusion 2.14
-import QtQuick.Controls.Fusion.impl 2.14
+import QtQuick 2.15
+import QtQuick.Window 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls 2.15
+import QtQuick.Controls.impl 2.15
+import QtQuick.Controls.Fusion 2.15
+import QtQuick.Controls.Fusion.impl 2.15
T.ComboBox {
id: control
@@ -84,6 +84,7 @@ T.ComboBox {
readOnly: control.down
inputMethodHints: control.inputMethodHints
validator: control.validator
+ selectByMouse: control.selectTextByMouse
font: control.font
color: control.editable ? control.palette.text : control.palette.buttonText
diff --git a/src/imports/controls/fusion/HorizontalHeaderView.qml b/src/imports/controls/fusion/HorizontalHeaderView.qml
new file mode 100644
index 00000000..0be27642
--- /dev/null
+++ b/src/imports/controls/fusion/HorizontalHeaderView.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+
+T.HorizontalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ border.color: "#cacaca"
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0
+ color: "#fbfbfb"
+ }
+ GradientStop {
+ position: 1
+ color: "#e0dfe0"
+ }
+ }
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "#ff26282a"
+ }
+ }
+}
diff --git a/src/imports/controls/fusion/VerticalHeaderView.qml b/src/imports/controls/fusion/VerticalHeaderView.qml
new file mode 100644
index 00000000..a9eadc23
--- /dev/null
+++ b/src/imports/controls/fusion/VerticalHeaderView.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+
+T.VerticalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ border.color: "#cacaca"
+
+ gradient: Gradient {
+ GradientStop {
+ position: 0
+ color: "#fbfbfb"
+ }
+ GradientStop {
+ position: 1
+ color: "#e0dfe0"
+ }
+ }
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "#ff26282a"
+ }
+ }
+}
diff --git a/src/imports/controls/fusion/fusion.pri b/src/imports/controls/fusion/fusion.pri
index 72978db5..bdc413fd 100644
--- a/src/imports/controls/fusion/fusion.pri
+++ b/src/imports/controls/fusion/fusion.pri
@@ -28,6 +28,7 @@ QML_FILES += \
$$PWD/Drawer.qml \
$$PWD/Frame.qml \
$$PWD/GroupBox.qml \
+ $$PWD/HorizontalHeaderView.qml \
$$PWD/ItemDelegate.qml \
$$PWD/Label.qml \
$$PWD/Menu.qml \
@@ -64,4 +65,5 @@ QML_FILES += \
$$PWD/ToolButton.qml \
$$PWD/ToolSeparator.qml \
$$PWD/ToolTip.qml \
- $$PWD/Tumbler.qml
+ $$PWD/Tumbler.qml \
+ $$PWD/VerticalHeaderView.qml
diff --git a/src/imports/controls/imagine/ComboBox.qml b/src/imports/controls/imagine/ComboBox.qml
index 2d582e98..92937826 100644
--- a/src/imports/controls/imagine/ComboBox.qml
+++ b/src/imports/controls/imagine/ComboBox.qml
@@ -34,12 +34,12 @@
**
****************************************************************************/
-import QtQuick 2.14
-import QtQuick.Window 2.14
-import QtQuick.Templates 2.14 as T
-import QtQuick.Controls 2.14
-import QtQuick.Controls.Imagine 2.14
-import QtQuick.Controls.Imagine.impl 2.14
+import QtQuick 2.15
+import QtQuick.Window 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls 2.15
+import QtQuick.Controls.Imagine 2.15
+import QtQuick.Controls.Imagine.impl 2.15
T.ComboBox {
id: control
@@ -98,6 +98,7 @@ T.ComboBox {
readOnly: control.down
inputMethodHints: control.inputMethodHints
validator: control.validator
+ selectByMouse: control.selectTextByMouse
font: control.font
color: control.flat ? control.palette.windowText : control.editable ? control.palette.text : control.palette.buttonText
diff --git a/src/imports/controls/imagine/HorizontalHeaderView.qml b/src/imports/controls/imagine/HorizontalHeaderView.qml
new file mode 100644
index 00000000..946d3a75
--- /dev/null
+++ b/src/imports/controls/imagine/HorizontalHeaderView.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+
+T.HorizontalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: "#f6f6f6"
+ border.color: "#e4e4e4"
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "#ff26282a"
+ }
+ }
+}
diff --git a/src/imports/controls/imagine/VerticalHeaderView.qml b/src/imports/controls/imagine/VerticalHeaderView.qml
new file mode 100644
index 00000000..67d4c1ce
--- /dev/null
+++ b/src/imports/controls/imagine/VerticalHeaderView.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+
+T.VerticalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: "#f6f6f6"
+ border.color: "#e4e4e4"
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: "#ff26282a"
+ }
+ }
+}
diff --git a/src/imports/controls/imagine/imagine.pri b/src/imports/controls/imagine/imagine.pri
index 081a509e..4c6bcf1b 100644
--- a/src/imports/controls/imagine/imagine.pri
+++ b/src/imports/controls/imagine/imagine.pri
@@ -12,6 +12,7 @@ QML_FILES += \
$$PWD/Drawer.qml \
$$PWD/Frame.qml \
$$PWD/GroupBox.qml \
+ $$PWD/HorizontalHeaderView.qml \
$$PWD/ItemDelegate.qml \
$$PWD/Label.qml \
$$PWD/Menu.qml \
@@ -44,7 +45,8 @@ QML_FILES += \
$$PWD/ToolButton.qml \
$$PWD/ToolSeparator.qml \
$$PWD/ToolTip.qml \
- $$PWD/Tumbler.qml
+ $$PWD/Tumbler.qml \
+ $$PWD/VerticalHeaderView.qml
HEADERS += \
$$PWD/qquickimageselector_p.h \
diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml
index 7d635902..e4ee332b 100644
--- a/src/imports/controls/material/ComboBox.qml
+++ b/src/imports/controls/material/ComboBox.qml
@@ -34,13 +34,13 @@
**
****************************************************************************/
-import QtQuick 2.14
-import QtQuick.Window 2.14
-import QtQuick.Controls 2.14
-import QtQuick.Controls.impl 2.14
-import QtQuick.Templates 2.14 as T
-import QtQuick.Controls.Material 2.14
-import QtQuick.Controls.Material.impl 2.14
+import QtQuick 2.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Controls.impl 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls.Material 2.15
+import QtQuick.Controls.Material.impl 2.15
T.ComboBox {
id: control
@@ -89,6 +89,7 @@ T.ComboBox {
readOnly: control.down
inputMethodHints: control.inputMethodHints
validator: control.validator
+ selectByMouse: control.selectTextByMouse
font: control.font
color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
diff --git a/src/imports/controls/material/CursorDelegate.qml b/src/imports/controls/material/CursorDelegate.qml
index 1626a6fb..fe2d25c6 100644
--- a/src/imports/controls/material/CursorDelegate.qml
+++ b/src/imports/controls/material/CursorDelegate.qml
@@ -46,7 +46,7 @@ Rectangle {
Connections {
target: cursor.parent
- onCursorPositionChanged: {
+ function onCursorPositionChanged() {
// keep a moving cursor visible
cursor.opacity = 1
timer.restart()
diff --git a/src/imports/controls/material/HorizontalHeaderView.qml b/src/imports/controls/material/HorizontalHeaderView.qml
new file mode 100644
index 00000000..a1228cdc
--- /dev/null
+++ b/src/imports/controls/material/HorizontalHeaderView.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls.Material 2.15
+import QtQuick.Controls.Material.impl 2.15
+
+T.HorizontalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: control.Material.backgroundColor
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: enabled ? control.Material.foreground : control.Material.hintTextColor
+ }
+ }
+}
diff --git a/src/imports/controls/material/VerticalHeaderView.qml b/src/imports/controls/material/VerticalHeaderView.qml
new file mode 100644
index 00000000..8acda3d7
--- /dev/null
+++ b/src/imports/controls/material/VerticalHeaderView.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls.Material 2.15
+import QtQuick.Controls.Material.impl 2.15
+
+T.VerticalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: control.Material.backgroundColor
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: enabled ? control.Material.foreground : control.Material.hintTextColor
+ }
+ }
+}
diff --git a/src/imports/controls/material/material.pri b/src/imports/controls/material/material.pri
index bda1fb21..457a8df1 100644
--- a/src/imports/controls/material/material.pri
+++ b/src/imports/controls/material/material.pri
@@ -30,6 +30,7 @@ QML_FILES += \
$$PWD/ElevationEffect.qml \
$$PWD/Frame.qml \
$$PWD/GroupBox.qml \
+ $$PWD/HorizontalHeaderView.qml \
$$PWD/ItemDelegate.qml \
$$PWD/Label.qml \
$$PWD/Menu.qml \
@@ -68,4 +69,5 @@ QML_FILES += \
$$PWD/ToolButton.qml \
$$PWD/ToolSeparator.qml \
$$PWD/ToolTip.qml \
- $$PWD/Tumbler.qml
+ $$PWD/Tumbler.qml \
+ $$PWD/VerticalHeaderView.qml
diff --git a/src/imports/controls/material/shaders/+qsb/RectangularGlow.frag b/src/imports/controls/material/shaders/+qsb/RectangularGlow.frag
index a805b134..5cfa2db6 100644
--- a/src/imports/controls/material/shaders/+qsb/RectangularGlow.frag
+++ b/src/imports/controls/material/shaders/+qsb/RectangularGlow.frag
Binary files differ
diff --git a/src/imports/controls/material/shaders/compile.bat b/src/imports/controls/material/shaders/compile.bat
new file mode 100644
index 00000000..e87efa7a
--- /dev/null
+++ b/src/imports/controls/material/shaders/compile.bat
@@ -0,0 +1,40 @@
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::
+:: Copyright (C) 2019 The Qt Company Ltd.
+:: Contact: https://www.qt.io/licensing/
+::
+:: This file is part of the QtQuick module of the Qt Toolkit.
+::
+:: $QT_BEGIN_LICENSE:LGPL$
+:: 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 Lesser General Public License Usage
+:: Alternatively, this file may be used under the terms of the GNU Lesser
+:: General Public License version 3 as published by the Free Software
+:: Foundation and appearing in the file LICENSE.LGPL3 included in the
+:: packaging of this file. Please review the following information to
+:: ensure the GNU Lesser General Public License version 3 requirements
+:: will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+::
+:: GNU General Public License Usage
+:: Alternatively, this file may be used under the terms of the GNU
+:: General Public License version 2.0 or (at your option) the GNU General
+:: Public license version 3 or any later version approved by the KDE Free
+:: Qt Foundation. The licenses are as published by the Free Software
+:: Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+:: included in the packaging of this file. Please review the following
+:: information to ensure the GNU General Public License requirements will
+:: be met: https://www.gnu.org/licenses/gpl-2.0.html and
+:: https://www.gnu.org/licenses/gpl-3.0.html.
+::
+:: $QT_END_LICENSE$
+::
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/RectangularGlow.frag RectangularGlow_rhi.frag
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 260e7297..9fe82ba2 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -198,6 +198,10 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<QQuickSplitHandleAttached>(uri, 2, 13, "SplitHandle",
QStringLiteral("SplitHandle is only available as an attached property."));
+ // QtQuick.Controls 2.15 (new types in Qt 5.15)
+ qmlRegisterType(resolvedUrl(QStringLiteral("HorizontalHeaderView.qml")), uri, 2, 15, "HorizontalHeaderView");
+ qmlRegisterType(resolvedUrl(QStringLiteral("VerticalHeaderView.qml")), uri, 2, 15, "VerticalHeaderView");
+
// Register the latest version, even if there are no new types or new revisions for existing types yet.
// Before Qt 5.12, we would do the following:
//
diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml
index 9a4e119b..fd2d8935 100644
--- a/src/imports/controls/universal/ComboBox.qml
+++ b/src/imports/controls/universal/ComboBox.qml
@@ -34,12 +34,12 @@
**
****************************************************************************/
-import QtQuick 2.14
-import QtQuick.Window 2.14
-import QtQuick.Controls 2.14
-import QtQuick.Controls.impl 2.14
-import QtQuick.Templates 2.14 as T
-import QtQuick.Controls.Universal 2.14
+import QtQuick 2.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Controls.impl 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls.Universal 2.15
T.ComboBox {
id: control
@@ -94,6 +94,7 @@ T.ComboBox {
readOnly: control.down
inputMethodHints: control.inputMethodHints
validator: control.validator
+ selectByMouse: control.selectTextByMouse
font: control.font
color: !control.enabled ? control.Universal.chromeDisabledLowColor :
diff --git a/src/imports/controls/universal/HorizontalHeaderView.qml b/src/imports/controls/universal/HorizontalHeaderView.qml
new file mode 100644
index 00000000..6f48560e
--- /dev/null
+++ b/src/imports/controls/universal/HorizontalHeaderView.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Controls.impl 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls.Universal 2.15
+import QtQuick.Controls.Universal.impl 2.15
+
+T.HorizontalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: control.Universal.background
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2)
+ }
+ }
+}
diff --git a/src/imports/controls/universal/VerticalHeaderView.qml b/src/imports/controls/universal/VerticalHeaderView.qml
new file mode 100644
index 00000000..80133dbd
--- /dev/null
+++ b/src/imports/controls/universal/VerticalHeaderView.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Controls.impl 2.15
+import QtQuick.Templates 2.15 as T
+import QtQuick.Controls.Universal 2.15
+import QtQuick.Controls.Universal.impl 2.15
+
+T.VerticalHeaderView {
+ id: control
+
+ delegate: Rectangle {
+ implicitWidth: 50
+ implicitHeight: 25
+ color: control.Universal.background
+
+ Text {
+ text: model[control.textRole]
+ width: parent.width
+ height: parent.height
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2)
+ }
+ }
+}
diff --git a/src/imports/controls/universal/universal.pri b/src/imports/controls/universal/universal.pri
index 4440acbf..8f1b905c 100644
--- a/src/imports/controls/universal/universal.pri
+++ b/src/imports/controls/universal/universal.pri
@@ -13,6 +13,7 @@ QML_FILES += \
$$PWD/Drawer.qml \
$$PWD/Frame.qml \
$$PWD/GroupBox.qml \
+ $$PWD/HorizontalHeaderView.qml \
$$PWD/ItemDelegate.qml \
$$PWD/Label.qml \
$$PWD/Menu.qml \
@@ -48,7 +49,8 @@ QML_FILES += \
$$PWD/ToolButton.qml \
$$PWD/ToolSeparator.qml \
$$PWD/ToolTip.qml \
- $$PWD/Tumbler.qml
+ $$PWD/Tumbler.qml \
+ $$PWD/VerticalHeaderView.qml
HEADERS += \
$$PWD/qquickuniversalbusyindicator_p.h \
diff --git a/src/imports/platform/qquickplatformdialog.cpp b/src/imports/platform/qquickplatformdialog.cpp
index fc3c0429..2a785bbc 100644
--- a/src/imports/platform/qquickplatformdialog.cpp
+++ b/src/imports/platform/qquickplatformdialog.cpp
@@ -119,7 +119,7 @@ QPlatformDialogHelper *QQuickPlatformDialog::handle() const
*/
QQmlListProperty<QObject> QQuickPlatformDialog::data()
{
- return QQmlListProperty<QObject>(this, m_data);
+ return QQmlListProperty<QObject>(this, &m_data);
}
/*!
diff --git a/src/imports/platform/qquickplatformfiledialog.cpp b/src/imports/platform/qquickplatformfiledialog.cpp
index 6f212bef..4c8a0192 100644
--- a/src/imports/platform/qquickplatformfiledialog.cpp
+++ b/src/imports/platform/qquickplatformfiledialog.cpp
@@ -303,7 +303,7 @@ void QQuickPlatformFileDialog::setOptions(QFileDialogOptions::FileDialogOptions
void QQuickPlatformFileDialog::resetOptions()
{
- setOptions(0);
+ setOptions({});
}
/*!
diff --git a/src/imports/platform/qquickplatformfolderdialog.cpp b/src/imports/platform/qquickplatformfolderdialog.cpp
index b9ea0184..4ae6341e 100644
--- a/src/imports/platform/qquickplatformfolderdialog.cpp
+++ b/src/imports/platform/qquickplatformfolderdialog.cpp
@@ -186,7 +186,7 @@ void QQuickPlatformFolderDialog::setOptions(QFileDialogOptions::FileDialogOption
void QQuickPlatformFolderDialog::resetOptions()
{
- setOptions(0);
+ setOptions({});
}
/*!
diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp
index e84db606..3b085c56 100644
--- a/src/imports/templates/qtquicktemplates2plugin.cpp
+++ b/src/imports/templates/qtquicktemplates2plugin.cpp
@@ -56,6 +56,7 @@
#include <QtQuickTemplates2/private/qquickdrawer_p.h>
#include <QtQuickTemplates2/private/qquickframe_p.h>
#include <QtQuickTemplates2/private/qquickgroupbox_p.h>
+#include <QtQuickTemplates2/private/qquickheaderview_p.h>
#include <QtQuickTemplates2/private/qquickicon_p.h>
#include <QtQuickTemplates2/private/qquickitemdelegate_p.h>
#include <QtQuickTemplates2/private/qquicklabel_p.h>
@@ -358,6 +359,13 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri)
// QtQuick.Templates 2.14 (new types and revisions in Qt 5.14)
qmlRegisterType<QQuickComboBox, 14>(uri, 2, 14, "ComboBox");
+
+ // QtQuick.Templates 2.15 (new types and revisions in Qt 5.15)
+ qmlRegisterType<QQuickComboBox, 15>(uri, 2, 15, "ComboBox");
+ // Register QQuickTableView here to expose headerView's base, with a irregular type name to 'hide' it.
+ qmlRegisterType<QQuickTableView, 15>(uri, 2, 15, "__TableView__");
+ qmlRegisterType<QQuickHorizontalHeaderView>(uri, 2, 15, "HorizontalHeaderView");
+ qmlRegisterType<QQuickVerticalHeaderView>(uri, 2, 15, "VerticalHeaderView");
}
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 5520e074..8632e14c 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -44,7 +44,9 @@
#include <QtGui/qstylehints.h>
#include <QtGui/qguiapplication.h>
-#include <QtGui/private/qshortcutmap_p.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/private/qshortcutmap_p.h>
+#endif
#include <QtGui/private/qguiapplication_p.h>
#include <QtQuick/private/qquickevents_p_p.h>
#include <QtQml/qqmllist.h>
@@ -713,7 +715,7 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator)
const qreal oldImplicitIndicatorHeight = implicitIndicatorHeight();
d->removeImplicitSizeListener(d->indicator);
- delete d->indicator;
+ QQuickControlPrivate::hideOldItem(d->indicator);
d->indicator = indicator;
if (indicator) {
@@ -1018,8 +1020,8 @@ void QQuickAbstractButton::componentComplete()
bool QQuickAbstractButton::event(QEvent *event)
{
- Q_D(QQuickAbstractButton);
#if QT_CONFIG(shortcut)
+ Q_D(QQuickAbstractButton);
if (event->type() == QEvent::Shortcut) {
QShortcutEvent *se = static_cast<QShortcutEvent *>(event);
if (se->shortcutId() == d->shortcutId) {
@@ -1106,9 +1108,9 @@ void QQuickAbstractButton::timerEvent(QTimerEvent *event)
void QQuickAbstractButton::itemChange(ItemChange change, const ItemChangeData &value)
{
- Q_D(QQuickAbstractButton);
QQuickControl::itemChange(change, value);
#if QT_CONFIG(shortcut)
+ Q_D(QQuickAbstractButton);
if (change == ItemVisibleHasChanged) {
if (value.boolValue)
d->grabShortcut();
diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h
index e079836d..9291c1a8 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -50,7 +50,9 @@
#include <QtQuickTemplates2/private/qquickabstractbutton_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
-#include <QtGui/qkeysequence.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/qkeysequence.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp
index 6cb63238..0b083339 100644
--- a/src/quicktemplates2/qquickaction.cpp
+++ b/src/quicktemplates2/qquickaction.cpp
@@ -40,7 +40,9 @@
#include "qquickshortcutcontext_p_p.h"
#include <QtGui/qevent.h>
-#include <QtGui/private/qshortcutmap_p.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/private/qshortcutmap_p.h>
+#endif
#include <QtGui/private/qguiapplication_p.h>
#include <QtQuick/private/qquickitem_p.h>
@@ -261,6 +263,8 @@ void QQuickActionPrivate::unregisterItem(QQuickItem *item)
delete entry;
updateDefaultShortcutEntry();
+#else
+ Q_UNUSED(item);
#endif
}
@@ -277,6 +281,8 @@ void QQuickActionPrivate::itemVisibilityChanged(QQuickItem *item)
entry->ungrab();
updateDefaultShortcutEntry();
+#else
+ Q_UNUSED(item);
#endif
}
@@ -332,8 +338,8 @@ void QQuickActionPrivate::updateDefaultShortcutEntry()
QQuickAction::QQuickAction(QObject *parent)
: QObject(*(new QQuickActionPrivate), parent)
{
- Q_D(QQuickAction);
#if QT_CONFIG(shortcut)
+ Q_D(QQuickAction);
d->defaultShortcutEntry = new QQuickActionPrivate::ShortcutEntry(this);
#endif
}
@@ -554,8 +560,8 @@ void QQuickActionPrivate::trigger(QObject* source, bool doToggle)
bool QQuickAction::event(QEvent *event)
{
- Q_D(QQuickAction);
#if QT_CONFIG(shortcut)
+ Q_D(QQuickAction);
if (event->type() == QEvent::Shortcut)
return d->handleShortcutEvent(this, static_cast<QShortcutEvent *>(event));
#endif
@@ -564,10 +570,13 @@ bool QQuickAction::event(QEvent *event)
bool QQuickAction::eventFilter(QObject *object, QEvent *event)
{
- Q_D(QQuickAction);
#if QT_CONFIG(shortcut)
+ Q_D(QQuickAction);
if (event->type() == QEvent::Shortcut)
return d->handleShortcutEvent(object, static_cast<QShortcutEvent *>(event));
+#else
+ Q_UNUSED(object);
+ Q_UNUSED(event);
#endif
return false;
}
diff --git a/src/quicktemplates2/qquickaction_p_p.h b/src/quicktemplates2/qquickaction_p_p.h
index 7c70bab1..252b0075 100644
--- a/src/quicktemplates2/qquickaction_p_p.h
+++ b/src/quicktemplates2/qquickaction_p_p.h
@@ -51,7 +51,9 @@
#include <QtCore/private/qobject_p.h>
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
-#include <QtGui/qkeysequence.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/qkeysequence.h>
+#endif
#include <QtQuick/private/qquickitemchangelistener_p.h>
QT_BEGIN_NAMESPACE
@@ -119,8 +121,8 @@ public:
bool checkable = false;
QString text;
QQuickIcon icon;
- QKeySequence keySequence;
#if QT_CONFIG(shortcut)
+ QKeySequence keySequence;
QVariant vshortcut;
ShortcutEntry *defaultShortcutEntry = nullptr;
QVector<ShortcutEntry *> shortcutEntries;
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index 92d19a37..903de676 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -407,7 +407,7 @@ void QQuickApplicationWindow::setBackground(QQuickItem *background)
if (!d->background.isExecuting())
d->cancelBackground();
- delete d->background;
+ QQuickControlPrivate::hideOldItem(d->background);
d->background = background;
if (background) {
background->setParentItem(QQuickWindow::contentItem());
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 7833b39b..5f3f1cfc 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -51,6 +51,7 @@
#include <QtQml/qqmlcontext.h>
#include <QtQml/private/qlazilyallocated_p.h>
#include <private/qqmldelegatemodel_p.h>
+#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <QtQuick/private/qquickevents_p_p.h>
#include <QtQuick/private/qquicktextinput_p.h>
#include <QtQuick/private/qquickitemview_p.h>
@@ -232,13 +233,9 @@ public:
void updateEditText();
void updateCurrentText();
void updateCurrentValue();
- void updateCurrentText(bool hasDelegateModelObject);
- void updateCurrentValue(bool hasDelegateModelObject);
void updateCurrentTextAndValue();
bool isValidIndex(int index) const;
- QString fastTextAt(int index) const;
- QVariant fastValueAt(int index) const;
void acceptInput();
QString tryComplete(const QString &inputText);
@@ -268,6 +265,8 @@ public:
void itemImplicitWidthChanged(QQuickItem *item) override;
void itemImplicitHeightChanged(QQuickItem *item) override;
+ static void hideOldPopup(QQuickPopup *popup);
+
bool flat = false;
bool down = false;
bool hasDown = false;
@@ -294,6 +293,7 @@ public:
bool editable = false;
bool accepting = false;
bool allowComplete = false;
+ bool selectTextByMouse = false;
Qt::InputMethodHints inputMethodHints = Qt::ImhNone;
QString editText;
QValidator *validator = nullptr;
@@ -441,34 +441,10 @@ void QQuickComboBoxPrivate::updateEditText()
q->setEditText(text);
}
-// We have these two rather than just using default arguments
-// because QObjectPrivate::connect() doesn't accept lambdas.
void QQuickComboBoxPrivate::updateCurrentText()
{
- updateCurrentText(false);
-}
-
-void QQuickComboBoxPrivate::updateCurrentValue()
-{
- updateCurrentValue(false);
-}
-
-void QQuickComboBoxPrivate::updateCurrentText(bool hasDelegateModelObject)
-{
Q_Q(QQuickComboBox);
- QString text;
- // If a delegate model object was passed in, it means the calling code
- // has decided to reuse it for several function calls to speed things up.
- // So, use the faster (private) version in that case.
- // For other cases, we use the version that creates the delegate model object
- // itself in order to have neater, more convenient calling code.
- if (isValidIndex(currentIndex)) {
- if (hasDelegateModelObject)
- text = fastTextAt(currentIndex);
- else
- text = q->textAt(currentIndex);
- }
-
+ const QString text = q->textAt(currentIndex);
if (currentText != text) {
currentText = text;
if (!hasDisplayText)
@@ -483,19 +459,10 @@ void QQuickComboBoxPrivate::updateCurrentText(bool hasDelegateModelObject)
q->setEditText(currentText);
}
-void QQuickComboBoxPrivate::updateCurrentValue(bool hasDelegateModelObject)
+void QQuickComboBoxPrivate::updateCurrentValue()
{
Q_Q(QQuickComboBox);
- QVariant value;
- // If a delegate model object was passed in, it means the calling code
- // has decided to reuse it for several function calls to speed things up.
- // So, use the faster (private) version in that case.
- if (isValidIndex(currentIndex)) {
- if (hasDelegateModelObject)
- value = fastValueAt(currentIndex);
- else
- value = q->valueAt(currentIndex);
- }
+ const QVariant value = q->valueAt(currentIndex);
if (currentValue == value)
return;
@@ -505,15 +472,8 @@ void QQuickComboBoxPrivate::updateCurrentValue(bool hasDelegateModelObject)
void QQuickComboBoxPrivate::updateCurrentTextAndValue()
{
- QObject *object = nullptr;
- // For performance reasons, we reuse the same delegate model object: QTBUG-76029.
- if (isValidIndex(currentIndex))
- object = delegateModel->object(currentIndex);
- const bool hasDelegateModelObject = object != nullptr;
- updateCurrentText(hasDelegateModelObject);
- updateCurrentValue(hasDelegateModelObject);
- if (object)
- delegateModel->release(object);
+ updateCurrentText();
+ updateCurrentValue();
}
bool QQuickComboBoxPrivate::isValidIndex(int index) const
@@ -521,20 +481,6 @@ bool QQuickComboBoxPrivate::isValidIndex(int index) const
return delegateModel && index >= 0 && index < delegateModel->count();
}
-// For performance reasons (QTBUG-76029), both this and valueAt assume that
-// the index is valid and delegateModel->object(index) has been called.
-QString QQuickComboBoxPrivate::fastTextAt(int index) const
-{
- const QString effectiveTextRole = textRole.isEmpty() ? QStringLiteral("modelData") : textRole;
- return delegateModel->stringValue(index, effectiveTextRole);
-}
-
-QVariant QQuickComboBoxPrivate::fastValueAt(int index) const
-{
- const QString effectiveValueRole = valueRole.isEmpty() ? QStringLiteral("modelData") : valueRole;
- return delegateModel->variantValue(index, effectiveValueRole);
-}
-
void QQuickComboBoxPrivate::acceptInput()
{
Q_Q(QQuickComboBox);
@@ -832,6 +778,21 @@ void QQuickComboBoxPrivate::itemImplicitHeightChanged(QQuickItem *item)
emit q->implicitIndicatorHeightChanged();
}
+void QQuickComboBoxPrivate::hideOldPopup(QQuickPopup *popup)
+{
+ if (!popup)
+ return;
+
+ qCDebug(lcItemManagement) << "hiding old popup" << popup;
+
+ popup->setVisible(false);
+ popup->setParentItem(nullptr);
+ // Remove the item from the accessibility tree.
+ QQuickAccessibleAttached *accessible = accessibleAttached(popup);
+ if (accessible)
+ accessible->setIgnored(true);
+}
+
QQuickComboBox::QQuickComboBox(QQuickItem *parent)
: QQuickControl(*(new QQuickComboBoxPrivate), parent)
{
@@ -852,7 +813,7 @@ QQuickComboBox::~QQuickComboBox()
// Disconnect visibleChanged() to avoid a spurious highlightedIndexChanged() signal
// emission during the destruction of the (visible) popup. (QTBUG-57650)
QObjectPrivate::disconnect(d->popup.data(), &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged);
- delete d->popup;
+ QQuickComboBoxPrivate::hideOldPopup(d->popup);
d->popup = nullptr;
}
}
@@ -1194,7 +1155,7 @@ void QQuickComboBox::setIndicator(QQuickItem *indicator)
const qreal oldImplicitIndicatorHeight = implicitIndicatorHeight();
d->removeImplicitSizeListener(d->indicator);
- delete d->indicator;
+ QQuickControlPrivate::hideOldItem(d->indicator);
d->indicator = indicator;
if (indicator) {
if (!indicator->parentItem())
@@ -1242,7 +1203,7 @@ void QQuickComboBox::setPopup(QQuickPopup *popup)
if (d->popup) {
QObjectPrivate::disconnect(d->popup.data(), &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged);
- delete d->popup;
+ QQuickComboBoxPrivate::hideOldPopup(d->popup);
}
if (popup) {
QQuickPopupPrivate::get(popup)->allowVerticalFlip = true;
@@ -1583,13 +1544,8 @@ QVariant QQuickComboBox::valueAt(int index) const
if (!d->isValidIndex(index))
return QVariant();
- QObject *object = d->delegateModel->object(index);
- QVariant value;
- if (object) {
- value = d->fastValueAt(index);
- d->delegateModel->release(object);
- }
- return value;
+ const QString effectiveValueRole = d->valueRole.isEmpty() ? QStringLiteral("modelData") : d->valueRole;
+ return d->delegateModel->variantValue(index, effectiveValueRole);
}
/*!
@@ -1613,6 +1569,30 @@ int QQuickComboBox::indexOfValue(const QVariant &value) const
}
/*!
+ \since QtQuick.Controls 2.15 (Qt 5.15)
+ \qmlproperty bool QtQuick.Controls::ComboBox::selectTextByMouse
+
+ This property holds whether the text field for an editable ComboBox
+ can be selected with the mouse.
+
+ The default value is \c false.
+*/
+bool QQuickComboBox::selectTextByMouse() const
+{
+ Q_D(const QQuickComboBox);
+ return d->extra.isAllocated() ? d->extra->selectTextByMouse : false;
+}
+
+void QQuickComboBox::setSelectTextByMouse(bool canSelect)
+{
+ Q_D(QQuickComboBox);
+ if (canSelect == selectTextByMouse())
+ return;
+
+ d->extra.value().selectTextByMouse = canSelect;
+ emit selectTextByMouseChanged();
+}
+/*!
\qmlmethod string QtQuick.Controls::ComboBox::textAt(int index)
Returns the text for the specified \a index, or an empty string
@@ -1626,13 +1606,8 @@ QString QQuickComboBox::textAt(int index) const
if (!d->isValidIndex(index))
return QString();
- QObject *object = d->delegateModel->object(index);
- QString text;
- if (object) {
- text = d->fastTextAt(index);
- d->delegateModel->release(object);
- }
- return text;
+ const QString effectiveTextRole = d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole;
+ return d->delegateModel->stringValue(index, effectiveTextRole);
}
/*!
diff --git a/src/quicktemplates2/qquickcombobox_p.h b/src/quicktemplates2/qquickcombobox_p.h
index c9063d6a..b52d7545 100644
--- a/src/quicktemplates2/qquickcombobox_p.h
+++ b/src/quicktemplates2/qquickcombobox_p.h
@@ -48,10 +48,13 @@
// We mean it.
//
+#include <QtCore/qloggingcategory.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcItemManagement)
+
class QValidator;
class QQuickPopup;
class QQmlInstanceModel;
@@ -89,6 +92,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickComboBox : public QQuickControl
// 2.14 (Qt 5.14)
Q_PROPERTY(QVariant currentValue READ currentValue NOTIFY currentValueChanged FINAL REVISION 14)
Q_PROPERTY(QString valueRole READ valueRole WRITE setValueRole NOTIFY valueRoleChanged FINAL REVISION 14)
+ // 2.15 (Qt 5.15)
+ Q_PROPERTY(bool selectTextByMouse READ selectTextByMouse WRITE setSelectTextByMouse NOTIFY selectTextByMouseChanged FINAL REVISION 15)
public:
explicit QQuickComboBox(QQuickItem *parent = nullptr);
@@ -166,6 +171,10 @@ public:
Q_REVISION(14) Q_INVOKABLE QVariant valueAt(int index) const;
Q_REVISION(14) Q_INVOKABLE int indexOfValue(const QVariant &value) const;
+ // 2.15 (Qt 5.15)
+ bool selectTextByMouse() const;
+ void setSelectTextByMouse(bool canSelect);
+
public Q_SLOTS:
void incrementCurrentIndex();
void decrementCurrentIndex();
@@ -203,6 +212,8 @@ Q_SIGNALS:
// 2.14 (Qt 5.14)
Q_REVISION(14) void valueRoleChanged();
Q_REVISION(14) void currentValueChanged();
+ // 2.15 (Qt 5.15)
+ Q_REVISION(15) void selectTextByMouseChanged();
protected:
bool eventFilter(QObject *object, QEvent *event) override;
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index 19b59e33..f38c2b09 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -219,7 +219,7 @@ void QQuickContainerPrivate::cleanup()
QQuickWindowPrivate::get(window)->clearFocusInScope(contentItem, focusItem, Qt::OtherFocusReason);
q->contentItemChange(nullptr, contentItem);
- delete contentItem;
+ QQuickControlPrivate::hideOldItem(contentItem);
}
QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 838a841d..4eb411c2 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -56,6 +56,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcItemManagement, "qt.quick.controls.control.itemmanagement")
+
/*!
\qmltype Control
\inherits Item
@@ -428,7 +430,7 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify)
contentItem = item;
q->contentItemChange(item, oldContentItem);
- delete oldContentItem;
+ QQuickControlPrivate::hideOldItem(oldContentItem);
if (item) {
connect(contentItem.data(), &QQuickItem::baselineOffsetChanged, this, &QQuickControlPrivate::updateBaselineOffset);
@@ -846,6 +848,22 @@ void QQuickControlPrivate::executeBackground(bool complete)
quickCompleteDeferred(q, backgroundName(), background);
}
+void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+{
+ if (!item)
+ return;
+
+ qCDebug(lcItemManagement) << "hiding old item" << item;
+
+ item->setVisible(false);
+ item->setParentItem(nullptr);
+
+ // Remove the item from the accessibility tree.
+ QQuickAccessibleAttached *accessible = accessibleAttached(item);
+ if (accessible)
+ accessible->setIgnored(true);
+}
+
void QQuickControlPrivate::updateBaselineOffset()
{
Q_Q(QQuickControl);
@@ -1598,7 +1616,7 @@ void QQuickControl::setBackground(QQuickItem *background)
}
d->removeImplicitSizeListener(d->background, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry);
- delete d->background;
+ QQuickControlPrivate::hideOldItem(d->background);
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h
index 1b59f86d..fa06c97f 100644
--- a/src/quicktemplates2/qquickcontrol_p_p.h
+++ b/src/quicktemplates2/qquickcontrol_p_p.h
@@ -60,8 +60,12 @@
#include <QtGui/qaccessible.h>
#endif
+#include <QtCore/qloggingcategory.h>
+
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcItemManagement)
+
class QQuickAccessibleAttached;
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickControlPrivate : public QQuickItemPrivate, public QQuickItemChangeListener
@@ -168,6 +172,8 @@ public:
virtual void cancelBackground();
virtual void executeBackground(bool complete = false);
+ static void hideOldItem(QQuickItem *item);
+
void updateBaselineOffset();
static const ChangeTypes ImplicitSizeChanges;
diff --git a/src/quicktemplates2/qquickdeferredexecute.cpp b/src/quicktemplates2/qquickdeferredexecute.cpp
index 800dcedb..d56131e4 100644
--- a/src/quicktemplates2/qquickdeferredexecute.cpp
+++ b/src/quicktemplates2/qquickdeferredexecute.cpp
@@ -92,11 +92,21 @@ static bool beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &pro
typedef QMultiHash<int, const QV4::CompiledData::Binding *> QV4PropertyBindingHash;
auto it = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.second);
auto last = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.first);
+#if Q_QML_PRIVATE_API_VERSION < 7
while (it != last) {
if (!state->creator->populateDeferredBinding(property, deferData, *it))
state->errors << state->creator->errors;
++it;
}
+#else
+ state->creator->beginPopulateDeferred(deferData->context);
+ while (it != last) {
+ state->creator->populateDeferredBinding(property, deferData->deferredIdx, *it);
+ ++it;
+ }
+ state->creator->finalizePopulateDeferred();
+ state->errors << state->creator->errors;
+#endif
deferredState->constructionStates += state;
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp
index b07628ff..99bd0e98 100644
--- a/src/quicktemplates2/qquickdial.cpp
+++ b/src/quicktemplates2/qquickdial.cpp
@@ -620,7 +620,7 @@ void QQuickDial::setHandle(QQuickItem *handle)
if (!d->handle.isExecuting())
d->cancelHandle();
- delete d->handle;
+ QQuickControlPrivate::hideOldItem(d->handle);
d->handle = handle;
if (d->handle && !d->handle->parentItem())
d->handle->setParentItem(this);
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index d448aeed..f3dd2da1 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -545,7 +545,7 @@ void QQuickDialogButtonBox::setAlignment(Qt::Alignment alignment)
void QQuickDialogButtonBox::resetAlignment()
{
- setAlignment(0);
+ setAlignment({});
}
/*!
diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
index 6f9c9033..22da9e6d 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
+++ b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h
@@ -80,7 +80,7 @@ public:
void updateLanguage();
- Qt::Alignment alignment = 0;
+ Qt::Alignment alignment;
QQuickDialogButtonBox::Position position = QQuickDialogButtonBox::Footer;
QPlatformDialogHelper::StandardButtons standardButtons = QPlatformDialogHelper::NoButton;
QPlatformDialogHelper::ButtonLayout buttonLayout = QPlatformDialogHelper::UnknownLayout;
diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp
index 3dbf3174..70ec30dc 100644
--- a/src/quicktemplates2/qquickgroupbox.cpp
+++ b/src/quicktemplates2/qquickgroupbox.cpp
@@ -199,7 +199,7 @@ void QQuickGroupBox::setLabel(QQuickItem *label)
const qreal oldImplicitLabelHeight = implicitLabelHeight();
d->removeImplicitSizeListener(d->label);
- delete d->label;
+ QQuickControlPrivate::hideOldItem(d->label);
d->label = label;
if (label) {
diff --git a/src/quicktemplates2/qquickheaderview.cpp b/src/quicktemplates2/qquickheaderview.cpp
new file mode 100644
index 00000000..49463944
--- /dev/null
+++ b/src/quicktemplates2/qquickheaderview.cpp
@@ -0,0 +1,500 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQuickTemplates2/private/qquickheaderview_p_p.h>
+#include <algorithm>
+
+/*!
+ \qmltype HorizontalHeaderView
+ \inqmlmodule QtQuick.Controls
+ \ingroup qtquickcontrols2-containers
+ \inherits TableView
+ \brief Provides a horizontal header view to accompany a \l TableView.
+
+ A HorizontalHeaderView provides labeling of the columns of a \l TableView.
+ To add a horizontal header to a TableView, bind the
+ \l {HorizontalHeaderView::syncView} {syncView} property to the TableView:
+
+ \snippet qtquickcontrols2-headerview-simple.qml horizontal
+
+ The header displays data from the {syncView}'s model by default, but can
+ also have its own model. If the model is a QAbstractTableModel, then
+ the header will display the model's horizontal headerData(); otherwise,
+ the model's data().
+*/
+
+/*!
+ \qmltype VerticalHeaderView
+ \inqmlmodule QtQuick.Controls
+ \ingroup qtquickcontrols2-containers
+ \inherits TableView
+ \brief Provides a vertical header view to accompany a \l TableView.
+
+ A VerticalHeaderView provides labeling of the rows of a \l TableView.
+ To add a vertical header to a TableView, bind the
+ \l {VerticalHeaderView::syncView} {syncView} property to the TableView:
+
+ \snippet qtquickcontrols2-headerview-simple.qml vertical
+
+ The header displays data from the {syncView}'s model by default, but can
+ also have its own model. If the model is a QAbstractTableModel, then
+ the header will display the model's vertical headerData(); otherwise,
+ the model's data().
+*/
+
+/*!
+ \qmlproperty TableView QtQuick::HorizontalHeaderView::syncView
+
+ This property holds the TableView to synchronize with.
+
+ Once this property is bound to another TableView, both header and table
+ will synchronize with regard to column widths, column spacing, and flicking
+ horizontally.
+
+ If the \l model is not explicitly set, then the header will use the syncView's
+ model to label the columns.
+
+ \sa model TableView
+*/
+
+/*!
+ \qmlproperty TableView QtQuick::VerticalHeaderView::syncView
+
+ This property holds the TableView to synchronize with.
+
+ Once this property is bound to another TableView, both header and table
+ will synchronize with regard to row heights, row spacing, and flicking
+ vertically.
+
+ If the \l model is not explicitly set, then the header will use the syncView's
+ model to label the rows.
+
+ \sa model TableView
+*/
+
+/*!
+ \qmlproperty QVariant QtQuick::HorizontalHeaderView::model
+
+ This property holds the model providing data for the horizontal header view.
+
+ When model is not explicitly set, the header will use the syncView's
+ model once syncView is set.
+
+ If model is a QAbstractTableModel, its horizontal headerData() will
+ be accessed.
+
+ If model is a QAbstractItemModel other than QAbstractTableModel, model's data()
+ will be accessed.
+
+ Otherwise, the behavior is same as setting TableView::model.
+
+ \sa TableView {TableView::model} {model} QAbstractTableModel
+*/
+
+/*!
+ \qmlproperty QVariant QtQuick::VerticalHeaderView::model
+
+ This property holds the model providing data for the vertical header view.
+
+ When model is not explicitly set, it will be synchronized with syncView's model
+ once syncView is set.
+
+ If model is a QAbstractTableModel, its vertical headerData() will
+ be accessed.
+
+ If model is a QAbstractItemModel other than QAbstractTableModel, model's data()
+ will be accessed.
+
+ Otherwise, the behavior is same as setting TableView::model.
+
+ \sa TableView {TableView::model} {model} QAbstractTableModel
+*/
+
+/*!
+ \qmlproperty QString QtQuick::HorizontalHeaderView::textRole
+
+ This property holds the model role used to display text in each header cell.
+
+ The default value is the \c "display" role.
+
+ \sa QAbstractItemModel::roleNames()
+*/
+
+/*!
+ \qmlproperty QString QtQuick::VerticalHeaderView::textRole
+
+ This property holds the model role used to display text in each header cell.
+
+ The default value is the \c "display" role.
+
+ \sa QAbstractItemModel::roleNames()
+*/
+
+QT_BEGIN_NAMESPACE
+
+QQuickHeaderViewBasePrivate::QQuickHeaderViewBasePrivate()
+ : QQuickTableViewPrivate()
+{
+}
+
+QQuickHeaderViewBasePrivate::~QQuickHeaderViewBasePrivate()
+{
+}
+
+const QPointer<QQuickItem> QQuickHeaderViewBasePrivate::delegateItemAt(int row, int col) const
+{
+ return loadedTableItem(QPoint(col, row))->item;
+}
+
+QVariant QQuickHeaderViewBasePrivate::modelImpl() const
+{
+ if (auto model = m_headerDataProxyModel.sourceModel())
+ return QVariant::fromValue(model.data());
+ if (auto model = m_transposeProxyModel.sourceModel())
+ return QVariant::fromValue(model);
+ return QQuickTableViewPrivate::modelImpl();
+}
+
+template <typename P, typename M>
+inline bool proxyModelSetter(QQuickHeaderViewBase *const q, P &proxyModel, M *model)
+{
+ if (model) {
+ if (model == proxyModel.sourceModel())
+ return true;
+ proxyModel.setSourceModel(model);
+ const auto &modelVariant = QVariant::fromValue(std::addressof(proxyModel));
+ bool isProxyModelChanged = (modelVariant != QQuickTableViewPrivate::get(q)->QQuickTableViewPrivate::modelImpl());
+ QQuickTableViewPrivate::get(q)->QQuickTableViewPrivate::setModelImpl(modelVariant);
+ //Necessary, since TableView's assigned model not changed, but proxy's source changed
+ if (!isProxyModelChanged)
+ emit q->modelChanged();
+ return true;
+ }
+ proxyModel.setSourceModel(nullptr);
+ return false;
+}
+
+void QQuickHeaderViewBasePrivate::setModelImpl(const QVariant &newModel)
+{
+ Q_Q(QQuickHeaderViewBase);
+ m_modelExplicitlySetByUser = true;
+ // Case 1: newModel is QAbstractTableModel
+ if (proxyModelSetter(q, m_headerDataProxyModel, newModel.value<QAbstractTableModel *>()))
+ return;
+ // Case 2: newModel is QAbstractItemModel but not QAbstractTableModel
+ if (orientation() == Qt::Horizontal
+ && proxyModelSetter(q, m_transposeProxyModel, newModel.value<QAbstractItemModel *>()))
+ return;
+
+ QQuickTableViewPrivate::setModelImpl(newModel);
+}
+
+void QQuickHeaderViewBasePrivate::syncModel()
+{
+ Q_Q(QQuickHeaderViewBase);
+ if (assignedSyncView && !m_modelExplicitlySetByUser) {
+ auto newModel = assignedSyncView->model();
+ if (auto m = newModel.value<QAbstractTableModel *>()) {
+ proxyModelSetter(q, m_headerDataProxyModel, m);
+ } else if (orientation() == Qt::Horizontal) {
+ if (auto m = newModel.value<QAbstractItemModel *>())
+ proxyModelSetter(q, m_transposeProxyModel, m);
+ } else {
+ QQuickTableViewPrivate::setModelImpl(newModel);
+ }
+ }
+
+ QQuickTableViewPrivate::syncModel();
+}
+
+void QQuickHeaderViewBasePrivate::syncSyncView()
+{
+ Q_Q(QQuickHeaderViewBase);
+ if (assignedSyncDirection != orientation()) {
+ qmlWarning(q_func()) << "Setting syncDirection other than Qt::"
+ << QVariant::fromValue(orientation()).toString()
+ << " is invalid.";
+ assignedSyncDirection = orientation();
+ }
+ if (assignedSyncView) {
+ QBoolBlocker fixupGuard(inUpdateContentSize, true);
+ if (orientation() == Qt::Horizontal) {
+ q->setLeftMargin(assignedSyncView->leftMargin());
+ q->setRightMargin(assignedSyncView->rightMargin());
+ } else {
+ q->setTopMargin(assignedSyncView->topMargin());
+ q->setBottomMargin(assignedSyncView->bottomMargin());
+ }
+ }
+ QQuickTableViewPrivate::syncSyncView();
+}
+
+QQuickHeaderViewBase::QQuickHeaderViewBase(Qt::Orientation orient, QQuickItem *parent)
+ : QQuickTableView(*(new QQuickHeaderViewBasePrivate), parent)
+{
+ d_func()->setOrientation(orient);
+ setSyncDirection(orient);
+}
+
+QQuickHeaderViewBase::QQuickHeaderViewBase(QQuickHeaderViewBasePrivate &dd, QQuickItem *parent)
+ : QQuickTableView(dd, parent)
+{
+}
+
+QQuickHeaderViewBase::~QQuickHeaderViewBase()
+{
+}
+
+QString QQuickHeaderViewBase::textRole() const
+{
+ Q_D(const QQuickHeaderViewBase);
+ return d->m_textRole;
+}
+
+void QQuickHeaderViewBase::setTextRole(const QString &role)
+{
+ Q_D(QQuickHeaderViewBase);
+ if (d->m_textRole == role)
+ return;
+
+ d->m_textRole = role;
+ emit textRoleChanged();
+}
+
+Qt::Orientation QQuickHeaderViewBasePrivate::orientation() const
+{
+ return m_headerDataProxyModel.orientation();
+}
+
+void QQuickHeaderViewBasePrivate::setOrientation(Qt::Orientation orientation)
+{
+ if (QQuickHeaderViewBasePrivate::orientation() == orientation)
+ return;
+ m_headerDataProxyModel.setOrientation(orientation);
+}
+
+QQuickVerticalHeaderView::QQuickVerticalHeaderView(QQuickVerticalHeaderViewPrivate &dd, QQuickItem *parent)
+ : QQuickHeaderViewBase(dd, parent)
+{
+}
+
+/*! \internal
+ \class QHeaderDataProxyModel
+ \brief
+ QHeaderDataProxyModel is a proxy AbstractItemModel type that maps
+ source model's headerData() to correspondent data()
+ */
+QHeaderDataProxyModel::QHeaderDataProxyModel(QObject *parent)
+ : QAbstractItemModel(parent)
+{
+}
+
+QHeaderDataProxyModel::~QHeaderDataProxyModel() = default;
+
+void QHeaderDataProxyModel::setSourceModel(QAbstractItemModel *newSourceModel)
+{
+ if (m_model == newSourceModel)
+ return;
+ beginResetModel();
+ disconnectFromModel();
+ m_model = newSourceModel;
+ connectToModel();
+ endResetModel();
+}
+
+QModelIndex QHeaderDataProxyModel::index(int row, int column, const QModelIndex &parent) const
+{
+ return hasIndex(row, column, parent) ? createIndex(row, column) : QModelIndex();
+}
+
+QModelIndex QHeaderDataProxyModel::parent(const QModelIndex &child) const
+{
+ Q_UNUSED(child)
+ return QModelIndex();
+}
+
+QModelIndex QHeaderDataProxyModel::sibling(int row, int column, const QModelIndex &idx) const
+{
+ return index(row, column, idx);
+}
+
+int QHeaderDataProxyModel::rowCount(const QModelIndex &parent) const
+{
+ return m_model.isNull() ? -1 : (m_orientation == Qt::Horizontal ? 1 : m_model->rowCount(parent));
+}
+
+int QHeaderDataProxyModel::columnCount(const QModelIndex &parent) const
+{
+ return m_model.isNull() ? -1 : (m_orientation == Qt::Vertical ? 1 : m_model->columnCount(parent));
+}
+
+QVariant QHeaderDataProxyModel::data(const QModelIndex &index, int role) const
+{
+ if (m_model.isNull())
+ return QVariant();
+ if (!hasIndex(index.row(), index.column()))
+ return QModelIndex();
+ auto section = m_orientation == Qt::Vertical ? index.row() : index.column();
+ return m_model->headerData(section, m_orientation, role);
+}
+
+bool QHeaderDataProxyModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!hasIndex(index.row(), index.column()))
+ return false;
+ auto section = m_orientation == Qt::Vertical ? index.row() : index.column();
+ auto ret = m_model->setHeaderData(section, m_orientation, value, role);
+ emit dataChanged(index, index, { role });
+ return ret;
+}
+
+bool QHeaderDataProxyModel::hasChildren(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return false;
+}
+
+QVariant QHeaderDataProxyModel::variantValue() const
+{
+ return QVariant::fromValue(static_cast<QObject *>(const_cast<QHeaderDataProxyModel *>(this)));
+}
+
+void QHeaderDataProxyModel::setOrientation(Qt::Orientation o)
+{
+ if (o == m_orientation)
+ return;
+ beginResetModel();
+ m_orientation = o;
+ endResetModel();
+}
+
+Qt::Orientation QHeaderDataProxyModel::orientation() const
+{
+ return m_orientation;
+}
+
+QPointer<QAbstractItemModel> QHeaderDataProxyModel::sourceModel() const
+{
+ return m_model;
+}
+
+void QHeaderDataProxyModel::connectToModel()
+{
+ if (m_model.isNull())
+ return;
+ connect(m_model, &QAbstractItemModel::headerDataChanged,
+ [this](Qt::Orientation orient, int first, int last) {
+ if (orient != orientation())
+ return;
+ if (orient == Qt::Horizontal) {
+ emit dataChanged(createIndex(0, first), createIndex(0, last));
+ } else {
+ emit dataChanged(createIndex(first, 0), createIndex(last, 0));
+ }
+ });
+ connect(m_model, &QAbstractItemModel::modelAboutToBeReset,
+ this, &QHeaderDataProxyModel::modelAboutToBeReset, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::modelReset,
+ this, &QHeaderDataProxyModel::modelReset, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::rowsAboutToBeMoved,
+ this, &QHeaderDataProxyModel::rowsAboutToBeMoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::rowsMoved,
+ this, &QHeaderDataProxyModel::rowsMoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::rowsAboutToBeInserted,
+ this, &QHeaderDataProxyModel::rowsAboutToBeInserted, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::rowsInserted,
+ this, &QHeaderDataProxyModel::rowsInserted, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::rowsAboutToBeRemoved,
+ this, &QHeaderDataProxyModel::rowsAboutToBeRemoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::rowsRemoved,
+ this, &QHeaderDataProxyModel::rowsRemoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::columnsAboutToBeMoved,
+ this, &QHeaderDataProxyModel::columnsAboutToBeMoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::columnsMoved,
+ this, &QHeaderDataProxyModel::columnsMoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::columnsAboutToBeInserted,
+ this, &QHeaderDataProxyModel::columnsAboutToBeInserted, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::columnsInserted,
+ this, &QHeaderDataProxyModel::columnsInserted, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::columnsAboutToBeRemoved,
+ this, &QHeaderDataProxyModel::columnsAboutToBeRemoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::columnsRemoved,
+ this, &QHeaderDataProxyModel::columnsRemoved, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::layoutAboutToBeChanged,
+ this, &QHeaderDataProxyModel::layoutAboutToBeChanged, Qt::UniqueConnection);
+ connect(m_model, &QAbstractItemModel::layoutChanged,
+ this, &QHeaderDataProxyModel::layoutChanged, Qt::UniqueConnection);
+}
+
+void QHeaderDataProxyModel::disconnectFromModel()
+{
+ if (m_model.isNull())
+ return;
+ m_model->disconnect(this);
+}
+
+QQuickHorizontalHeaderView::QQuickHorizontalHeaderView(QQuickItem *parent)
+ : QQuickHeaderViewBase(Qt::Horizontal, parent)
+{
+ setFlickableDirection(FlickableDirection::HorizontalFlick);
+}
+
+QQuickHorizontalHeaderView::~QQuickHorizontalHeaderView()
+{
+}
+
+QQuickVerticalHeaderView::QQuickVerticalHeaderView(QQuickItem *parent)
+ : QQuickHeaderViewBase(Qt::Vertical, parent)
+{
+ setFlickableDirection(FlickableDirection::VerticalFlick);
+}
+
+QQuickVerticalHeaderView::~QQuickVerticalHeaderView()
+{
+}
+
+QQuickHorizontalHeaderViewPrivate::QQuickHorizontalHeaderViewPrivate() = default;
+
+QQuickHorizontalHeaderViewPrivate::~QQuickHorizontalHeaderViewPrivate() = default;
+
+QQuickVerticalHeaderViewPrivate::QQuickVerticalHeaderViewPrivate() = default;
+
+QQuickVerticalHeaderViewPrivate::~QQuickVerticalHeaderViewPrivate() = default;
+
+QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickheaderview_p.h b/src/quicktemplates2/qquickheaderview_p.h
new file mode 100644
index 00000000..10c55c6e
--- /dev/null
+++ b/src/quicktemplates2/qquickheaderview_p.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKHEADERVIEW_P_H
+#define QQUICKHEADERVIEW_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qquicktableview_p.h>
+#include <private/qtquicktemplates2global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickHeaderViewBase;
+class QQuickHeaderViewBasePrivate;
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickHeaderViewBase : public QQuickTableView
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickHeaderViewBase)
+ Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL)
+
+public:
+ explicit QQuickHeaderViewBase(Qt::Orientation orient, QQuickItem *parent = nullptr);
+ ~QQuickHeaderViewBase();
+
+ QString textRole() const;
+ void setTextRole(const QString &role);
+
+protected:
+ QQuickHeaderViewBase(QQuickHeaderViewBasePrivate &dd, QQuickItem *parent);
+
+Q_SIGNALS:
+ void textRoleChanged();
+
+private:
+ Q_DISABLE_COPY(QQuickHeaderViewBase)
+ friend class QQuickHorizontalHeaderView;
+ friend class QQuickVerticalHeaderView;
+};
+
+class QQuickHorizontalHeaderViewPrivate;
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickHorizontalHeaderView : public QQuickHeaderViewBase
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickHorizontalHeaderView)
+
+public:
+ QQuickHorizontalHeaderView(QQuickItem *parent = nullptr);
+ ~QQuickHorizontalHeaderView() override;
+
+protected:
+ QQuickHorizontalHeaderView(QQuickHorizontalHeaderViewPrivate &dd, QQuickItem *parent);
+
+private:
+ Q_DISABLE_COPY(QQuickHorizontalHeaderView)
+};
+
+class QQuickVerticalHeaderViewPrivate;
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickVerticalHeaderView : public QQuickHeaderViewBase
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QQuickVerticalHeaderView)
+
+public:
+ QQuickVerticalHeaderView(QQuickItem *parent = nullptr);
+ ~QQuickVerticalHeaderView() override;
+
+protected:
+ QQuickVerticalHeaderView(QQuickVerticalHeaderViewPrivate &dd, QQuickItem *parent);
+
+private:
+ Q_DISABLE_COPY(QQuickVerticalHeaderView)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickHorizontalHeaderView)
+QML_DECLARE_TYPE(QQuickVerticalHeaderView)
+
+#endif // QQUICKHEADERVIEW_P_H
diff --git a/src/quicktemplates2/qquickheaderview_p_p.h b/src/quicktemplates2/qquickheaderview_p_p.h
new file mode 100644
index 00000000..961c554b
--- /dev/null
+++ b/src/quicktemplates2/qquickheaderview_p_p.h
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKHEADERVIEW_P_P_H
+#define QQUICKHEADERVIEW_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QAbstractItemModel>
+#include <QtCore/QPointer>
+#include <QtCore/QTransposeProxyModel>
+#include <QtQuick/private/qquicktableview_p_p.h>
+#include <private/qquickheaderview_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QHeaderDataProxyModel : public QAbstractItemModel
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QHeaderDataProxyModel)
+ Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel)
+public:
+ explicit QHeaderDataProxyModel(QObject *parent = nullptr);
+ ~QHeaderDataProxyModel();
+
+ void setSourceModel(QAbstractItemModel *newSourceModel);
+ QPointer<QAbstractItemModel> sourceModel() const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
+ QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
+
+ inline QVariant variantValue() const;
+ inline Qt::Orientation orientation() const;
+ inline void setOrientation(Qt::Orientation o);
+
+private:
+ inline void connectToModel();
+ inline void disconnectFromModel();
+ QPointer<QAbstractItemModel> m_model = nullptr;
+ Qt::Orientation m_orientation = Qt::Horizontal;
+};
+
+class QQuickHeaderViewBasePrivate : public QQuickTableViewPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickHeaderViewBase)
+public:
+ QQuickHeaderViewBasePrivate();
+ ~QQuickHeaderViewBasePrivate();
+
+ Qt::Orientation orientation() const;
+ void setOrientation(Qt::Orientation orientation);
+ const QPointer<QQuickItem> delegateItemAt(int row, int col) const;
+ QVariant modelImpl() const override;
+ void setModelImpl(const QVariant &newModel) override;
+ void syncModel() override;
+ void syncSyncView() override;
+
+protected:
+ QHeaderDataProxyModel m_headerDataProxyModel;
+ QTransposeProxyModel m_transposeProxyModel;
+ struct SectionSize
+ {
+ int section;
+ qreal previousSize;
+ };
+ QStack<SectionSize> m_hiddenSectionSizes;
+ bool m_modelExplicitlySetByUser = false;
+ QString m_textRole = QStringLiteral("display");
+};
+
+class QQuickHorizontalHeaderViewPrivate : public QQuickHeaderViewBasePrivate
+{
+ Q_DECLARE_PUBLIC(QQuickHorizontalHeaderView)
+public:
+ QQuickHorizontalHeaderViewPrivate();
+ ~QQuickHorizontalHeaderViewPrivate();
+};
+
+class QQuickVerticalHeaderViewPrivate : public QQuickHeaderViewBasePrivate
+{
+ Q_DECLARE_PUBLIC(QQuickVerticalHeaderView)
+public:
+ QQuickVerticalHeaderViewPrivate();
+ ~QQuickVerticalHeaderViewPrivate();
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKHEADERVIEW_P_P_H
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
index 9937436c..71b60a2b 100644
--- a/src/quicktemplates2/qquicklabel.cpp
+++ b/src/quicktemplates2/qquicklabel.cpp
@@ -405,7 +405,7 @@ void QQuickLabel::setBackground(QQuickItem *background)
}
QQuickControlPrivate::removeImplicitSizeListener(d->background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry);
- delete d->background;
+ QQuickControlPrivate::hideOldItem(d->background);
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp
index 0fbfb90b..ec1ea621 100644
--- a/src/quicktemplates2/qquickmenuitem.cpp
+++ b/src/quicktemplates2/qquickmenuitem.cpp
@@ -216,7 +216,7 @@ void QQuickMenuItem::setArrow(QQuickItem *arrow)
if (!d->arrow.isExecuting())
d->cancelArrow();
- delete d->arrow;
+ QQuickControlPrivate::hideOldItem(d->arrow);
d->arrow = arrow;
if (arrow && !arrow->parentItem())
arrow->setParentItem(this);
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index ea72072b..e9f8801d 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -34,10 +34,12 @@
**
****************************************************************************/
+#include "qquickcontrol_p_p.h"
#include "qquickoverlay_p.h"
#include "qquickoverlay_p_p.h"
#include "qquickpopupitem_p_p.h"
#include "qquickpopup_p_p.h"
+#include "qquickdrawer_p.h"
#include "qquickdrawer_p_p.h"
#include "qquickapplicationwindow_p.h"
#include <QtQml/qqmlinfo.h>
@@ -255,7 +257,7 @@ void QQuickOverlayPrivate::removePopup(QQuickPopup *popup)
{
Q_Q(QQuickOverlay);
allPopups.removeOne(popup);
- if (allDrawers.removeOne(static_cast<QQuickDrawer *>(popup)))
+ if (allDrawers.removeOne(qobject_cast<QQuickDrawer *>(popup)))
q->setVisible(!allDrawers.isEmpty() || !q->childItems().isEmpty());
}
@@ -341,7 +343,6 @@ void QQuickOverlay::setModal(QQmlComponent *modal)
if (d->modal == modal)
return;
- delete d->modal;
d->modal = modal;
emit modalChanged();
}
@@ -358,7 +359,6 @@ void QQuickOverlay::setModeless(QQmlComponent *modeless)
if (d->modeless == modeless)
return;
- delete d->modeless;
d->modeless = modeless;
emit modelessChanged();
}
@@ -670,7 +670,6 @@ void QQuickOverlayAttached::setModal(QQmlComponent *modal)
if (d->modal == modal)
return;
- delete d->modal;
d->modal = modal;
emit modalChanged();
}
@@ -703,7 +702,6 @@ void QQuickOverlayAttached::setModeless(QQmlComponent *modeless)
if (d->modeless == modeless)
return;
- delete d->modeless;
d->modeless = modeless;
emit modelessChanged();
}
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index ecb2568e..7a7e00b1 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -1843,6 +1843,8 @@ void QQuickPopup::setModal(bool modal)
d->toggleOverlay();
emit modalChanged();
+ QQuickItemPrivate::get(d->popupItem)->isTabFence = modal;
+
if (!d->hasDim) {
setDim(modal);
d->hasDim = false;
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index fcf23db5..8e169b0b 100644
--- a/src/quicktemplates2/qquickpopupitem.cpp
+++ b/src/quicktemplates2/qquickpopupitem.cpp
@@ -42,7 +42,9 @@
#include "qquickpopup_p_p.h"
#include "qquickdeferredexecute_p_p.h"
-#include <QtGui/private/qshortcutmap_p.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/private/qshortcutmap_p.h>
+#endif
#include <QtGui/private/qguiapplication_p.h>
#if QT_CONFIG(accessibility)
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index bd53963d..9ad12102 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -267,7 +267,7 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle)
const qreal oldImplicitHandleHeight = implicitHandleHeight();
QQuickControlPrivate::get(d->slider)->removeImplicitSizeListener(d->handle);
- delete d->handle;
+ QQuickControlPrivate::hideOldItem(d->handle);
d->handle = handle;
if (handle) {
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index 1fb674b6..f4a459fa 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -579,7 +579,7 @@ void QQuickSlider::setHandle(QQuickItem *handle)
const qreal oldImplicitHandleHeight = implicitHandleHeight();
d->removeImplicitSizeListener(d->handle);
- delete d->handle;
+ QQuickControlPrivate::hideOldItem(d->handle);
d->handle = handle;
if (handle) {
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 8b81e4e5..3482af8c 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -1126,7 +1126,7 @@ void QQuickSpinButton::setIndicator(QQuickItem *indicator)
QQuickSpinBox *spinBox = static_cast<QQuickSpinBox *>(parent());
QQuickSpinBoxPrivate::get(spinBox)->removeImplicitSizeListener(d->indicator);
- delete d->indicator;
+ QQuickControlPrivate::hideOldItem(d->indicator);
d->indicator = indicator;
if (indicator) {
diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp
index 7ae5c495..4c14022a 100644
--- a/src/quicktemplates2/qquickstackelement.cpp
+++ b/src/quicktemplates2/qquickstackelement.cpp
@@ -44,6 +44,7 @@
#include <QtQml/private/qv4qobjectwrapper_p.h>
#include <QtQml/private/qqmlcomponent_p.h>
#include <QtQml/private/qqmlengine_p.h>
+#include <QtQml/private/qqmlapiversion_p.h>
QT_BEGIN_NAMESPACE
@@ -210,7 +211,12 @@ void QQuickStackElement::initialize()
QV4::ScopedValue ipv(scope, properties.value());
QV4::Scoped<QV4::QmlContext> qmlContext(scope, qmlCallingContext.value());
QV4::ScopedValue qmlObject(scope, QV4::QObjectWrapper::wrap(v4, item));
+#if Q_QML_PRIVATE_API_VERSION >= 6
+ RequiredProperties requiredPropertiesCurrentlyNotSupported;
+ QQmlComponentPrivate::setInitialProperties(v4, qmlContext, qmlObject, ipv, requiredPropertiesCurrentlyNotSupported, item);
+#else
QQmlComponentPrivate::setInitialProperties(v4, qmlContext, qmlObject, ipv);
+#endif
properties.clear();
}
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 75dfba4e..56dc946d 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -634,7 +634,7 @@ void QQuickTextArea::setBackground(QQuickItem *background)
}
QQuickControlPrivate::removeImplicitSizeListener(d->background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry);
- delete d->background;
+ QQuickControlPrivate::hideOldItem(d->background);
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 025139f8..8fa04bd3 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -503,7 +503,7 @@ void QQuickTextField::setBackground(QQuickItem *background)
}
QQuickControlPrivate::removeImplicitSizeListener(d->background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry);
- delete d->background;
+ QQuickControlPrivate::hideOldItem(d->background);
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index c145c20f..fa6929f9 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -31,6 +31,8 @@ HEADERS += \
$$PWD/qquickframe_p.h \
$$PWD/qquickframe_p_p.h \
$$PWD/qquickgroupbox_p.h \
+ $$PWD/qquickheaderview_p.h \
+ $$PWD/qquickheaderview_p_p.h \
$$PWD/qquickicon_p.h \
$$PWD/qquickitemdelegate_p.h \
$$PWD/qquickitemdelegate_p_p.h \
@@ -120,6 +122,7 @@ SOURCES += \
$$PWD/qquickdrawer.cpp \
$$PWD/qquickframe.cpp \
$$PWD/qquickgroupbox.cpp \
+ $$PWD/qquickheaderview.cpp \
$$PWD/qquickicon.cpp \
$$PWD/qquickitemdelegate.cpp \
$$PWD/qquicklabel.cpp \
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 8612e2c1..853c84a8 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -14,6 +14,7 @@ SUBDIRS += \
qquickapplicationwindow \
qquickcolor \
qquickdrawer \
+ qquickheaderview \
qquickiconimage \
qquickiconlabel \
qquickimaginestyle \
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 634d70a8..2d5069b3 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -1854,6 +1854,22 @@ TestCase {
compare(closedSpy.count, 1)
}
+ function test_comboBoxSelectTextByMouse() {
+ let control = createTemporaryObject(comboBox, testCase,
+ { editable: true, selectTextByMouse: true, model: [ "Some text" ], width: parent.width })
+ verify(control)
+ waitForRendering(control)
+ control.forceActiveFocus()
+
+ // Position the text cursor at the beginning of the text.
+ mouseClick(control, control.leftPadding, control.height / 2)
+ // Select all of the text.
+ mousePress(control, control.leftPadding, control.height / 2)
+ mouseMove(control, control.leftPadding + control.contentItem.width, control.height / 2)
+ mouseRelease(control, control.leftPadding + control.contentItem.width, control.height / 2)
+ compare(control.contentItem.selectedText, "Some text")
+ }
+
// QTBUG-78885: When the edit text is changed on an editable ComboBox,
// and then that ComboBox loses focus, its currentIndex should change
// to the index of the edit text (assuming a match is found).
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index d3a0d8bb..22dbb352 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -658,4 +658,20 @@ TestCase {
compare(control.displayText, data.displayTexts[i])
}
}
+
+ Component {
+ id: overriddenSpinBox
+ SpinBox {
+ value: 50
+ up.indicator: Rectangle {
+ property string s: "this is the one"
+ }
+ }
+ }
+
+ function test_indicatorOverridden() {
+ var control = createTemporaryObject(overriddenSpinBox, testCase)
+ verify(control)
+ compare(control.up.indicator.s, "this is the one");
+ }
}
diff --git a/tests/auto/customization/data/styles/identified/AbstractButton.qml b/tests/auto/customization/data/styles/identified/AbstractButton.qml
index b9656f7a..cd2b5bdc 100644
--- a/tests/auto/customization/data/styles/identified/AbstractButton.qml
+++ b/tests/auto/customization/data/styles/identified/AbstractButton.qml
@@ -58,15 +58,18 @@ T.AbstractButton {
indicator: Item {
id: indicator
objectName: "abstractbutton-indicator-identified"
+ Accessible.name: objectName
}
contentItem: Item {
id: contentItem
objectName: "abstractbutton-contentItem-identified"
+ Accessible.name: objectName
}
background: Item {
id: background
objectName: "abstractbutton-background-identified"
+ Accessible.name: objectName
}
}
diff --git a/tests/auto/customization/tst_customization.cpp b/tests/auto/customization/tst_customization.cpp
index 41efc2a6..cce74b41 100644
--- a/tests/auto/customization/tst_customization.cpp
+++ b/tests/auto/customization/tst_customization.cpp
@@ -42,6 +42,7 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
#include <QtQuickControls2/qquickstyle.h>
+#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
#include "../shared/visualtestutil.h"
using namespace QQuickVisualTestUtil;
@@ -439,11 +440,36 @@ void tst_customization::override()
QVERIFY2(qt_createdQObjects()->isEmpty(), qPrintable("unexpectedly created: " + qt_createdQObjects->join(", ")));
if (!nonDeferred.isEmpty()) {
- for (QString delegate : qAsConst(delegates)) {
- if (!delegate.contains("-"))
- delegate.append("-" + nonDeferred);
- delegate.prepend(type.toLower() + "-");
- QVERIFY2(qt_destroyedQObjects()->removeOne(delegate), qPrintable(delegate + " was not destroyed as expected"));
+ // There were items for which deferred execution was not possible.
+ for (QString delegateName : qAsConst(delegates)) {
+ if (!delegateName.contains("-"))
+ delegateName.append("-" + nonDeferred);
+ delegateName.prepend(type.toLower() + "-");
+
+ const int delegateIndex = qt_destroyedQObjects()->indexOf(delegateName);
+ QVERIFY2(delegateIndex == -1, qPrintable(delegateName + " was unexpectedly destroyed"));
+
+ const auto controlChildren = control->children();
+ const auto childIt = std::find_if(controlChildren.constBegin(), controlChildren.constEnd(), [delegateName](const QObject *child) {
+ return child->objectName() == delegateName;
+ });
+ // We test other delegates (like the background) here, so make sure we don't end up with XPASSes by using the wrong delegate.
+ if (delegateName.contains(QLatin1String("handle"))) {
+ QEXPECT_FAIL("identified:RangeSlider", "For some reason, items that are belong to grouped properties fail here", Abort);
+ QEXPECT_FAIL("overidentified:RangeSlider", "For some reason, items that are belong to grouped properties fail here", Abort);
+ }
+ if (delegateName.contains(QLatin1String("indicator"))) {
+ QEXPECT_FAIL("identified:SpinBox", "For some reason, items that are belong to grouped properties fail here", Abort);
+ QEXPECT_FAIL("overidentified:SpinBox", "For some reason, items that are belong to grouped properties fail here", Abort);
+ }
+ QVERIFY2(childIt != controlChildren.constEnd(), qPrintable(QString::fromLatin1(
+ "Expected delegate \"%1\" to still be a QObject child of \"%2\"").arg(delegateName).arg(controlName)));
+
+ const auto *delegate = qobject_cast<QQuickItem*>(*childIt);
+ // Ensure that the item is hidden, etc.
+ QVERIFY(delegate);
+ QCOMPARE(delegate->isVisible(), false);
+ QCOMPARE(delegate->parentItem(), nullptr);
}
}
diff --git a/tests/auto/qquickheaderview/data/Window.qml b/tests/auto/qquickheaderview/data/Window.qml
new file mode 100644
index 00000000..3811904e
--- /dev/null
+++ b/tests/auto/qquickheaderview/data/Window.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite 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.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+import TestTableModel 0.1
+import TestTableModelWithHeader 0.1
+import HeaderDataProxyModel 0.1
+
+Window {
+ objectName: "window"
+ width: 400
+ height: 400
+ visible: true
+
+ Component {
+ id: cellDelegate
+ Rectangle {
+ implicitHeight: 25
+ implicitWidth: 50
+ color: "red"
+ Text {
+ text: row + "," + column
+ }
+ }
+ }
+
+ HeaderDataProxyModel {
+ id: pm
+ objectName: "proxyModel"
+ }
+
+ TestTableModel {
+ id: tm
+ objectName: "tableModel"
+ rowCount: 5
+ columnCount: 10
+ }
+
+ TestTableModelWithHeader {
+ id: thm
+ objectName: "tableHeaderModel"
+ rowCount: 5
+ columnCount: 10
+ }
+
+ HorizontalHeaderView {
+ id: hhv
+ objectName: "horizontalHeader"
+ width: 200
+ height: 200
+ model: thm
+ delegate: cellDelegate
+ }
+
+ VerticalHeaderView {
+ id: vhv
+ objectName: "verticalHeader"
+ width: 200
+ height: 200
+ model: thm
+ delegate: cellDelegate
+ }
+
+ TableView {
+ id: tv
+ objectName: "tableView"
+ width: 400
+ height: 400
+ model: thm
+ delegate:cellDelegate
+ }
+}
diff --git a/tests/auto/qquickheaderview/qquickheaderview.pro b/tests/auto/qquickheaderview/qquickheaderview.pro
new file mode 100644
index 00000000..4410c888
--- /dev/null
+++ b/tests/auto/qquickheaderview/qquickheaderview.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickheaderview
+SOURCES += tst_qquickheaderview.cpp
+
+macos:CONFIG -= app_bundle
+
+QT += core-private gui-private qml-private quick-private testlib quickcontrols2 \
+ quickcontrols2-private quicktemplates2-private quicktemplates2
+
+include (../shared/util.pri)
+
+TESTDATA = data/*
+
+OTHER_FILES += \
+ data/*.qml
diff --git a/tests/auto/qquickheaderview/tst_qquickheaderview.cpp b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp
new file mode 100644
index 00000000..5ce5439d
--- /dev/null
+++ b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp
@@ -0,0 +1,354 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../shared/qtest_quickcontrols.h"
+#include "../shared/util.h"
+#include <QtTest/qsignalspy.h>
+#include <QtTest/qtest.h>
+
+#include <QAbstractItemModelTester>
+#include <QtQml/QQmlEngine>
+#include <QtQuick/private/qquickwindow_p.h>
+#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
+#include <QtQuickTemplates2/private/qquickheaderview_p.h>
+#include <private/qquickheaderview_p_p.h>
+
+class TestTableModel : public QAbstractTableModel {
+ Q_OBJECT
+ Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
+ Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
+
+public:
+ TestTableModel(QObject *parent = nullptr)
+ : QAbstractTableModel(parent)
+ {
+ }
+
+ int rowCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return m_rows;
+ }
+ virtual void setRowCount(int count)
+ {
+ beginResetModel();
+ m_rows = count;
+ emit rowCountChanged();
+ endResetModel();
+ }
+
+ int columnCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return m_cols;
+ }
+ virtual void setColumnCount(int count)
+ {
+ beginResetModel();
+ m_cols = count;
+ emit columnCountChanged();
+ endResetModel();
+ }
+
+ int indexValue(const QModelIndex &index) const
+ {
+ return index.row() + (index.column() * rowCount());
+ }
+
+ Q_INVOKABLE QModelIndex toQModelIndex(int serialIndex)
+ {
+ return createIndex(serialIndex % rowCount(), serialIndex / rowCount());
+ }
+
+ Q_INVOKABLE QVariant data(int row, int col)
+ {
+ return data(createIndex(row, col), Qt::DisplayRole);
+ }
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ if (!index.isValid())
+ return QVariant();
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return QString("%1, %2, checked: %3 ")
+ .arg(index.row())
+ .arg(index.column())
+ .arg(m_checkedCells.contains(indexValue(index)));
+ case Qt::EditRole:
+ return m_checkedCells.contains(indexValue(index));
+ default:
+ return QVariant();
+ }
+ }
+
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole) override
+ {
+
+ if (role != Qt::EditRole)
+ return false;
+
+ int i = indexValue(index);
+ bool checked = value.toBool();
+ if (checked == m_checkedCells.contains(i))
+ return false;
+
+ if (checked)
+ m_checkedCells.insert(i);
+ else
+ m_checkedCells.remove(i);
+
+ emit dataChanged(index, index, { role });
+ return true;
+ }
+
+ Q_INVOKABLE QHash<int, QByteArray> roleNames() const override
+ {
+ return {
+ { Qt::DisplayRole, "display" },
+ { Qt::EditRole, "edit" }
+ };
+ }
+
+signals:
+ void rowCountChanged();
+ void columnCountChanged();
+
+private:
+ int m_rows = 0;
+ int m_cols = 0;
+
+ QSet<int> m_checkedCells;
+};
+
+class TestTableModelWithHeader : public TestTableModel {
+
+ Q_OBJECT
+public:
+ void setRowCount(int count) override
+ {
+ vData.resize(count);
+ TestTableModel::setRowCount(count);
+ }
+
+ void setColumnCount(int count) override
+ {
+ hData.resize(count);
+ TestTableModel::setColumnCount(count);
+ }
+ Q_INVOKABLE QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const override
+ {
+ auto sectionCount = orientation == Qt::Horizontal ? columnCount() : rowCount();
+ if (section < 0 || section >= sectionCount)
+ return QVariant();
+ switch (role) {
+ case Qt::DisplayRole:
+ case Qt::EditRole: {
+ auto &data = orientation == Qt::Horizontal ? hData : vData;
+ return data[section].toString();
+ }
+ default:
+ return QVariant();
+ }
+ }
+ Q_INVOKABLE bool setHeaderData(int section, Qt::Orientation orientation,
+ const QVariant &value, int role = Qt::EditRole) override
+ {
+ qDebug() << Q_FUNC_INFO
+ << "section:" << section
+ << "orient:" << orientation
+ << "value:" << value
+ << "role:" << QAbstractItemModel::roleNames()[role];
+ auto sectionCount = orientation == Qt::Horizontal ? columnCount() : rowCount();
+ if (section < 0 || section >= sectionCount)
+ return false;
+ auto &data = orientation == Qt::Horizontal ? hData : vData;
+ data[section] = value;
+ emit headerDataChanged(orientation, section, section);
+ return true;
+ }
+
+private:
+ QVector<QVariant> hData, vData;
+};
+
+class tst_QQuickHeaderView : public QQmlDataTest {
+ Q_OBJECT
+
+private slots:
+ void initTestCase() override;
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void defaults();
+ void testHeaderDataProxyModel();
+ void testOrientation();
+ void testModel();
+
+private:
+ QQmlEngine *engine;
+ QString errorString;
+
+ std::unique_ptr<QObject> rootObjectFromQml(const char *file)
+ {
+ auto component = new QQmlComponent(engine);
+ component->loadUrl(testFileUrl(file));
+ auto root = component->create();
+ if (!root)
+ errorString = component->errorString();
+ return std::unique_ptr<QObject>(new QObject(root));
+ }
+};
+
+void tst_QQuickHeaderView::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<TestTableModel>("TestTableModel", 0, 1, "TestTableModel");
+ qmlRegisterType<TestTableModelWithHeader>("TestTableModelWithHeader", 0, 1, "TestTableModelWithHeader");
+ qmlRegisterType<QHeaderDataProxyModel>("HeaderDataProxyModel", 0, 1, "HeaderDataProxyModel");
+}
+
+void tst_QQuickHeaderView::cleanupTestCase()
+{
+}
+
+void tst_QQuickHeaderView::init()
+{
+ engine = new QQmlEngine(this);
+}
+
+void tst_QQuickHeaderView::cleanup()
+{
+ if (engine) {
+ delete engine;
+ engine = nullptr;
+ }
+}
+
+void tst_QQuickHeaderView::defaults()
+{
+ QQmlComponent component(engine);
+ component.loadUrl(testFileUrl("Window.qml"));
+
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(root, qPrintable(component.errorString()));
+
+ auto hhv = root->findChild<QQuickHorizontalHeaderView *>("horizontalHeader");
+ QVERIFY(hhv);
+ auto vhv = root->findChild<QQuickVerticalHeaderView *>("verticalHeader");
+ QVERIFY(vhv);
+ auto tm = root->findChild<TestTableModel *>("tableModel");
+ QVERIFY(tm);
+ auto pm = root->findChild<QHeaderDataProxyModel *>("proxyModel");
+ QVERIFY(pm);
+ auto tv = root->findChild<QQuickTableView *>("tableView");
+ QVERIFY(tv);
+}
+
+void tst_QQuickHeaderView::testHeaderDataProxyModel()
+{
+ TestTableModel model;
+ model.setColumnCount(10);
+ model.setRowCount(7);
+ QHeaderDataProxyModel model2;
+ model2.setSourceModel(&model);
+ QAbstractItemModelTester tester(&model2, QAbstractItemModelTester::FailureReportingMode::QtTest);
+}
+
+void tst_QQuickHeaderView::testOrientation()
+{
+ QQmlComponent component(engine);
+ component.loadUrl(testFileUrl("Window.qml"));
+
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(root, qPrintable(component.errorString()));
+
+ auto hhv = root->findChild<QQuickHorizontalHeaderView *>("horizontalHeader");
+ QVERIFY(hhv);
+ QCOMPARE(hhv->columns(), 10);
+ QCOMPARE(hhv->rows(), 1);
+ auto vhv = root->findChild<QQuickVerticalHeaderView *>("verticalHeader");
+ QVERIFY(vhv);
+
+ hhv->setSyncDirection(Qt::Vertical);
+ hhv->flick(10, 20);
+
+ vhv->setSyncDirection(Qt::Horizontal);
+ vhv->flick(20, 10);
+
+ QVERIFY(QTest::qWaitForWindowActive(qobject_cast<QWindow *>(root.data())));
+ // Explicitly setting a different synDirection is ignored
+ QCOMPARE(hhv->syncDirection(), Qt::Horizontal);
+ QCOMPARE(hhv->flickableDirection(), QQuickFlickable::HorizontalFlick);
+ QCOMPARE(vhv->syncDirection(), Qt::Vertical);
+ QCOMPARE(vhv->flickableDirection(), QQuickFlickable::VerticalFlick);
+}
+
+void tst_QQuickHeaderView::testModel()
+{
+ QQmlComponent component(engine);
+ component.loadUrl(testFileUrl("Window.qml"));
+
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(root, qPrintable(component.errorString()));
+
+ auto hhv = root->findChild<QQuickHorizontalHeaderView *>("horizontalHeader");
+ QVERIFY(hhv);
+ auto thm = root->findChild<TestTableModel *>("tableHeaderModel");
+ QVERIFY(thm);
+ auto pm = root->findChild<QHeaderDataProxyModel *>("proxyModel");
+ QVERIFY(pm);
+
+ QSignalSpy modelChangedSpy(hhv, SIGNAL(modelChanged()));
+ QVERIFY(modelChangedSpy.isValid());
+
+ hhv->setModel(QVariant::fromValue(thm));
+ QCOMPARE(modelChangedSpy.count(), 0);
+
+ hhv->setModel(QVariant::fromValue(pm));
+ QCOMPARE(modelChangedSpy.count(), 1);
+
+ TestTableModel ttm2;
+ ttm2.setRowCount(100);
+ ttm2.setColumnCount(30);
+ hhv->setModel(QVariant::fromValue(&ttm2));
+ QCOMPARE(modelChangedSpy.count(), 2);
+}
+
+QTEST_MAIN(tst_QQuickHeaderView)
+
+#include "tst_qquickheaderview.moc"
diff --git a/tests/auto/qquickpopup/data/tabFence.qml b/tests/auto/qquickpopup/data/tabFence.qml
new file mode 100644
index 00000000..2cf408e9
--- /dev/null
+++ b/tests/auto/qquickpopup/data/tabFence.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite 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.15
+import QtQuick.Layouts 1.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+
+ApplicationWindow {
+ width: 400
+ height: 400
+ objectName: "Rectangle"
+
+ property alias dialog: dialog
+ property alias outsideButton1: outsideButton1
+ property alias outsideButton2: outsideButton2
+ property alias dialogButton1: dialogButton1
+ property alias dialogButton2: dialogButton2
+
+ ColumnLayout {
+ Button {
+ id: outsideButton1
+ text: "Button1"
+ }
+ Button {
+ id: outsideButton2
+ text: "Button2"
+ }
+ }
+
+ Dialog {
+ id: dialog
+ objectName: "Dialog"
+ width: 200
+ height: 200
+ anchors.centerIn: parent
+ visible: true
+
+ ColumnLayout {
+ Button {
+ id: dialogButton1
+ text: "Button3"
+ }
+ Button {
+ id: dialogButton2
+ text: "Button4"
+ }
+ }
+ }
+}
diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp
index f55d42bc..0b7d14bd 100644
--- a/tests/auto/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp
@@ -93,6 +93,7 @@ private slots:
void countChanged();
void toolTipCrashOnClose();
void setOverlayParentToNull();
+ void tabFence();
void invisibleToolTipOpen();
};
@@ -794,7 +795,9 @@ void tst_QQuickPopup::wheel_data()
static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees)
{
QQuickWindow *window = item->window();
- QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0);
+ QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos),
+ QPoint(0, 0), QPoint(0, 8 * degrees),
+ 0, Qt::Vertical, Qt::NoButton, {});
QSpontaneKeyEvent::setSpontaneous(&wheelEvent);
return qGuiApp->notify(window, &wheelEvent);
}
@@ -1300,6 +1303,62 @@ void tst_QQuickPopup::setOverlayParentToNull()
// While nullifying the overlay parent doesn't make much sense, it shouldn't crash.
}
+void tst_QQuickPopup::tabFence()
+{
+ if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
+ QSKIP("This platform only allows tab focus for text controls");
+
+ QQuickApplicationHelper helper(this, "tabFence.qml");
+
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickPopup *popup = window->property("dialog").value<QQuickPopup*>();
+ QVERIFY(popup);
+ popup->open();
+ popup->setModal(true);
+
+ QQuickButton *outsideButton1 = window->property("outsideButton1").value<QQuickButton*>();
+ QVERIFY(outsideButton1);
+ QQuickButton *outsideButton2 = window->property("outsideButton2").value<QQuickButton*>();
+ QVERIFY(outsideButton2);
+ QQuickButton *dialogButton1 = window->property("dialogButton1").value<QQuickButton*>();
+ QVERIFY(dialogButton1);
+ QQuickButton *dialogButton2 = window->property("dialogButton2").value<QQuickButton*>();
+ QVERIFY(dialogButton2);
+
+ // When modal, focus loops between the two external buttons
+ outsideButton1->forceActiveFocus();
+ QVERIFY(outsideButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton1->hasActiveFocus());
+
+ // Same thing for dialog's buttons
+ dialogButton1->forceActiveFocus();
+ QVERIFY(dialogButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton1->hasActiveFocus());
+
+ popup->setModal(false);
+
+ // When not modal, focus goes in and out of the dialog
+ outsideButton1->forceActiveFocus();
+ QVERIFY(outsideButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton1->hasActiveFocus());
+}
+
void tst_QQuickPopup::invisibleToolTipOpen()
{
QQuickApplicationHelper helper(this, "invisibleToolTipOpen.qml");
diff --git a/tests/manual/headerview/headerview.pro b/tests/manual/headerview/headerview.pro
new file mode 100644
index 00000000..474cc921
--- /dev/null
+++ b/tests/manual/headerview/headerview.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = headerview
+QT += qml quick quick-private quickcontrols2 quickcontrols2-private \
+ quicktemplates2-private quicktemplates2
+SOURCES += main.cpp
+RESOURCES += main.qml
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/tests/manual/headerview/main.cpp b/tests/manual/headerview/main.cpp
new file mode 100644
index 00000000..4c1e611c
--- /dev/null
+++ b/tests/manual/headerview/main.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QAbstractTableModel>
+#include <QDebug>
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+class TestTableModel : public QAbstractTableModel {
+ Q_OBJECT
+ Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount NOTIFY rowCountChanged)
+ Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount NOTIFY columnCountChanged)
+
+public:
+ TestTableModel(QObject *parent = nullptr)
+ : QAbstractTableModel(parent)
+ {
+ }
+
+ int rowCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return m_rows;
+ }
+ virtual void setRowCount(int count)
+ {
+ beginResetModel();
+ m_rows = count;
+ emit rowCountChanged();
+ endResetModel();
+ }
+
+ int columnCount(const QModelIndex & = QModelIndex()) const override
+ {
+ return m_cols;
+ }
+ virtual void setColumnCount(int count)
+ {
+ beginResetModel();
+ m_cols = count;
+ emit columnCountChanged();
+ endResetModel();
+ }
+
+ int indexValue(const QModelIndex &index) const
+ {
+ return index.row() + (index.column() * rowCount());
+ }
+
+ Q_INVOKABLE QModelIndex toQModelIndex(int serialIndex)
+ {
+ return createIndex(serialIndex % rowCount(), serialIndex / rowCount());
+ }
+
+ Q_INVOKABLE QVariant data(int row, int col)
+ {
+ return data(createIndex(row, col), Qt::DisplayRole);
+ }
+ QVariant data(const QModelIndex &index, int role) const override
+ {
+ if (!index.isValid())
+ return QVariant();
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return QLatin1String("Foo");
+ case Qt::EditRole:
+ return m_checkedCells.contains(indexValue(index));
+ default:
+ return QVariant();
+ }
+ }
+
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole) override
+ {
+
+ if (role != Qt::EditRole)
+ return false;
+
+ int i = indexValue(index);
+ bool checked = value.toBool();
+ if (checked == m_checkedCells.contains(i))
+ return false;
+
+ if (checked)
+ m_checkedCells.insert(i);
+ else
+ m_checkedCells.remove(i);
+
+ emit dataChanged(index, index, { role });
+ return true;
+ }
+
+ Q_INVOKABLE QHash<int, QByteArray> roleNames() const override
+ {
+ return {
+ { Qt::DisplayRole, "display" },
+ { Qt::EditRole, "edit" }
+ };
+ }
+
+signals:
+ void rowCountChanged();
+ void columnCountChanged();
+
+private:
+ int m_rows = 0;
+ int m_cols = 0;
+
+ QSet<int> m_checkedCells;
+};
+
+class TestTableModelWithHeader : public TestTableModel {
+
+ Q_OBJECT
+public:
+ void setRowCount(int count) override
+ {
+ vData.resize(count);
+ TestTableModel::setRowCount(count);
+ }
+
+ void setColumnCount(int count) override
+ {
+ hData.resize(count);
+ TestTableModel::setColumnCount(count);
+ }
+
+ Q_INVOKABLE QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const override
+ {
+ const bool isHorizontal = orientation == Qt::Horizontal;
+ auto sectionCount = isHorizontal ? columnCount() : rowCount();
+ if (section < 0 || section >= sectionCount)
+ return QVariant();
+ switch (role) {
+ case Qt::DisplayRole:
+ return (isHorizontal ? QString::fromLatin1("Column %1") : QString::fromLatin1("Row %1")).arg(section);
+ case Qt::EditRole: {
+ auto &data = isHorizontal ? hData : vData;
+ return data[section].toString();
+ }
+ default:
+ return QVariant();
+ }
+ }
+
+ Q_INVOKABLE bool setHeaderData(int section, Qt::Orientation orientation,
+ const QVariant &value, int role = Qt::EditRole) override
+ {
+ qDebug() << Q_FUNC_INFO
+ << "section:" << section
+ << "orient:" << orientation
+ << "value:" << value
+ << "role:" << QAbstractItemModel::roleNames()[role];
+ auto sectionCount = orientation == Qt::Horizontal ? columnCount() : rowCount();
+ if (section < 0 || section >= sectionCount)
+ return false;
+ auto &data = orientation == Qt::Horizontal ? hData : vData;
+ data[section] = value;
+ emit headerDataChanged(orientation, section, section);
+ return true;
+ }
+
+private:
+ QVector<QVariant> hData, vData;
+};
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ qmlRegisterType<TestTableModel>("TestTableModel", 0, 1, "TestTableModel");
+ qmlRegisterType<TestTableModelWithHeader>("TestTableModelWithHeader", 0, 1, "TestTableModelWithHeader");
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/headerview/main.qml b/tests/manual/headerview/main.qml
new file mode 100644
index 00000000..2919f1b2
--- /dev/null
+++ b/tests/manual/headerview/main.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite 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.Models 2.15
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+import QtQuick.Shapes 1.15
+import QtQuick.Window 2.15
+import Qt.labs.qmlmodels 1.0
+import TestTableModelWithHeader 0.1
+
+Window {
+ visible: true
+ width: 640
+ height: 480
+ title: qsTr("HeaderView Test")
+
+ TestTableModelWithHeader {
+ id: tableModel
+ rowCount: 50
+ columnCount: 80
+ }
+
+ TableView {
+ id: tableView
+ anchors.top: parent.top
+ anchors.topMargin: horizontalHeader.height + rowSpacing
+ anchors.left: parent.left
+ anchors.leftMargin: verticalHeader.width + columnSpacing
+ model: tableModel
+ rightMargin: 100
+ bottomMargin: 100
+ columnSpacing: 4
+ rowSpacing: 4
+ syncDirection: Qt.Vertical | Qt.Horizontal
+ implicitWidth: parent.width + columnSpacing
+ implicitHeight: parent.height + rowSpacing
+ clip: true
+ delegate: Rectangle {
+ implicitWidth: 150
+ implicitHeight: 50
+ color: "#e6ecf5"
+
+ CheckBox {
+ anchors.fill: parent
+ text: model.display
+ checked: model.edit
+ leftPadding: 12
+ onClicked: model.edit = checked
+ }
+ }
+ }
+
+ HorizontalHeaderView {
+ id: horizontalHeader
+ objectName: "horizontalHeader"
+ height: contentHeight
+ width: syncView.width
+ anchors.top: parent.top
+ anchors.left: tableView.left
+ syncView: tableView
+ clip: true
+ }
+
+ VerticalHeaderView {
+ id: verticalHeader
+ objectName: "verticalHeader"
+ width: contentWidth
+ height: syncView.height
+ anchors.top: tableView.top
+ syncView: tableView
+ clip: true
+ }
+
+ ToolButton {
+ width: verticalHeader.width
+ height: horizontalHeader.height
+ onClicked: {
+ horizontalHeader.contentX = 0
+ verticalHeader.contentY = 0
+ }
+ }
+}
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index d23b4494..fba3c12a 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -3,6 +3,7 @@ SUBDIRS += \
buttons \
gifs \
fonts \
+ headerview \
screenshots \
styles \
testbench