From dfc7521a8216ce05c38fb9d143b86e7fa8f1aeeb Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Fri, 26 Jul 2024 16:07:06 +0200 Subject: [PATCH] qmllint: disable the tumbler warning in qmllint The tumbler warning in qmllint does deliver false positives, even on the code used by the documentation. Disable the warning for now, and use QTBUG-127562 to track work on fixing the tumbler warning. Add a test for the tumbler where the warning should not be received. Pick-to: 6.8 6.7 Task-number: QTBUG-127562 Change-Id: Ia403b2d3aec0991613bf444d0047aa040db2bf65 Reviewed-by: Fabian Kosmale --- src/plugins/qmllint/quick/quicklintplugin.cpp | 4 ---- .../qml/qmllint/data/pluginQuick_attached.qml | 1 - .../qmllint/data/pluginQuick_tumblerGood.qml | 19 +++++++++++++++++++ tests/auto/qml/qmllint/tst_qmllint.cpp | 7 +++++-- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 tests/auto/qml/qmllint/data/pluginQuick_tumblerGood.qml diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp index fa2a939e08..934c2ef48f 100644 --- a/src/plugins/qmllint/quick/quicklintplugin.cpp +++ b/src/plugins/qmllint/quick/quicklintplugin.cpp @@ -717,10 +717,6 @@ void QmlLintQuickPlugin::registerPasses(QQmlSA::PassManager *manager, "SwipeDelegate attached property must be attached to an object deriving from Item"); addAttachedWarning({ "QtQuick.Templates", "SwipeView" }, { { "QtQuick", "Item" } }, "SwipeView attached property must be attached to an object deriving from Item"); - addAttachedWarning( - { "QtQuick.Templates", "Tumbler" }, { { "QtQuick", "Tumbler" } }, - "Tumbler: attached properties of Tumbler must be accessed through a delegate item", - true); addVarBindingWarning("QtQuick.Templates", "Tumbler", { { "contentItem", { "QtQuick", "PathView" } }, { "contentItem", { "QtQuick", "ListView" } } }); diff --git a/tests/auto/qml/qmllint/data/pluginQuick_attached.qml b/tests/auto/qml/qmllint/data/pluginQuick_attached.qml index c5f4e0d552..b63147a9b2 100644 --- a/tests/auto/qml/qmllint/data/pluginQuick_attached.qml +++ b/tests/auto/qml/qmllint/data/pluginQuick_attached.qml @@ -21,7 +21,6 @@ Item { property int swipeView: SwipeView.index // Read-only TextArea.flickable: TextArea {} ToolTip.delay: 50 - property bool tumbler: Tumbler.displacement // Read-only property bool swipeDelegate: SwipeDelegate.pressed // Read-only } } diff --git a/tests/auto/qml/qmllint/data/pluginQuick_tumblerGood.qml b/tests/auto/qml/qmllint/data/pluginQuick_tumblerGood.qml new file mode 100644 index 0000000000..5b4bed1f33 --- /dev/null +++ b/tests/auto/qml/qmllint/data/pluginQuick_tumblerGood.qml @@ -0,0 +1,19 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick.Controls + +Rectangle { + // modified from the Tumbler documentation at https://doc.qt.io/qt-6/qml-qtquick-controls-tumbler.html + Component { + id: delegateComponent + + Label { + text: formatText(Tumbler.tumbler.count, modelData) + opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2) + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + } +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 683b599fee..8240af31ec 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -2291,11 +2291,14 @@ void TestQmllint::quickPlugin() Message { u"StackView attached property must be attached to an object deriving from Item"_s }, Message { u"TextArea attached property must be attached to an object deriving from Flickable"_s }, Message { u"StackLayout attached property must be attached to an object deriving from Item"_s }, - Message { - u"Tumbler: attached properties of Tumbler must be accessed through a delegate item"_s }, Message { u"SwipeDelegate attached property must be attached to an object deriving from Item"_s }, Message { u"SwipeView attached property must be attached to an object deriving from Item"_s } } }); + { + const Result result{ {}, { Message{ u"Tumbler"_s }, }, }; + runTest("pluginQuick_tumblerGood.qml", result); + } + runTest("pluginQuick_swipeDelegate.qml", Result { { Message {