Commit 699ff228 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.Model: check ids for qml keywords

ids are now checked if they are a qml keyword
parent 2e80355e
...@@ -160,6 +160,15 @@ QString ModelNode::validId() ...@@ -160,6 +160,15 @@ QString ModelNode::validId()
return id(); return id();
} }
static bool idIsQmlKeyWord(const QString& id)
{
QStringList keywords;
keywords << "import" << "property" << "signal"
<< "as" << "on" << "list";
return keywords.contains(id);
}
static bool idContainsWrongLetter(const QString& id) static bool idContainsWrongLetter(const QString& id)
{ {
static QRegExp idExpr(QLatin1String("[a-z][a-zA-Z0-9_]*")); static QRegExp idExpr(QLatin1String("[a-z][a-zA-Z0-9_]*"));
...@@ -168,7 +177,7 @@ static bool idContainsWrongLetter(const QString& id) ...@@ -168,7 +177,7 @@ static bool idContainsWrongLetter(const QString& id)
bool ModelNode::isValidId(const QString &id) bool ModelNode::isValidId(const QString &id)
{ {
return id.isEmpty() || !idContainsWrongLetter(id); return id.isEmpty() || (!idContainsWrongLetter(id) && !idIsQmlKeyWord(id));
} }
void ModelNode::setId(const QString& id) void ModelNode::setId(const QString& id)
......
Supports Markdown
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