diff options
Diffstat (limited to 'src')
40 files changed, 644 insertions, 326 deletions
diff --git a/src/qmlmodels/qqmltableinstancemodel.cpp b/src/qmlmodels/qqmltableinstancemodel.cpp index 5eb28db3f2..5bb444637e 100644 --- a/src/qmlmodels/qqmltableinstancemodel.cpp +++ b/src/qmlmodels/qqmltableinstancemodel.cpp @@ -407,6 +407,11 @@ bool QQmlTableInstanceModel::setRequiredProperty(int index, const QString &name, return wasInRequired; } +QQmlDelegateModelItem *QQmlTableInstanceModel::getModelItem(int index) +{ + return m_modelItems.value(index, nullptr); +} + void QQmlTableInstanceModel::deleteIncubationTaskLater(QQmlIncubator *incubationTask) { // We often need to post-delete incubation tasks, since we cannot diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h index cb4fb4c0dd..1aa19cc315 100644 --- a/src/qmlmodels/qqmltableinstancemodel_p.h +++ b/src/qmlmodels/qqmltableinstancemodel_p.h @@ -91,6 +91,8 @@ public: void setWatchedRoles(const QList<QByteArray> &) override { Q_UNREACHABLE(); } int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE_RETURN(0); } + QQmlDelegateModelItem *getModelItem(int index); + private: enum DestructionMode { Deferred, diff --git a/src/quickcontrols/basic/CMakeLists.txt b/src/quickcontrols/basic/CMakeLists.txt index 7b681eee30..4da6e4f2a6 100644 --- a/src/quickcontrols/basic/CMakeLists.txt +++ b/src/quickcontrols/basic/CMakeLists.txt @@ -26,6 +26,7 @@ set(qml_files "Frame.qml" "GroupBox.qml" "HorizontalHeaderView.qml" + "HorizontalHeaderViewDelegate.qml" "ItemDelegate.qml" "Label.qml" "Menu.qml" @@ -64,6 +65,7 @@ set(qml_files "ToolTip.qml" "Tumbler.qml" "VerticalHeaderView.qml" + "VerticalHeaderViewDelegate.qml" ) if (QT_FEATURE_quicktemplates2_calendar) list(APPEND qml_files diff --git a/src/quickcontrols/basic/HorizontalHeaderView.qml b/src/quickcontrols/basic/HorizontalHeaderView.qml index 9f571a8f62..c9c03f322b 100644 --- a/src/quickcontrols/basic/HorizontalHeaderView.qml +++ b/src/quickcontrols/basic/HorizontalHeaderView.qml @@ -3,7 +3,6 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T T.HorizontalHeaderView { @@ -17,27 +16,5 @@ T.HorizontalHeaderView { // TableView won't bother loading any delegates at all. implicitHeight: Math.max(1, contentHeight) - delegate: Rectangle { - id: delegate - - required property var model - - // 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: "#f6f6f6" - border.color: "#e4e4e4" - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: "#ff26282a" - } - } + delegate: HorizontalHeaderViewDelegate { } } diff --git a/src/quickcontrols/basic/HorizontalHeaderViewDelegate.qml b/src/quickcontrols/basic/HorizontalHeaderViewDelegate.qml new file mode 100644 index 0000000000..18d75752d9 --- /dev/null +++ b/src/quickcontrols/basic/HorizontalHeaderViewDelegate.qml @@ -0,0 +1,31 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + border.color: "#e4e4e4" + color: "#f6f6f6" + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "#ff26282a" + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/basic/VerticalHeaderView.qml b/src/quickcontrols/basic/VerticalHeaderView.qml index 52a9bcb876..ecc8e0a653 100644 --- a/src/quickcontrols/basic/VerticalHeaderView.qml +++ b/src/quickcontrols/basic/VerticalHeaderView.qml @@ -3,7 +3,6 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T T.VerticalHeaderView { @@ -17,27 +16,5 @@ T.VerticalHeaderView { implicitWidth: Math.max(1, contentWidth) implicitHeight: syncView ? syncView.height : 0 - delegate: Rectangle { - id: delegate - - required property var model - - // Qt6: add cellPadding (and font etc) as public API in headerview - readonly property real cellPadding: 8 - - implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2)) - implicitHeight: text.implicitHeight + (cellPadding * 2) - color: "#f6f6f6" - border.color: "#e4e4e4" - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: "#ff26282a" - } - } + delegate: VerticalHeaderViewDelegate { } } diff --git a/src/quickcontrols/basic/VerticalHeaderViewDelegate.qml b/src/quickcontrols/basic/VerticalHeaderViewDelegate.qml new file mode 100644 index 0000000000..18d75752d9 --- /dev/null +++ b/src/quickcontrols/basic/VerticalHeaderViewDelegate.qml @@ -0,0 +1,31 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + border.color: "#e4e4e4" + color: "#f6f6f6" + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "#ff26282a" + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/fusion/CMakeLists.txt b/src/quickcontrols/fusion/CMakeLists.txt index 937d357bd6..021b9323dc 100644 --- a/src/quickcontrols/fusion/CMakeLists.txt +++ b/src/quickcontrols/fusion/CMakeLists.txt @@ -20,6 +20,7 @@ set(qml_files "Frame.qml" "GroupBox.qml" "HorizontalHeaderView.qml" + "HorizontalHeaderViewDelegate.qml" "ItemDelegate.qml" "Label.qml" "Menu.qml" @@ -57,6 +58,7 @@ set(qml_files "TreeViewDelegate.qml" "Tumbler.qml" "VerticalHeaderView.qml" + "VerticalHeaderViewDelegate.qml" ) set_source_files_properties(DelayButton.qml PROPERTIES QT_QML_SOURCE_VERSIONS "2.2;6.0" diff --git a/src/quickcontrols/fusion/HorizontalHeaderView.qml b/src/quickcontrols/fusion/HorizontalHeaderView.qml index dbea743aca..c9c03f322b 100644 --- a/src/quickcontrols/fusion/HorizontalHeaderView.qml +++ b/src/quickcontrols/fusion/HorizontalHeaderView.qml @@ -3,9 +3,7 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T -import QtQuick.Controls.Fusion.impl T.HorizontalHeaderView { id: control @@ -18,36 +16,5 @@ T.HorizontalHeaderView { // TableView won't bother loading any delegates at all. implicitHeight: Math.max(1, contentHeight) - delegate: Rectangle { - id: delegate - - required property var model - - // 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)) - - gradient: Gradient { - id: buttonGradient - GradientStop { - position: 0 - color: Fusion.gradientStart(control.palette.button) - } - GradientStop { - position: 1 - color: Fusion.gradientStop(control.palette.button) - } - } - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } + delegate: HorizontalHeaderViewDelegate { } } diff --git a/src/quickcontrols/fusion/HorizontalHeaderViewDelegate.qml b/src/quickcontrols/fusion/HorizontalHeaderViewDelegate.qml new file mode 100644 index 0000000000..681359a8d0 --- /dev/null +++ b/src/quickcontrols/fusion/HorizontalHeaderViewDelegate.qml @@ -0,0 +1,41 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T +import QtQuick.Controls.Fusion as FusionControls + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + id: backgroundRect + color: control.palette.button + gradient: Gradient { + GradientStop { + position: 0 + color: FusionControls.Fusion.gradientStart(backgroundRect.color) + } + GradientStop { + position: 1 + color: FusionControls.Fusion.gradientStop(backgroundRect.color) + } + } + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/fusion/VerticalHeaderView.qml b/src/quickcontrols/fusion/VerticalHeaderView.qml index c2cb281a24..ecc8e0a653 100644 --- a/src/quickcontrols/fusion/VerticalHeaderView.qml +++ b/src/quickcontrols/fusion/VerticalHeaderView.qml @@ -3,9 +3,7 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T -import QtQuick.Controls.Fusion.impl T.VerticalHeaderView { id: control @@ -18,35 +16,5 @@ T.VerticalHeaderView { implicitWidth: Math.max(1, contentWidth) implicitHeight: syncView ? syncView.height : 0 - delegate: Rectangle { - id: delegate - - required property var model - - // Qt6: add cellPadding (and font etc) as public API in headerview - readonly property real cellPadding: 8 - - implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2)) - implicitHeight: text.implicitHeight + (cellPadding * 2) - - gradient: Gradient { - GradientStop { - position: 0 - color: Fusion.gradientStart(control.palette.button) - } - GradientStop { - position: 1 - color: Fusion.gradientStop(control.palette.button) - } - } - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } + delegate: VerticalHeaderViewDelegate { } } diff --git a/src/quickcontrols/fusion/VerticalHeaderViewDelegate.qml b/src/quickcontrols/fusion/VerticalHeaderViewDelegate.qml new file mode 100644 index 0000000000..681359a8d0 --- /dev/null +++ b/src/quickcontrols/fusion/VerticalHeaderViewDelegate.qml @@ -0,0 +1,41 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T +import QtQuick.Controls.Fusion as FusionControls + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + id: backgroundRect + color: control.palette.button + gradient: Gradient { + GradientStop { + position: 0 + color: FusionControls.Fusion.gradientStart(backgroundRect.color) + } + GradientStop { + position: 1 + color: FusionControls.Fusion.gradientStop(backgroundRect.color) + } + } + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/imagine/CMakeLists.txt b/src/quickcontrols/imagine/CMakeLists.txt index d9267be651..f67bb400af 100644 --- a/src/quickcontrols/imagine/CMakeLists.txt +++ b/src/quickcontrols/imagine/CMakeLists.txt @@ -20,6 +20,7 @@ set(qml_files "Frame.qml" "GroupBox.qml" "HorizontalHeaderView.qml" + "HorizontalHeaderViewDelegate.qml" "ItemDelegate.qml" "Label.qml" "Menu.qml" @@ -56,6 +57,7 @@ set(qml_files "ToolTip.qml" "Tumbler.qml" "VerticalHeaderView.qml" + "VerticalHeaderViewDelegate.qml" ) set_source_files_properties(DelayButton.qml PROPERTIES QT_QML_SOURCE_VERSIONS "2.2;6.0" diff --git a/src/quickcontrols/imagine/HorizontalHeaderView.qml b/src/quickcontrols/imagine/HorizontalHeaderView.qml index 9f571a8f62..c9c03f322b 100644 --- a/src/quickcontrols/imagine/HorizontalHeaderView.qml +++ b/src/quickcontrols/imagine/HorizontalHeaderView.qml @@ -3,7 +3,6 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T T.HorizontalHeaderView { @@ -17,27 +16,5 @@ T.HorizontalHeaderView { // TableView won't bother loading any delegates at all. implicitHeight: Math.max(1, contentHeight) - delegate: Rectangle { - id: delegate - - required property var model - - // 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: "#f6f6f6" - border.color: "#e4e4e4" - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: "#ff26282a" - } - } + delegate: HorizontalHeaderViewDelegate { } } diff --git a/src/quickcontrols/imagine/HorizontalHeaderViewDelegate.qml b/src/quickcontrols/imagine/HorizontalHeaderViewDelegate.qml new file mode 100644 index 0000000000..18d75752d9 --- /dev/null +++ b/src/quickcontrols/imagine/HorizontalHeaderViewDelegate.qml @@ -0,0 +1,31 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + border.color: "#e4e4e4" + color: "#f6f6f6" + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "#ff26282a" + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/imagine/VerticalHeaderView.qml b/src/quickcontrols/imagine/VerticalHeaderView.qml index 52a9bcb876..ecc8e0a653 100644 --- a/src/quickcontrols/imagine/VerticalHeaderView.qml +++ b/src/quickcontrols/imagine/VerticalHeaderView.qml @@ -3,7 +3,6 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T T.VerticalHeaderView { @@ -17,27 +16,5 @@ T.VerticalHeaderView { implicitWidth: Math.max(1, contentWidth) implicitHeight: syncView ? syncView.height : 0 - delegate: Rectangle { - id: delegate - - required property var model - - // Qt6: add cellPadding (and font etc) as public API in headerview - readonly property real cellPadding: 8 - - implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2)) - implicitHeight: text.implicitHeight + (cellPadding * 2) - color: "#f6f6f6" - border.color: "#e4e4e4" - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: "#ff26282a" - } - } + delegate: VerticalHeaderViewDelegate { } } diff --git a/src/quickcontrols/imagine/VerticalHeaderViewDelegate.qml b/src/quickcontrols/imagine/VerticalHeaderViewDelegate.qml new file mode 100644 index 0000000000..18d75752d9 --- /dev/null +++ b/src/quickcontrols/imagine/VerticalHeaderViewDelegate.qml @@ -0,0 +1,31 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + border.color: "#e4e4e4" + color: "#f6f6f6" + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "#ff26282a" + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/ios/CMakeLists.txt b/src/quickcontrols/ios/CMakeLists.txt index f3be4038a3..165fb76c53 100644 --- a/src/quickcontrols/ios/CMakeLists.txt +++ b/src/quickcontrols/ios/CMakeLists.txt @@ -46,7 +46,9 @@ set(qml_files "BusyIndicator.qml" "ComboBox.qml" "HorizontalHeaderView.qml" + "HorizontalHeaderViewDelegate.qml" "VerticalHeaderView.qml" + "VerticalHeaderViewDelegate.qml" "Dialog.qml" "DialogButtonBox.qml" "DelayButton.qml" diff --git a/src/quickcontrols/ios/HorizontalHeaderView.qml b/src/quickcontrols/ios/HorizontalHeaderView.qml index 1a02ff8f05..b74e4ea119 100644 --- a/src/quickcontrols/ios/HorizontalHeaderView.qml +++ b/src/quickcontrols/ios/HorizontalHeaderView.qml @@ -3,7 +3,6 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T T.HorizontalHeaderView { @@ -17,24 +16,5 @@ T.HorizontalHeaderView { // TableView won't bother loading any delegates at all. implicitHeight: Math.max(1, contentHeight) - delegate: Rectangle { - id: delegate - - required property var model - - readonly property real cellPadding: 8 - - implicitWidth: text.implicitWidth + (cellPadding * 2) - implicitHeight: Math.max(control.height, text.implicitHeight + (cellPadding * 2)) - color: control.palette.button - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } + delegate: HorizontalHeaderViewDelegate { } } diff --git a/src/quickcontrols/ios/HorizontalHeaderViewDelegate.qml b/src/quickcontrols/ios/HorizontalHeaderViewDelegate.qml new file mode 100644 index 0000000000..1f553b0ec4 --- /dev/null +++ b/src/quickcontrols/ios/HorizontalHeaderViewDelegate.qml @@ -0,0 +1,29 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + color: control.palette.button + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/ios/VerticalHeaderView.qml b/src/quickcontrols/ios/VerticalHeaderView.qml index 179bc35b23..816e0a519a 100644 --- a/src/quickcontrols/ios/VerticalHeaderView.qml +++ b/src/quickcontrols/ios/VerticalHeaderView.qml @@ -3,7 +3,6 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T T.VerticalHeaderView { @@ -17,24 +16,5 @@ T.VerticalHeaderView { implicitWidth: Math.max(1, contentWidth) implicitHeight: syncView ? syncView.height : 0 - delegate: Rectangle { - id: delegate - - required property var model - - readonly property real cellPadding: 8 - - implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2)) - implicitHeight: text.implicitHeight + (cellPadding * 2) - color: control.palette.button - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } + delegate: VerticalHeaderViewDelegate { } } diff --git a/src/quickcontrols/ios/VerticalHeaderViewDelegate.qml b/src/quickcontrols/ios/VerticalHeaderViewDelegate.qml new file mode 100644 index 0000000000..1f553b0ec4 --- /dev/null +++ b/src/quickcontrols/ios/VerticalHeaderViewDelegate.qml @@ -0,0 +1,29 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + color: control.palette.button + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/material/CMakeLists.txt b/src/quickcontrols/material/CMakeLists.txt index f485fe7b30..8ff5513401 100644 --- a/src/quickcontrols/material/CMakeLists.txt +++ b/src/quickcontrols/material/CMakeLists.txt @@ -20,6 +20,7 @@ set(qml_files "Frame.qml" "GroupBox.qml" "HorizontalHeaderView.qml" + "HorizontalHeaderViewDelegate.qml" "ItemDelegate.qml" "Label.qml" "Menu.qml" @@ -59,6 +60,7 @@ set(qml_files "TreeViewDelegate.qml" "Tumbler.qml" "VerticalHeaderView.qml" + "VerticalHeaderViewDelegate.qml" ) set_source_files_properties(DelayButton.qml PROPERTIES QT_QML_SOURCE_VERSIONS "2.2;6.0" diff --git a/src/quickcontrols/material/HorizontalHeaderView.qml b/src/quickcontrols/material/HorizontalHeaderView.qml index 76060d8e83..d0fbddf50b 100644 --- a/src/quickcontrols/material/HorizontalHeaderView.qml +++ b/src/quickcontrols/material/HorizontalHeaderView.qml @@ -3,10 +3,8 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T import QtQuick.Controls.Material -import QtQuick.Controls.Material.impl T.HorizontalHeaderView { id: control @@ -19,26 +17,5 @@ T.HorizontalHeaderView { // TableView won't bother loading any delegates at all. implicitHeight: Math.max(1, contentHeight) - delegate: Rectangle { - id: delegate - - required property var model - - // 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 - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: enabled ? control.Material.foreground : control.Material.hintTextColor - } - } + delegate: HorizontalHeaderViewDelegate { } } diff --git a/src/quickcontrols/material/HorizontalHeaderViewDelegate.qml b/src/quickcontrols/material/HorizontalHeaderViewDelegate.qml new file mode 100644 index 0000000000..1f3d6e7c68 --- /dev/null +++ b/src/quickcontrols/material/HorizontalHeaderViewDelegate.qml @@ -0,0 +1,32 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + color: control.Material.backgroundColor + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: enabled ? control.Material.foreground + : control.Material.hintTextColor + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/material/VerticalHeaderView.qml b/src/quickcontrols/material/VerticalHeaderView.qml index 0646f6135d..d030797254 100644 --- a/src/quickcontrols/material/VerticalHeaderView.qml +++ b/src/quickcontrols/material/VerticalHeaderView.qml @@ -3,10 +3,8 @@ pragma ComponentBehavior: Bound -import QtQuick import QtQuick.Templates as T import QtQuick.Controls.Material -import QtQuick.Controls.Material.impl T.VerticalHeaderView { id: control @@ -19,26 +17,5 @@ T.VerticalHeaderView { implicitWidth: Math.max(1, contentWidth) implicitHeight: syncView ? syncView.height : 0 - delegate: Rectangle { - id: delegate - - required property var model - - // Qt6: add cellPadding (and font etc) as public API in headerview - readonly property real cellPadding: 8 - - implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2)) - implicitHeight: text.implicitHeight + (cellPadding * 2) - color: control.Material.backgroundColor - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: enabled ? control.Material.foreground : control.Material.hintTextColor - } - } + delegate: VerticalHeaderViewDelegate { } } diff --git a/src/quickcontrols/material/VerticalHeaderViewDelegate.qml b/src/quickcontrols/material/VerticalHeaderViewDelegate.qml new file mode 100644 index 0000000000..1f3d6e7c68 --- /dev/null +++ b/src/quickcontrols/material/VerticalHeaderViewDelegate.qml @@ -0,0 +1,32 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + color: control.Material.backgroundColor + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: enabled ? control.Material.foreground + : control.Material.hintTextColor + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/universal/CMakeLists.txt b/src/quickcontrols/universal/CMakeLists.txt index 167a9f66a6..e309f51bb5 100644 --- a/src/quickcontrols/universal/CMakeLists.txt +++ b/src/quickcontrols/universal/CMakeLists.txt @@ -20,6 +20,7 @@ set(qml_files "Frame.qml" "GroupBox.qml" "HorizontalHeaderView.qml" + "HorizontalHeaderViewDelegate.qml" "ItemDelegate.qml" "Label.qml" "Menu.qml" @@ -57,6 +58,7 @@ set(qml_files "ToolTip.qml" "Tumbler.qml" "VerticalHeaderView.qml" + "VerticalHeaderViewDelegate.qml" ) set_source_files_properties(DelayButton.qml PROPERTIES QT_QML_SOURCE_VERSIONS "2.2;6.0" diff --git a/src/quickcontrols/universal/HorizontalHeaderView.qml b/src/quickcontrols/universal/HorizontalHeaderView.qml index f792a1e690..c6124a8d28 100644 --- a/src/quickcontrols/universal/HorizontalHeaderView.qml +++ b/src/quickcontrols/universal/HorizontalHeaderView.qml @@ -3,11 +3,8 @@ pragma ComponentBehavior: Bound -import QtQuick -import QtQuick.Controls.impl import QtQuick.Templates as T import QtQuick.Controls.Universal -import QtQuick.Controls.Universal.impl T.HorizontalHeaderView { id: control @@ -20,26 +17,5 @@ T.HorizontalHeaderView { // TableView won't bother loading any delegates at all. implicitHeight: Math.max(1, contentHeight) - delegate: Rectangle { - id: delegate - - required property var model - - // 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.Universal.background - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2) - } - } + delegate: HorizontalHeaderViewDelegate { } } diff --git a/src/quickcontrols/universal/HorizontalHeaderViewDelegate.qml b/src/quickcontrols/universal/HorizontalHeaderViewDelegate.qml new file mode 100644 index 0000000000..fcfbdd6deb --- /dev/null +++ b/src/quickcontrols/universal/HorizontalHeaderViewDelegate.qml @@ -0,0 +1,33 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls.impl as ControlsImpl +import QtQuick.Controls.Universal +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + color: control.Universal.background + } + + contentItem: Label { + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: ControlsImpl.Color.transparent(control.Universal.foreground, + enabled ? 1.0 : 0.2) + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quickcontrols/universal/VerticalHeaderView.qml b/src/quickcontrols/universal/VerticalHeaderView.qml index 6e4540d66a..0dc6281558 100644 --- a/src/quickcontrols/universal/VerticalHeaderView.qml +++ b/src/quickcontrols/universal/VerticalHeaderView.qml @@ -3,11 +3,8 @@ pragma ComponentBehavior: Bound -import QtQuick -import QtQuick.Controls.impl import QtQuick.Templates as T import QtQuick.Controls.Universal -import QtQuick.Controls.Universal.impl T.VerticalHeaderView { id: control @@ -20,26 +17,5 @@ T.VerticalHeaderView { implicitWidth: Math.max(1, contentWidth) implicitHeight: syncView ? syncView.height : 0 - delegate: Rectangle { - id: delegate - - required property var model - - // Qt6: add cellPadding (and font etc) as public API in headerview - readonly property real cellPadding: 8 - - implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2)) - implicitHeight: text.implicitHeight + (cellPadding * 2) - color: control.Universal.background - - Label { - id: text - text: delegate.model[control.textRole] - width: delegate.width - height: delegate.height - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: Color.transparent(control.Universal.foreground, enabled ? 1.0 : 0.2) - } - } + delegate: VerticalHeaderViewDelegate { } } diff --git a/src/quickcontrols/universal/VerticalHeaderViewDelegate.qml b/src/quickcontrols/universal/VerticalHeaderViewDelegate.qml new file mode 100644 index 0000000000..e5c071e774 --- /dev/null +++ b/src/quickcontrols/universal/VerticalHeaderViewDelegate.qml @@ -0,0 +1,39 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls.impl as ControlsImpl +import QtQuick.Controls.Universal +import QtQuick.Templates as T + +T.HeaderViewDelegate { + id: control + + // same as AbstractButton.qml + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 8 + + highlighted: selected + + background: Rectangle { + implicitWidth: Math.max(control.headerView.width, + control.contentItem.implicitWidth + + (control.padding * 2)) + implicitHeight: control.contentItem.implicitHeight + (control.padding * 2) + color: control.Universal.background + } + + contentItem: Label { + width: control.width + height: control.height + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: ControlsImpl.Color.transparent(control.Universal.foreground, + enabled ? 1.0 : 0.2) + text: control.model[control.headerView.textRole] + } +} diff --git a/src/quicktemplates/CMakeLists.txt b/src/quicktemplates/CMakeLists.txt index e12719f5d1..c7ce4d611f 100644 --- a/src/quicktemplates/CMakeLists.txt +++ b/src/quicktemplates/CMakeLists.txt @@ -174,6 +174,8 @@ qt_internal_extend_target(QuickTemplates2 CONDITION QT_FEATURE_quick_tableview qquickselectionrectangle.cpp qquickselectionrectangle_p.h qquickselectionrectangle_p_p.h qquicktableviewdelegate.cpp qquicktableviewdelegate_p.h + qquicktableviewdelegate_p_p.h + qquickheaderviewdelegate.cpp qquickheaderviewdelegate_p.h ) qt_internal_extend_target(QuickTemplates2 CONDITION QT_FEATURE_quick_treeview diff --git a/src/quicktemplates/qquickheaderview.cpp b/src/quicktemplates/qquickheaderview.cpp index c6ba3c02da..8c019bac27 100644 --- a/src/quicktemplates/qquickheaderview.cpp +++ b/src/quicktemplates/qquickheaderview.cpp @@ -80,6 +80,9 @@ QT_BEGIN_NAMESPACE +static const char *kRequiredProperty_headerView = "headerView"; +static const char *kRequiredProperty_model = "model"; + QQuickHeaderViewBasePrivate::QQuickHeaderViewBasePrivate() : QQuickTableViewPrivate() { @@ -184,6 +187,24 @@ QAbstractItemModel *QQuickHeaderViewBasePrivate::selectionSourceModel() return &m_headerDataProxyModel; } +void QQuickHeaderViewBasePrivate::initItemCallback(int modelIndex, QObject *object) +{ + Q_Q(QQuickHeaderViewBase); + + QQuickTableViewPrivate::initItemCallback(modelIndex, object); + + auto item = qobject_cast<QQuickItem *>(object); + if (!item) + return; + + QQmlDelegateModelItem *modelItem = tableModel->getModelItem(modelIndex); + + setRequiredProperty(kRequiredProperty_headerView, QVariant::fromValue(q), + modelIndex, item, true); + setRequiredProperty(kRequiredProperty_model, QVariant::fromValue(modelItem->modelObject()), + modelIndex, item, true); +} + int QQuickHeaderViewBasePrivate::logicalRowIndex(const int visualIndex) const { return (m_headerDataProxyModel.orientation() == Qt::Horizontal) ? visualIndex : QQuickTableViewPrivate::logicalRowIndex(visualIndex); diff --git a/src/quicktemplates/qquickheaderview_p_p.h b/src/quicktemplates/qquickheaderview_p_p.h index 96bbe5a00f..df700bdca4 100644 --- a/src/quicktemplates/qquickheaderview_p_p.h +++ b/src/quicktemplates/qquickheaderview_p_p.h @@ -63,6 +63,8 @@ public: QQuickHeaderViewBasePrivate(); ~QQuickHeaderViewBasePrivate(); + static inline QQuickHeaderViewBasePrivate *get(QQuickHeaderViewBase *q) { return q->d_func(); } + void init(); Qt::Orientation orientation() const; void setOrientation(Qt::Orientation orientation); @@ -73,6 +75,9 @@ public: void syncSyncView() override; QAbstractItemModel *selectionSourceModel() override; + // QQuickTableViewPrivate interface + virtual void initItemCallback(int modelIndex, QObject *item) override; + protected: QHeaderDataProxyModel m_headerDataProxyModel; struct SectionSize diff --git a/src/quicktemplates/qquickheaderviewdelegate.cpp b/src/quicktemplates/qquickheaderviewdelegate.cpp new file mode 100644 index 0000000000..a91e3c8d19 --- /dev/null +++ b/src/quicktemplates/qquickheaderviewdelegate.cpp @@ -0,0 +1,70 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qquickheaderviewdelegate_p.h" + +#include <QtQuickTemplates2/private/qquickheaderview_p.h> +#include <QtQuickTemplates2/private/qquickheaderview_p_p.h> +#include <QtQuickTemplates2/private/qquicktableviewdelegate_p_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickHeaderViewDelegatePrivate : public QQuickTableViewDelegatePrivate +{ +public: + Q_DECLARE_PUBLIC(QQuickHeaderViewDelegate) + +public: + QPointer<QQuickHeaderViewBase> headerView; + QVariant model; +}; + +QQuickHeaderViewDelegate::QQuickHeaderViewDelegate(QQuickItem *parent) + : QQuickTableViewDelegate(*(new QQuickHeaderViewDelegatePrivate), parent) +{ +} + +QQuickHeaderViewBase *QQuickHeaderViewDelegate::headerView() const +{ + return d_func()->headerView; +} + +Qt::Orientation QQuickHeaderViewDelegate::orientation() const +{ + return headerView() + ? QQuickHeaderViewBasePrivate::get(headerView())->orientation() + : Qt::Horizontal; +} + +void QQuickHeaderViewDelegate::setHeaderView(QQuickHeaderViewBase *headerView) +{ + Q_D(QQuickHeaderViewDelegate); + if (d->headerView == headerView) + return; + + const Qt::Orientation oldOrientation = orientation(); + + d->headerView = headerView; + emit headerViewChanged(); + + if (oldOrientation != orientation()) + emit orientationChanged(); +} + +QVariant QQuickHeaderViewDelegate::model() const +{ + return d_func()->model; +} + +void QQuickHeaderViewDelegate::setModel(const QVariant &model) +{ + Q_D(QQuickHeaderViewDelegate); + if (d->model == model) + return; + d->model = model; + emit modelChanged(); +} + +QT_END_NAMESPACE + +#include "moc_qquickheaderviewdelegate_p.cpp" diff --git a/src/quicktemplates/qquickheaderviewdelegate_p.h b/src/quicktemplates/qquickheaderviewdelegate_p.h new file mode 100644 index 0000000000..ef0829c264 --- /dev/null +++ b/src/quicktemplates/qquickheaderviewdelegate_p.h @@ -0,0 +1,60 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKHEADERVIEWDELEGATE_P_H +#define QQUICKHEADERVIEWDELEGATE_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 <QtQuickTemplates2/private/qquicktableviewdelegate_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickHeaderViewBase; +class QQuickHeaderViewDelegatePrivate; + +class Q_QUICKTEMPLATES2_EXPORT QQuickHeaderViewDelegate : public QQuickTableViewDelegate +{ + Q_OBJECT + + Q_PROPERTY(Qt::Orientation orientation READ orientation NOTIFY orientationChanged FINAL) + // Required properties + Q_PROPERTY(QQuickHeaderViewBase *headerView READ headerView WRITE setHeaderView NOTIFY headerViewChanged REQUIRED FINAL) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged REQUIRED FINAL) + + QML_NAMED_ELEMENT(HeaderViewDelegate) + QML_ADDED_IN_VERSION(6, 10) + +public: + QQuickHeaderViewDelegate(QQuickItem *parent = nullptr); + + QQuickHeaderViewBase *headerView() const; + void setHeaderView(QQuickHeaderViewBase *headerView); + + Qt::Orientation orientation() const; + + QVariant model() const; + void setModel(const QVariant &model); + +Q_SIGNALS: + void headerViewChanged(); + void modelChanged(); + void orientationChanged(); + +private: + Q_DISABLE_COPY(QQuickHeaderViewDelegate) + Q_DECLARE_PRIVATE(QQuickHeaderViewDelegate) +}; + +QT_END_NAMESPACE + +#endif // QQUICKHEADERVIEWDELEGATE_P_H diff --git a/src/quicktemplates/qquicktableviewdelegate.cpp b/src/quicktemplates/qquicktableviewdelegate.cpp index c62f0de810..c9ba8cabdd 100644 --- a/src/quicktemplates/qquicktableviewdelegate.cpp +++ b/src/quicktemplates/qquicktableviewdelegate.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qquicktableviewdelegate_p.h" +#include "qquicktableviewdelegate_p_p.h" #include <QtQuickTemplates2/private/qquickitemdelegate_p_p.h> #include <QtQuick/private/qquicktaphandler_p.h> @@ -113,20 +114,6 @@ QT_BEGIN_NAMESPACE using namespace Qt::Literals::StringLiterals; -class QQuickTableViewDelegatePrivate : public QQuickItemDelegatePrivate -{ -public: - Q_DECLARE_PUBLIC(QQuickTableViewDelegate) - - QPalette defaultPalette() const override; - -public: - QPointer<QQuickTableView> m_tableView; - bool m_current = false; - bool m_selected = false; - bool m_editing = false; -}; - QQuickTableViewDelegate::QQuickTableViewDelegate(QQuickItem *parent) : QQuickItemDelegate(*(new QQuickTableViewDelegatePrivate), parent) { @@ -157,6 +144,11 @@ QQuickTableViewDelegate::QQuickTableViewDelegate(QQuickItem *parent) }, Qt::DirectConnection); } +QQuickTableViewDelegate::QQuickTableViewDelegate(QQuickTableViewDelegatePrivate &dd, QQuickItem *parent) + : QQuickItemDelegate(dd, parent) +{ +} + void QQuickTableViewDelegate::mousePressEvent(QMouseEvent *event) { Q_D(QQuickTableViewDelegate); @@ -186,46 +178,46 @@ QFont QQuickTableViewDelegate::defaultFont() const bool QQuickTableViewDelegate::current() const { - return d_func()->m_current; + return d_func()->current; } void QQuickTableViewDelegate::setCurrent(bool current) { Q_D(QQuickTableViewDelegate); - if (d->m_current == current) + if (d->current == current) return; - d->m_current = current; + d->current = current; emit currentChanged(); } bool QQuickTableViewDelegate::selected() const { - return d_func()->m_selected; + return d_func()->selected; } void QQuickTableViewDelegate::setSelected(bool selected) { Q_D(QQuickTableViewDelegate); - if (d->m_selected == selected) + if (d->selected == selected) return; - d->m_selected = selected; + d->selected = selected; emit selectedChanged(); } bool QQuickTableViewDelegate::editing() const { - return d_func()->m_editing; + return d_func()->editing; } void QQuickTableViewDelegate::setEditing(bool editing) { Q_D(QQuickTableViewDelegate); - if (d->m_editing == editing) + if (d->editing == editing) return; - d->m_editing = editing; + d->editing = editing; emit editingChanged(); } diff --git a/src/quicktemplates/qquicktableviewdelegate_p.h b/src/quicktemplates/qquicktableviewdelegate_p.h index 80667b425f..1b7ffbec18 100644 --- a/src/quicktemplates/qquicktableviewdelegate_p.h +++ b/src/quicktemplates/qquicktableviewdelegate_p.h @@ -59,6 +59,8 @@ Q_SIGNALS: void editingChanged(); protected: + QQuickTableViewDelegate(QQuickTableViewDelegatePrivate &dd, QQuickItem *parent); + QFont defaultFont() const override; void mousePressEvent(QMouseEvent *event) override; diff --git a/src/quicktemplates/qquicktableviewdelegate_p_p.h b/src/quicktemplates/qquicktableviewdelegate_p_p.h new file mode 100644 index 0000000000..3ffde9830a --- /dev/null +++ b/src/quicktemplates/qquicktableviewdelegate_p_p.h @@ -0,0 +1,38 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QQUICKTABLEVIEWDELEGATE_P_P_H +#define QQUICKTABLEVIEWDELEGATE_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 <QtQuickTemplates2/private/qquickitemdelegate_p_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickTableViewDelegatePrivate : public QQuickItemDelegatePrivate +{ +public: + Q_DECLARE_PUBLIC(QQuickTableViewDelegate) + + QPalette defaultPalette() const override; + +public: + QPointer<QQuickTableView> m_tableView; + bool current = false; + bool selected = false; + bool editing = false; +}; + +QT_END_NAMESPACE + +#endif // QQUICKTABLEVIEWDELEGATE_P_P_H |