From da36459759414c582fbc3bb65f4b9edc28fdc34a Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 24 Aug 2022 13:11:33 +0200 Subject: QmlDesigner: Refactor isSubClass IsSubClass is renamed to isBasedOn and takes now NodeMetaInfo as a parameter. But for most cases there are is... functions as short cut. The model is providing shortcut NodeMetaInfos too. This is done in the sake of caching. Task-number: QDS-7445 Change-Id: Iff2dea66e253b412105427134bd49cb16ed76193 Reviewed-by: Tim Jenssen Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: Thomas Hartmann --- .../mockup/qmldesigner/designercore/include/nodemetainfo.h | 12 ++++++++++-- tests/unit/unittest/projectstorage-test.cpp | 14 +++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h b/tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h index 789b1f7f63..9a35096103 100644 --- a/tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h +++ b/tests/unit/mockup/qmldesigner/designercore/include/nodemetainfo.h @@ -47,7 +47,6 @@ public: std::vector classHierarchy() const { return {}; } std::vector superClasses() const { return {}; } - NodeMetaInfo directSuperClass() const { return {}; } bool defaultPropertyIsComponent() const { return {}; } @@ -62,12 +61,21 @@ public: bool hasCustomParser() const { return {}; } bool availableInVersion(int, int) const { return {}; } - bool isSubclassOf(const TypeName &, int = -1, int = -1) const { return {}; } + bool isBasedOn(const NodeMetaInfo &) const { return {}; } + bool isBasedOn(const NodeMetaInfo &, const NodeMetaInfo &) const { return {}; } + bool isBasedOn(const NodeMetaInfo &, const NodeMetaInfo &, const NodeMetaInfo &) const + { + return {}; + } bool isGraphicalItem() const { return {}; } bool isLayoutable() const { return {}; } bool isView() const { return {}; } bool isTabView() const { return {}; } + bool isQtQuick3DNode() const { return {}; } + bool isQtQuick3DModel() const { return {}; } + bool isQtQuick3DMaterial() const { return {}; } + bool isQtQuickLoader() const { return {}; } QString importDirectoryPath() const { return {}; } diff --git a/tests/unit/unittest/projectstorage-test.cpp b/tests/unit/unittest/projectstorage-test.cpp index 6bc7e50fa8..ebfff84034 100644 --- a/tests/unit/unittest/projectstorage-test.cpp +++ b/tests/unit/unittest/projectstorage-test.cpp @@ -6792,7 +6792,7 @@ TEST_F(ProjectStorage, GetPrototypeAndSelfIdsWithExtension) fetchTypeId(sourceId1, "QObject"))); } -TEST_F(ProjectStorage, IsBaseOfForDirectPrototype) +TEST_F(ProjectStorage, IsBasedOnForDirectPrototype) { auto package{createPackageWithProperties()}; storage.synchronize(package); @@ -6805,7 +6805,7 @@ TEST_F(ProjectStorage, IsBaseOfForDirectPrototype) ASSERT_TRUE(isBasedOn); } -TEST_F(ProjectStorage, IsBaseOfForIndirectPrototype) +TEST_F(ProjectStorage, IsBasedOnForIndirectPrototype) { auto package{createPackageWithProperties()}; storage.synchronize(package); @@ -6817,7 +6817,7 @@ TEST_F(ProjectStorage, IsBaseOfForIndirectPrototype) ASSERT_TRUE(isBasedOn); } -TEST_F(ProjectStorage, IsBaseOfForDirectExtension) +TEST_F(ProjectStorage, IsBasedOnForDirectExtension) { auto package{createPackageWithProperties()}; std::swap(package.types[1].extension, package.types[1].prototype); @@ -6830,7 +6830,7 @@ TEST_F(ProjectStorage, IsBaseOfForDirectExtension) ASSERT_TRUE(isBasedOn); } -TEST_F(ProjectStorage, IsBaseOfForIndirectExtension) +TEST_F(ProjectStorage, IsBasedOnForIndirectExtension) { auto package{createPackageWithProperties()}; std::swap(package.types[1].extension, package.types[1].prototype); @@ -6843,7 +6843,7 @@ TEST_F(ProjectStorage, IsBaseOfForIndirectExtension) ASSERT_TRUE(isBasedOn); } -TEST_F(ProjectStorage, IsBaseOfForSelf) +TEST_F(ProjectStorage, IsBasedOnForSelf) { auto package{createPackageWithProperties()}; storage.synchronize(package); @@ -6855,7 +6855,7 @@ TEST_F(ProjectStorage, IsBaseOfForSelf) ASSERT_TRUE(isBasedOn); } -TEST_F(ProjectStorage, IsNotBaseOf) +TEST_F(ProjectStorage, IsNotBasedOn) { auto package{createPackageWithProperties()}; storage.synchronize(package); @@ -6868,7 +6868,7 @@ TEST_F(ProjectStorage, IsNotBaseOf) ASSERT_FALSE(isBasedOn); } -TEST_F(ProjectStorage, IsNotBaseOfIfNoBaseTypeIsGiven) +TEST_F(ProjectStorage, IsNotBasedOnIfNoBaseTypeIsGiven) { auto package{createPackageWithProperties()}; storage.synchronize(package); -- cgit v1.2.1