diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-06-22 02:23:25 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-06-22 02:23:25 (GMT) |
commit | 84a4a2ed1b17dd8d73404f52af032b959aada8b1 (patch) | |
tree | 82567474b3db63f194fb6c4d09bacbb186fa8766 /src/declarative/util/qdeclarativelistmodel.cpp | |
parent | 02c83c2adf0513041d9a3866d4e589ad79d61bda (diff) | |
download | Qt-84a4a2ed1b17dd8d73404f52af032b959aada8b1.zip Qt-84a4a2ed1b17dd8d73404f52af032b959aada8b1.tar.gz Qt-84a4a2ed1b17dd8d73404f52af032b959aada8b1.tar.bz2 |
Allow QT_TR_NOOP (as a no-op) in ListModel values.
Task-number: QTBUG-11403
Diffstat (limited to 'src/declarative/util/qdeclarativelistmodel.cpp')
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index ff83227..9ed21a6 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -81,8 +81,8 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM 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). + Values must be simple constants - either strings (quoted and optionally within a call to QT_TR_NOOP), + bools (true, false), numbers, or enum values (like Text.AlignHCenter). The defined model can be used in views such as ListView: @@ -620,8 +620,13 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser 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; + if (script.startsWith("QT_TR_NOOP(\"") && script.endsWith("\")")) { + d[0] = char(QDeclarativeParser::Variant::String); + d += script.mid(12,script.length()-14); + } else { + error(prop, QDeclarativeListModel::tr("ListElement: cannot use script for property value")); + return false; + } } else { d[0] = char(QDeclarativeParser::Variant::Number); d += QByteArray::number(v); |