From: Michael Brasser Date: Wed, 31 Aug 2011 04:07:32 +0000 (+1000) Subject: Support QT_TRID_NOOP in ListElement. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=05daa9bfe1a03ffe1cc580b6cfd88e093e2493c0;p=konrad%2Fqtdeclarative.git Support QT_TRID_NOOP in ListElement. Task-number: QTBUG-21070 Change-Id: I91f68467ed96c89fe18726372348ebe809099f60 Reviewed-on: http://codereview.qt.nokia.com/3906 Reviewed-by: Qt Sanity Bot Reviewed-by: Charles Yin --- diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 2b113ab..3add850 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -847,11 +847,11 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser AST::StringLiteral *literal = 0; if (AST::CallExpression *callExpr = AST::cast(node)) { if (AST::IdentifierExpression *idExpr = AST::cast(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(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")) { diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 946a3a5..0c3b75a 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -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()