Fix QmltcTests compilation when tableview or gridview is disabled

Put two of the QML files behind appropriate feature flags (they
use TableView and GridView). Similarly guard the cpp side
includes and access to the genrated QML type.

As a drive-by add include guard when qml-table-model is disabled.

Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: Ic643ccb3f8346fc650afe5d863b575e8cec2f57a
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
This commit is contained in:
Juha Vuolle 2025-04-25 10:34:59 +03:00
parent f4c2eeac6a
commit cc98876fea
3 changed files with 22 additions and 2 deletions

View File

@ -33,9 +33,7 @@ set(qml_sources
simpleQtQuickTypes.qml simpleQtQuickTypes.qml
typeWithEnums.qml typeWithEnums.qml
methods.qml methods.qml
properties.qml
ObjectWithId.qml ObjectWithId.qml
documentWithIds.qml
importNamespace.qml importNamespace.qml
gradients.qml gradients.qml
qjsvalueAssignments.qml qjsvalueAssignments.qml
@ -161,6 +159,13 @@ set(common_libraries
Qt::Gui # QColor, QMatrix4x4, ... Qt::Gui # QColor, QMatrix4x4, ...
) )
if(QT_FEATURE_quick_tableview)
list(APPEND qml_sources properties.qml)
if(QT_FEATURE_quick_gridview)
list(APPEND qml_sources documentWithIds.qml)
endif()
endif()
if (QT_FEATURE_qml_table_model) if (QT_FEATURE_qml_table_model)
list(APPEND qml_sources QmlTableModel.qml) list(APPEND qml_sources QmlTableModel.qml)
list(APPEND common_libraries Qt::LabsQmlModelsPrivate) list(APPEND common_libraries Qt::LabsQmlModelsPrivate)

View File

@ -9,9 +9,13 @@
#include "simpleqtquicktypes.h" #include "simpleqtquicktypes.h"
#include "typewithenums.h" #include "typewithenums.h"
#include "methods.h" #include "methods.h"
#if QT_CONFIG(quick_tableview)
#include "properties.h" #include "properties.h"
#endif
#include "objectwithid.h" #include "objectwithid.h"
#if QT_CONFIG(quick_gridview)
#include "documentwithids.h" #include "documentwithids.h"
#endif
#include "importnamespace.h" #include "importnamespace.h"
#include "deferredproperties.h" #include "deferredproperties.h"
#include "deferredproperties_group.h" #include "deferredproperties_group.h"
@ -87,7 +91,9 @@
#include "mysignals.h" #include "mysignals.h"
#include "namespacedtypes.h" #include "namespacedtypes.h"
#include "type.h" #include "type.h"
#if QT_CONFIG(qml_table_model)
#include "qmltablemodel.h" #include "qmltablemodel.h"
#endif
#include "stringtourl.h" #include "stringtourl.h"
#include "signalconnections.h" #include "signalconnections.h"
#include "requiredproperties.h" #include "requiredproperties.h"
@ -334,6 +340,7 @@ void tst_qmltc::methods()
QCOMPARE(metaTypedMethod.parameterNames(), QList<QByteArray>({ "a", "b" })); QCOMPARE(metaTypedMethod.parameterNames(), QList<QByteArray>({ "a", "b" }));
} }
#if QT_CONFIG(quick_tableview)
void tst_qmltc::properties() void tst_qmltc::properties()
{ {
QQmlEngine e; QQmlEngine e;
@ -478,7 +485,9 @@ void tst_qmltc::properties()
QVERIFY(sentinelForComponent); QVERIFY(sentinelForComponent);
QCOMPARE(sentinelForComponent->property("text").toString(), u"should be correctly created"_s); QCOMPARE(sentinelForComponent->property("text").toString(), u"should be correctly created"_s);
} }
#endif // QT_CONFIG(quick_tableview)
#if QT_CONFIG(quick_tableview) && QT_CONFIG(quick_gridview)
void tst_qmltc::ids() void tst_qmltc::ids()
{ {
{ {
@ -575,6 +584,7 @@ void tst_qmltc::ids()
verifyComponent(afterChild, QString(), u"afterDelegateDefaultPropertyText"_s); verifyComponent(afterChild, QString(), u"afterDelegateDefaultPropertyText"_s);
} }
} }
#endif // QT_CONFIG(quick_tableview) && QT_CONFIG(quick_gridview)
void tst_qmltc::importNamespace() void tst_qmltc::importNamespace()
{ {

View File

@ -3,6 +3,7 @@
#include <qtest.h> #include <qtest.h>
#include <private/qtqmlmodelsglobal_p.h> #include <private/qtqmlmodelsglobal_p.h>
#include <private/qtquick-config_p.h> // For feature definitions
using namespace Qt::StringLiterals; using namespace Qt::StringLiterals;
@ -27,8 +28,12 @@ private slots:
void qtQuickIncludes(); void qtQuickIncludes();
void enumerations(); void enumerations();
void methods(); void methods();
#if QT_CONFIG(quick_tableview)
void properties(); void properties();
#if QT_CONFIG(quick_gridview)
void ids(); void ids();
#endif
#endif
void importNamespace(); void importNamespace();
void deferredProperties(); void deferredProperties();
void gradients(); // QTBUG-102560 void gradients(); // QTBUG-102560