Support QT_TRID_NOOP in ListElement.
authorMichael Brasser <michael.brasser@nokia.com>
Wed, 31 Aug 2011 04:07:32 +0000 (14:07 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 31 Aug 2011 05:04:25 +0000 (07:04 +0200)
Task-number: QTBUG-21070
Change-Id: I91f68467ed96c89fe18726372348ebe809099f60
Reviewed-on: http://codereview.qt.nokia.com/3906
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Charles Yin <charles.yin@nokia.com>
src/declarative/util/qdeclarativelistmodel.cpp
tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp

index 2b113ab..3add850 100644 (file)
@@ -847,11 +847,11 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
                         AST::StringLiteral *literal = 0;
                         if (AST::CallExpression *callExpr = AST::cast<AST::CallExpression *>(node)) {
                             if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(callExpr->base)) {
-                                if (idExpr->name == QLatin1String("QT_TR_NOOP")) {
+                                if (idExpr->name == QLatin1String("QT_TR_NOOP") || idExpr->name == QLatin1String("QT_TRID_NOOP")) {
                                     if (callExpr->arguments && !callExpr->arguments->next)
                                         literal = AST::cast<AST::StringLiteral *>(callExpr->arguments->expression);
                                     if (!literal) {
-                                        error(prop, QDeclarativeListModel::tr("ListElement: improperly specified QT_TR_NOOP"));
+                                        error(prop, QDeclarativeListModel::tr("ListElement: improperly specified %1").arg(idExpr->name.toString()));
                                         return false;
                                     }
                                 } else if (idExpr->name == QLatin1String("QT_TRANSLATE_NOOP")) {
index 946a3a5..0c3b75a 100644 (file)
@@ -219,6 +219,11 @@ void tst_qdeclarativelistmodel::static_i18n_data()
         << QVariant(QString("hello"))
         << QString();
 
+    QTest::newRow("QT_TRID_NOOP")
+        << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP(\"qtn_1st_text\") }")
+        << QVariant(QString("qtn_1st_text"))
+        << QString();
+
     QTest::newRow("QT_TR_NOOP extra param")
             << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"hello\",\"world\") }")
             << QVariant(QString())
@@ -228,6 +233,11 @@ void tst_qdeclarativelistmodel::static_i18n_data()
         << "ListElement { foo: QT_TRANSLATE_NOOP() }"
         << QVariant(QString())
         << QString("ListElement: improperly specified QT_TRANSLATE_NOOP");
+
+    QTest::newRow("QT_TRID_NOOP missing param")
+        << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP() }")
+        << QVariant(QString())
+        << QString("ListElement: improperly specified QT_TRID_NOOP");
 }
 
 void tst_qdeclarativelistmodel::static_i18n()