forked from qt-creator/qt-creator
QmlDesigner: Provide TypeTraits for type getter
The type traits contains already information like if the file is a file component etc.. Task-number: QDS-7327 Change-Id: I7713840fd1107046e8a6710c0ca493dc54edf823 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -3095,8 +3095,8 @@ public:
|
||||
"UPDATE types SET defaultPropertyId=?2 WHERE typeId=?1", database};
|
||||
WriteStatement<1> updateDefaultPropertyIdToNullStatement{
|
||||
"UPDATE types SET defaultPropertyId=NULL WHERE defaultPropertyId=?1", database};
|
||||
mutable ReadStatement<1, 1> selectInfoTypeByTypeIdStatement{
|
||||
"SELECT defaultPropertyId FROM types WHERE typeId=?", database};
|
||||
mutable ReadStatement<2, 1> selectInfoTypeByTypeIdStatement{
|
||||
"SELECT defaultPropertyId, traits FROM types WHERE typeId=?", database};
|
||||
};
|
||||
extern template class ProjectStorage<Sqlite::Database>;
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -936,11 +936,13 @@ public:
|
||||
class Type
|
||||
{
|
||||
public:
|
||||
Type(PropertyDeclarationId defaultPropertyId)
|
||||
Type(PropertyDeclarationId defaultPropertyId, TypeTraits traits)
|
||||
: defaultPropertyId{defaultPropertyId}
|
||||
, traits{traits}
|
||||
{}
|
||||
|
||||
PropertyDeclarationId defaultPropertyId;
|
||||
TypeTraits traits;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner::Storage::Info
|
||||
|
@@ -246,14 +246,15 @@ MATCHER(StringsAreSorted, std::string(negation ? "isn't sorted" : "is sorted"))
|
||||
});
|
||||
}
|
||||
|
||||
MATCHER_P(IsInfoType,
|
||||
MATCHER_P2(IsInfoType,
|
||||
defaultPropertyId,
|
||||
traits,
|
||||
std::string(negation ? "isn't " : "is ")
|
||||
+ PrintToString(Storage::Info::Type{defaultPropertyId}))
|
||||
+ PrintToString(Storage::Info::Type{defaultPropertyId, traits}))
|
||||
{
|
||||
const Storage::Info::Type &type = arg;
|
||||
|
||||
return type.defaultPropertyId == defaultPropertyId;
|
||||
return type.defaultPropertyId == defaultPropertyId && type.traits == traits;
|
||||
}
|
||||
|
||||
class ProjectStorage : public testing::Test
|
||||
@@ -5874,7 +5875,7 @@ TEST_F(ProjectStorage, GetType)
|
||||
|
||||
auto type = storage.type(typeId);
|
||||
|
||||
ASSERT_THAT(type, Optional(IsInfoType(defaultPropertyId)));
|
||||
ASSERT_THAT(type, Optional(IsInfoType(defaultPropertyId, TypeTraits::Reference)));
|
||||
}
|
||||
|
||||
TEST_F(ProjectStorage, DontGetTypeForInvalidId)
|
||||
|
Reference in New Issue
Block a user