summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2022-08-15 15:21:23 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2022-08-26 12:15:58 +0000
commit0982e668e7d7a5528808ab08cec1191745d7b6e3 (patch)
tree4be1f5f03b8da8cdb9d18846d9e9d2d29ec34635 /src
parent8a29c7da2fdc307e6076c4f672749a03b79dd581 (diff)
downloadqt-creator-0982e668e7d7a5528808ab08cec1191745d7b6e3.tar.gz
QmlDesigner: Add isBaseOf to project storage
It return true if it is the same or a derived type. You can use multiple base types. Task-number: QDS-7424 Change-Id: I965a7c5b87ef0eb0183be1c705ebc18dee1943c3 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/sqlite/sqlitebasestatement.h1
-rw-r--r--src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h28
2 files changed, 24 insertions, 5 deletions
diff --git a/src/libs/sqlite/sqlitebasestatement.h b/src/libs/sqlite/sqlitebasestatement.h
index 1adfd70245..058bee2f05 100644
--- a/src/libs/sqlite/sqlitebasestatement.h
+++ b/src/libs/sqlite/sqlitebasestatement.h
@@ -469,6 +469,7 @@ private:
, column(column)
{}
+ explicit operator bool() const { return statement.fetchIntValue(column); }
operator int() const { return statement.fetchIntValue(column); }
operator long() const { return statement.fetchLongValue(column); }
operator long long() const { return statement.fetchLongLongValue(column); }
diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h
index 6afdedf6f6..752ad8fe84 100644
--- a/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h
+++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstorage.h
@@ -245,11 +245,17 @@ public:
.template valuesWithTransaction<TypeId>(16, type);
}
- PropertyDeclarationId fetchPropertyDeclarationByTypeIdAndName(TypeId typeId,
- Utils::SmallStringView name)
+ template<typename... TypeIds>
+ bool isBasedOn(TypeId typeId, TypeIds... baseTypeIds) const
{
- return selectPropertyDeclarationIdByTypeIdAndNameStatement
- .template valueWithTransaction<PropertyDeclarationId>(typeId, name);
+ auto range = selectPrototypeAndSelfIdsStatement.template rangeWithTransaction<TypeId>(typeId);
+
+ for (TypeId currentTypeId : range) {
+ if (((currentTypeId == baseTypeIds) || ...))
+ return true;
+ }
+
+ return false;
}
TypeId fetchTypeIdByExportedName(Utils::SmallStringView name) const
@@ -2635,7 +2641,6 @@ public:
"ORDER BY minorVersion DESC "
"LIMIT 1",
database};
-
mutable ReadStatement<1, 2> selectPrototypeIdStatement{
"WITH RECURSIVE "
" all_prototype_and_extension(typeId, prototypeId) AS ("
@@ -3259,6 +3264,19 @@ public:
" typeChain AS tc USING(typeId)) "
"SELECT typeId FROM typeChain ORDER BY level",
database};
+ mutable ReadStatement<1, 1> selectPrototypeAndSelfIdsStatement{
+ "WITH RECURSIVE "
+ " all_prototype_and_extension(typeId, prototypeId) AS ("
+ " SELECT typeId, prototypeId FROM types WHERE prototypeId IS NOT NULL"
+ " UNION ALL "
+ " SELECT typeId, extensionId FROM types WHERE extensionId IS NOT NULL),"
+ " typeSelection(typeId) AS ("
+ " VALUES(?1) "
+ " UNION ALL "
+ " SELECT prototypeId FROM all_prototype_and_extension JOIN typeSelection "
+ " USING(typeId))"
+ "SELECT typeId FROM typeSelection",
+ database};
};
extern template class ProjectStorage<Sqlite::Database>;
} // namespace QmlDesigner