From 0b607bfe14048e32dd81855e1497dda3465b5183 Mon Sep 17 00:00:00 2001 From: Yulong Bai Date: Thu, 11 Apr 2019 17:30:49 +0200 Subject: Add HorizontalHeaderView and VerticalHeaderView [ChangeLog][Controls] Add HorizontalHeaderView and VerticalHeaderView. They are controls associated with TableView. Support flicking synchronization Support default, fusion, imagine, material and universal delegate styles. Fixes: QTPM-1300 Change-Id: Ie3f913dd616cda0d4e5a22a3d95baf71692370fe Reviewed-by: Volker Hilsheimer --- .../controls/material/HorizontalHeaderView.qml | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/imports/controls/material/HorizontalHeaderView.qml (limited to 'src/imports/controls/material/HorizontalHeaderView.qml') 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 + } + } +} -- cgit v1.2.3 From 6cdd4b53031de17b36b30b00de0a6945470a35ad Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 19 Feb 2020 15:56:38 +0100 Subject: HeaderView: set implicitSize on the style items By setting an implicit size, the user don't need to set a width or height on a HeaderView himself, but it will get the default size recommended by the style. By doing it the way it's done in the patch we achieve the following: 1. A HeaderView will by default be resized to be the same size as the delegate. 2. If the application sets a size on HeaderView it that is larger than the implicit size of the delegate, the delegate will be resized to have the same size (effectively filling out the free space in the header). 3. If the size of HeaderView is smaller than the implicit size of the delegate, the delegate will simply be clipped. (effectivly saying that the implicitSize of the delegate is also it's minimum size). If this is not acceptable for the application, it will need to use a custom delegate. Since a HeaderView delegate is a component and not an item, it should not be a part of the sanity checks we do to avoid using internal IDs. Hence we blacklist until we have a better way of handling such cases. Task-number: QTPM-1300 Change-Id: I30ca3e13ce5e1371b60f5c4ecf742a7d7e794a36 Reviewed-by: Mitch Curtis --- src/imports/controls/material/HorizontalHeaderView.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/imports/controls/material/HorizontalHeaderView.qml') diff --git a/src/imports/controls/material/HorizontalHeaderView.qml b/src/imports/controls/material/HorizontalHeaderView.qml index a1228cdc..504579cc 100644 --- a/src/imports/controls/material/HorizontalHeaderView.qml +++ b/src/imports/controls/material/HorizontalHeaderView.qml @@ -43,12 +43,19 @@ import QtQuick.Controls.Material.impl 2.15 T.HorizontalHeaderView { id: control + implicitWidth: syncView ? syncView.width : 0 + implicitHeight: contentHeight + delegate: Rectangle { - implicitWidth: 50 - implicitHeight: 25 + // Qt6: add cellPadding (and font etc) as public API in headerview + readonly property real cellPadding: 8 + + implicitWidth: text.implicitWidth + (cellPadding * 2) + implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2)) color: control.Material.backgroundColor Text { + id: text text: model[control.textRole] width: parent.width height: parent.height -- cgit v1.2.3