summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qdeclarativelistmodel.cpp
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2010-03-17 07:22:45 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2010-03-17 07:22:45 (GMT)
commit41b5a39aa3749ce95fa581236da0404f58672ca7 (patch)
tree198c44b2cad7ae8de4046b2cb55be8243c0f308e /src/declarative/util/qdeclarativelistmodel.cpp
parent2637e50d25d6b025b687760c90aed36529b8c918 (diff)
parent0dcdcac2898c5978ea3250ed2627a9e47dd86d96 (diff)
downloadQt-41b5a39aa3749ce95fa581236da0404f58672ca7.zip
Qt-41b5a39aa3749ce95fa581236da0404f58672ca7.tar.gz
Qt-41b5a39aa3749ce95fa581236da0404f58672ca7.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative/util/qdeclarativelistmodel.cpp')
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 45a3cf7..5b0a7ea 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -94,9 +94,12 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM
}
\endcode
- Roles (properties) must begin with a lower-case letter. The above example defines a
+ Roles (properties) must begin with a lower-case letter.The above example defines a
ListModel containing three elements, with the roles "name" and "cost".
+ Values must be simple constants - either strings (quoted), bools (true, false), numbers,
+ or enum values (like Text.AlignHCenter).
+
The defined model can be used in views such as ListView:
\code
Component {
@@ -167,6 +170,8 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM
}
\endcode
+ \section2 Modifying list models
+
The content of a ListModel may be created and modified using the clear(),
append(), and set() methods. For example:
@@ -676,10 +681,17 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
d += char(variant.asBoolean());
} else if (variant.isScript()) {
if (definesEmptyList(variant.asScript())) {
- d[0] = 0; // QDeclarativeParser::Variant::Invalid - marks empty list
+ d[0] = char(QDeclarativeParser::Variant::Invalid); // marks empty list
} else {
- error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value"));
- return false;
+ QByteArray script = variant.asScript().toUtf8();
+ int v = evaluateEnum(script);
+ if (v<0) {
+ error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value"));
+ return false;
+ } else {
+ d[0] = char(QDeclarativeParser::Variant::Number);
+ d += QByteArray::number(v);
+ }
}
}
d.append('\0');