diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-01-20 03:18:58 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-01-20 03:19:25 (GMT) |
commit | f95956a6cc61d0c05d96e2f8027167f51ed7dbea (patch) | |
tree | a8120cb448ca77bca7a8cbfe8dc4fc16204dea8b | |
parent | a7506ce64ae9e80a202e0ffdaa86785d1d117c78 (diff) | |
download | Qt-f95956a6cc61d0c05d96e2f8027167f51ed7dbea.zip Qt-f95956a6cc61d0c05d96e2f8027167f51ed7dbea.tar.gz Qt-f95956a6cc61d0c05d96e2f8027167f51ed7dbea.tar.bz2 |
Revert previous change. Does not work for statically defined list models.
This reverts commit bc6940f53891856a3a6c3d8f1c25a8eaada90b33.
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 45 | ||||
-rw-r--r-- | tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp | 5 |
2 files changed, 20 insertions, 30 deletions
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index cd4a120..de6ee2e 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -265,7 +265,6 @@ struct ModelNode QmlListModel *modelCache; ModelObject *objectCache; - bool isArray; }; QT_END_NAMESPACE @@ -281,7 +280,6 @@ void ModelNode::setObjectValue(const QScriptValue& valuemap) { ModelNode *value = new ModelNode; QScriptValue v = it.value(); if (v.isArray()) { - value->isArray = true; value->setListValue(v); } else { value->values << v.toVariant(); @@ -298,7 +296,6 @@ void ModelNode::setListValue(const QScriptValue& valuelist) { ModelNode *value = new ModelNode; QScriptValue v = it.value(); if (v.isArray()) { - value->isArray = true; value->setListValue(v); } else if (v.isObject()) { value->setObjectValue(v); @@ -370,29 +367,27 @@ QVariant QmlListModel::valueForNode(ModelNode *node) const { QObject *rv = 0; - if (node->isArray) { + if (!node->properties.isEmpty()) { + // Object + rv = node->object(this); + } else if (node->values.count() == 0) { + // Invalid + return QVariant(); + } else if (node->values.count() == 1) { + // Value + QVariant &var = node->values[0]; + ModelNode *valueNode = qvariant_cast<ModelNode *>(var); + if (valueNode) { + if (!valueNode->properties.isEmpty()) + rv = valueNode->object(this); + else + rv = valueNode->model(this); + } else { + return var; + } + } else if (node->values.count() > 1) { // List rv = node->model(this); - } else { - if (!node->properties.isEmpty()) { - // Object - rv = node->object(this); - } else if (node->values.count() == 0) { - // Invalid - return QVariant(); - } else if (node->values.count() == 1) { - // Value - QVariant &var = node->values[0]; - ModelNode *valueNode = qvariant_cast<ModelNode *>(var); - if (valueNode) { - if (!valueNode->properties.isEmpty()) - rv = valueNode->object(this); - else - rv = valueNode->model(this); - } else { - return var; - } - } } if (rv) @@ -938,7 +933,7 @@ static void dump(ModelNode *node, int ind) } ModelNode::ModelNode() -: modelCache(0), objectCache(0), isArray(false) +: modelCache(0), objectCache(0) { } diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index b43b699..0986d20 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -150,12 +150,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("listprop1a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << ""; QTest::newRow("listprop1b") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << ""; - QTest::newRow("listprop1c") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.count}" << 3 << ""; QTest::newRow("listprop2a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << ""; - - QTest::newRow("list-0-items") << "{append({'foo':[]});get(0).foo.count}" << 0 << ""; - QTest::newRow("list-1-item") << "{append({'foo':[1]});get(0).foo.count}" << 1 << ""; - QTest::newRow("list-multi-items") << "{append({'foo':[1,2,3]});get(0).foo.count}" << 3 << ""; } void tst_QmlListModel::dynamic() |