Commit e012e42f authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Tim Jenssen
Browse files

QmlDesigner: Do not allow certain ids



Some ids are likely to create issues, because they collide
with property names.

Change-Id: I688ed0751c227afdd3ef59ba0f31b1334b26eaea
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 99aaf86a
......@@ -179,6 +179,42 @@ static bool idIsQmlKeyWord(const QString& id)
return keywords.contains(id);
}
static bool isIdToAvoid(const QString& id)
{
static const QSet<QString> ids = {
"top",
"bottom",
"left",
"right",
"width",
"height",
"x",
"y",
"opacity",
"parent",
"item",
"flow",
"color",
"margin",
"padding",
"border",
"font",
"text",
"source",
"state",
"visible",
"focus",
"data",
"clip",
"layer",
"scale",
"enabled",
"anchors"
};
return ids.contains(id);
}
static bool idContainsWrongLetter(const QString& id)
{
static QRegExp idExpr(QStringLiteral("[a-z_][a-zA-Z0-9_]*"));
......@@ -187,7 +223,7 @@ static bool idContainsWrongLetter(const QString& id)
bool ModelNode::isValidId(const QString &id)
{
return id.isEmpty() || (!idContainsWrongLetter(id) && !idIsQmlKeyWord(id));
return id.isEmpty() || (!idContainsWrongLetter(id) && !idIsQmlKeyWord(id)) && !isIdToAvoid(id);
}
bool ModelNode::hasId() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment