Commit 7226937c authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.model resolving of lists in bindings

parent 9e7c1372
......@@ -54,6 +54,8 @@ public:
ModelNode resolveToModelNode() const;
AbstractProperty resolveToProperty() const;
bool isList() const;
QList<ModelNode> resolveToModelNodeList() const;
protected:
BindingProperty(const QString &propertyName, const Internal::InternalNodePointer &internalNode, Model* model, AbstractView *view);
......
......@@ -136,6 +136,16 @@ ModelNode BindingProperty::resolveToModelNode() const
return resolveBinding(expression(), parentModelNode(), view());
}
static inline QStringList commaSeparatedSimplifiedStringList(const QString &string)
{
QStringList stringList = string.split(QLatin1String(","));
QStringList simpleList;
foreach (const QString &simpleString, stringList)
simpleList.append(simpleString.simplified());
return simpleList;
}
AbstractProperty BindingProperty::resolveToProperty() const
{
if (!isValid())
......@@ -159,6 +169,33 @@ AbstractProperty BindingProperty::resolveToProperty() const
return AbstractProperty();
}
bool BindingProperty::isList() const
{
if (!isValid())
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
return expression().startsWith('[') && expression().endsWith(']');
}
QList<ModelNode> BindingProperty::resolveToModelNodeList() const
{
QList<ModelNode> returnList;
if (!isValid())
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (isList()) {
QString string = expression();
string.chop(1);
string.remove(0, 1);
QStringList simplifiedList = commaSeparatedSimplifiedStringList(string);
foreach (const QString &nodeId, simplifiedList) {
ModelNode modelNode = view()->modelNodeForId(nodeId);
if (modelNode.isValid())
returnList.append(modelNode);
}
}
return returnList;
}
void BindingProperty::setDynamicTypeNameAndExpression(const QString &typeName, const QString &expression)
{
......
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