forked from qt-creator/qt-creator
QmlDesigner: Introduction of PropertyMetaInfo
Because the project storage is integer id based the string based API isn't fitting well for the new approach. PropertyMetaInfo can be easier mapped to the project storage. Task-number: QDS-7197 Change-Id: I49bc650abdaacf4b039d76c2514b5ad05ec84abe Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -143,6 +143,8 @@ void ActionEditor::setModelNode(const ModelNode &modelNode)
|
||||
m_modelNode = modelNode;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool isLiteral(QmlJS::AST::Node *ast)
|
||||
{
|
||||
if (QmlJS::AST::cast<QmlJS::AST::StringLiteral *>(ast)
|
||||
@@ -154,6 +156,17 @@ bool isLiteral(QmlJS::AST::Node *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
TypeName skipCpp(TypeName typeName)
|
||||
{
|
||||
// TODO remove after project storage introduction
|
||||
|
||||
if (typeName.contains("<cpp>."))
|
||||
typeName.remove(0, 6);
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
void ActionEditor::prepareConnections()
|
||||
{
|
||||
if (!m_modelNode.isValid())
|
||||
@@ -197,17 +210,15 @@ void ActionEditor::prepareConnections()
|
||||
|
||||
ActionEditorDialog::ConnectionOption connection(modelNode.id());
|
||||
|
||||
for (const auto &propertyName : modelNode.metaInfo().propertyNames()) {
|
||||
if (!typeWhiteList.contains(modelNode.metaInfo().propertyTypeName(propertyName)))
|
||||
for (const auto &property : modelNode.metaInfo().properties()) {
|
||||
const auto &propertyTypeName = property.propertyTypeName();
|
||||
if (!typeWhiteList.contains(propertyTypeName))
|
||||
continue;
|
||||
|
||||
const QString name = QString::fromUtf8(propertyName);
|
||||
const bool writeable = modelNode.metaInfo().propertyIsWritable(propertyName);
|
||||
TypeName type = modelNode.metaInfo().propertyTypeName(propertyName);
|
||||
if (type.contains("<cpp>."))
|
||||
type.remove(0, 6);
|
||||
|
||||
connection.properties.append(ActionEditorDialog::PropertyOption(name, type, writeable));
|
||||
connection.properties.append(
|
||||
ActionEditorDialog::PropertyOption(QString::fromUtf8(property.name()),
|
||||
skipCpp(std::move(propertyTypeName)),
|
||||
property.isWritable()));
|
||||
}
|
||||
|
||||
for (const VariantProperty &variantProperty : modelNode.variantProperties()) {
|
||||
@@ -216,12 +227,12 @@ void ActionEditor::prepareConnections()
|
||||
continue;
|
||||
|
||||
const QString name = QString::fromUtf8(variantProperty.name());
|
||||
const bool writeable = modelNode.metaInfo().propertyIsWritable(variantProperty.name());
|
||||
TypeName type = variantProperty.dynamicTypeName();
|
||||
if (type.contains("<cpp>."))
|
||||
type.remove(0, 6);
|
||||
const bool writeable = modelNode.metaInfo().property(variantProperty.name()).isWritable();
|
||||
|
||||
connection.properties.append(ActionEditorDialog::PropertyOption(name, type, writeable));
|
||||
connection.properties.append(
|
||||
ActionEditorDialog::PropertyOption(name,
|
||||
skipCpp(variantProperty.dynamicTypeName()),
|
||||
writeable));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,18 +270,16 @@ void ActionEditor::prepareConnections()
|
||||
NodeMetaInfo metaInfo = m_modelNode.view()->model()->metaInfo(data.typeName.toUtf8());
|
||||
if (metaInfo.isValid()) {
|
||||
ActionEditorDialog::SingletonOption singelton;
|
||||
for (const PropertyName &propertyName : metaInfo.propertyNames()) {
|
||||
TypeName type = metaInfo.propertyTypeName(propertyName);
|
||||
for (const auto &property : metaInfo.properties()) {
|
||||
const TypeName &typeName = property.propertyTypeName();
|
||||
|
||||
if (!typeWhiteList.contains(type))
|
||||
if (!typeWhiteList.contains(typeName))
|
||||
continue;
|
||||
|
||||
const QString name = QString::fromUtf8(propertyName);
|
||||
const bool writeable = metaInfo.propertyIsWritable(propertyName);
|
||||
if (type.contains("<cpp>."))
|
||||
type.remove(0, 6);
|
||||
|
||||
singelton.properties.append(ActionEditorDialog::PropertyOption(name, type, writeable));
|
||||
singelton.properties.append(
|
||||
ActionEditorDialog::PropertyOption(QString::fromUtf8(property.name()),
|
||||
skipCpp(typeName),
|
||||
property.isWritable()));
|
||||
}
|
||||
|
||||
if (!singelton.properties.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user