From d71db342a34690438878684f054dca820f77b1b9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 13 Oct 2009 09:48:25 +1000 Subject: Fix UTF8 vs. Latin1 conversion I18n tests --- src/declarative/qml/qmlengine.cpp | 2 +- tests/auto/declarative/qmllanguage/data/I18n.qml | 6 ++--- ...8n\303\201\303\242\303\243\303\244\303\245.qml" | 5 +++-- .../qmllanguage/data/i18nDeclaredPropertyNames.qml | 6 ++--- .../qmllanguage/data/i18nDeclaredPropertyUse.qml | 2 -- .../declarative/qmllanguage/data/i18nScript.qml | 8 +++---- .../declarative/qmllanguage/data/i18nStrings.qml | 6 ++--- .../auto/declarative/qmllanguage/data/i18nType.qml | 6 +---- .../declarative/qmllanguage/tst_qmllanguage.cpp | 26 ++++++++++++++++++++++ 9 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 245ddc0..ef0f975 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1106,7 +1106,7 @@ public: } } if (url_return) { - *url_return = base.resolved(QUrl(QLatin1String(type + ".qml"))); + *url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml"))); return true; } else { return false; diff --git a/tests/auto/declarative/qmllanguage/data/I18n.qml b/tests/auto/declarative/qmllanguage/data/I18n.qml index dbbd4bd..558c836 100644 --- a/tests/auto/declarative/qmllanguage/data/I18n.qml +++ b/tests/auto/declarative/qmllanguage/data/I18n.qml @@ -1,6 +1,6 @@ -import Qt 4.6 +import Test 1.0 -Text { +MyTypeObject { property int áâãäå: 10 - text: "Test áâãäå: " + áâãäå + stringProperty: "Test áâãäå: " + áâãäå } diff --git "a/tests/auto/declarative/qmllanguage/data/I18n\303\201\303\242\303\243\303\244\303\245.qml" "b/tests/auto/declarative/qmllanguage/data/I18n\303\201\303\242\303\243\303\244\303\245.qml" index 6a841d1..42dbc69 100644 --- "a/tests/auto/declarative/qmllanguage/data/I18n\303\201\303\242\303\243\303\244\303\245.qml" +++ "b/tests/auto/declarative/qmllanguage/data/I18n\303\201\303\242\303\243\303\244\303\245.qml" @@ -1,4 +1,5 @@ -import Qt 4.6 +import Test 1.0 -Text { +MyTypeObject { + stringProperty: "Test áâãäå: 30" } diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml index dbbd4bd..558c836 100644 --- a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml +++ b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyNames.qml @@ -1,6 +1,6 @@ -import Qt 4.6 +import Test 1.0 -Text { +MyTypeObject { property int áâãäå: 10 - text: "Test áâãäå: " + áâãäå + stringProperty: "Test áâãäå: " + áâãäå } diff --git a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml index 240d7c1..74918e2 100644 --- a/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml +++ b/tests/auto/declarative/qmllanguage/data/i18nDeclaredPropertyUse.qml @@ -1,5 +1,3 @@ -import Qt 4.6 - I18n { áâãäå: 15 } diff --git a/tests/auto/declarative/qmllanguage/data/i18nScript.qml b/tests/auto/declarative/qmllanguage/data/i18nScript.qml index 6d07b03..942ed90 100644 --- a/tests/auto/declarative/qmllanguage/data/i18nScript.qml +++ b/tests/auto/declarative/qmllanguage/data/i18nScript.qml @@ -1,12 +1,12 @@ -import Qt 4.6 +import Test 1.0 -Text { +MyTypeObject { Script { function val() { - var áâãäå = 10 + var áâãäå = 20 return "Test áâãäå: " + áâãäå } } - text: val() + stringProperty: val() } diff --git a/tests/auto/declarative/qmllanguage/data/i18nStrings.qml b/tests/auto/declarative/qmllanguage/data/i18nStrings.qml index 062191f..764c926 100644 --- a/tests/auto/declarative/qmllanguage/data/i18nStrings.qml +++ b/tests/auto/declarative/qmllanguage/data/i18nStrings.qml @@ -1,5 +1,5 @@ -import Qt 4.6 +import Test 1.0 -Text { - text: "Test áâãäå (5 accented 'a' letters)" +MyTypeObject { + stringProperty: "Test áâãäå (5 accented 'a' letters)" } diff --git a/tests/auto/declarative/qmllanguage/data/i18nType.qml b/tests/auto/declarative/qmllanguage/data/i18nType.qml index 1a73096..11ef895 100644 --- a/tests/auto/declarative/qmllanguage/data/i18nType.qml +++ b/tests/auto/declarative/qmllanguage/data/i18nType.qml @@ -1,5 +1 @@ -import Qt 4.6 - -I18nÁâãäå { - text: "TEST" -} +I18nÁâãäå { } diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index a991144..cf42792 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -58,6 +58,8 @@ private slots: void cppnamespace(); void aliasProperties(); void componentCompositeType(); + void i18n(); + void i18n_data(); void importsBuiltin_data(); void importsBuiltin(); @@ -679,6 +681,30 @@ public: TestType2(QObject *p=0) : QObject(p) {} }; +void tst_qmllanguage::i18n_data() +{ + QTest::addColumn("file"); + QTest::addColumn("stringProperty"); + QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test áâãäå (5 accented 'a' letters)"); + QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test áâãäå: 10"); + QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test áâãäå: 15"); + QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test áâãäå: 20"); + QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test áâãäå: 30"); +} + +void tst_qmllanguage::i18n() +{ + QFETCH(QString, file); + QFETCH(QString, stringProperty); + QmlComponent component(&engine, TEST_FILE(file)); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->stringProperty(), stringProperty); + + delete object; +} + // Check that first child of qml is of given type. Empty type insists on error. void tst_qmllanguage::testType(const QString& qml, const QString& type) { -- cgit v0.12 From 3b0c979986a692c58b6c72a284070e700c09b9c4 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 13 Oct 2009 11:14:36 +1000 Subject: Add autotest for overriding a signal handler in a state change. --- .../declarative/states/data/ExtendedRectangle.qml | 19 ++++++++ .../declarative/states/data/signalOverride.qml | 18 ++++++++ .../declarative/states/data/signalOverride2.qml | 9 ++++ tests/auto/declarative/states/tst_states.cpp | 51 ++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 tests/auto/declarative/states/data/ExtendedRectangle.qml create mode 100644 tests/auto/declarative/states/data/signalOverride.qml create mode 100644 tests/auto/declarative/states/data/signalOverride2.qml diff --git a/tests/auto/declarative/states/data/ExtendedRectangle.qml b/tests/auto/declarative/states/data/ExtendedRectangle.qml new file mode 100644 index 0000000..8d64663 --- /dev/null +++ b/tests/auto/declarative/states/data/ExtendedRectangle.qml @@ -0,0 +1,19 @@ +import Qt 4.6 +Rectangle { + id: extendedRect + objectName: "extendedRect" + property color extendedColor: "orange" + + width: 100; height: 100 + color: "red" + states: State { + name: "green" + PropertyChanges { + target: rect + onDidSomething: { + extendedRect.color = "green" + extendedColor = "green" + } + } + } +} diff --git a/tests/auto/declarative/states/data/signalOverride.qml b/tests/auto/declarative/states/data/signalOverride.qml new file mode 100644 index 0000000..5ba1566 --- /dev/null +++ b/tests/auto/declarative/states/data/signalOverride.qml @@ -0,0 +1,18 @@ +import Qt 4.6 +import Qt.test 1.0 + +MyRectangle { + id: rect + + onDidSomething: color = "blue" + + width: 100; height: 100 + color: "red" + states: State { + name: "green" + PropertyChanges { + target: rect + onDidSomething: color = "green" + } + } +} diff --git a/tests/auto/declarative/states/data/signalOverride2.qml b/tests/auto/declarative/states/data/signalOverride2.qml new file mode 100644 index 0000000..527e165 --- /dev/null +++ b/tests/auto/declarative/states/data/signalOverride2.qml @@ -0,0 +1,9 @@ +import Qt 4.6 +import Qt.test 1.0 + +MyRectangle { + id: rect + onDidSomething: color = "blue" + width: 100; height: 100 + ExtendedRectangle {} +} diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp index 3a61bd6..b2532a2 100644 --- a/tests/auto/declarative/states/tst_states.cpp +++ b/tests/auto/declarative/states/tst_states.cpp @@ -13,6 +13,7 @@ private slots: void basicChanges(); void basicExtension(); void basicBinding(); + void signalOverride(); }; void tst_states::basicChanges() @@ -262,6 +263,56 @@ void tst_states::basicBinding() } } +class MyRect : public QFxRect +{ + Q_OBJECT +public: + MyRect() {} + void doSomething() { emit didSomething(); } +Q_SIGNALS: + void didSomething(); +}; + +QML_DECLARE_TYPE(MyRect) +QML_DEFINE_TYPE(Qt.test, 1, 0, 0, MyRectangle,MyRect); + +void tst_states::signalOverride() +{ + QmlEngine engine; + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml"); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setState("green"); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("green")); + } + + { + QmlComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml"); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("white")); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + + QFxRect *innerRect = qobject_cast(rect->findChild("extendedRect")); + + innerRect->setState("green"); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(innerRect->color(),QColor("green")); + QCOMPARE(innerRect->property("extendedColor").value(),QColor("green")); + } +} + QTEST_MAIN(tst_states) #include "tst_states.moc" -- cgit v0.12 From d39b7ce65f051da342dcc931e303a73339288c5e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 13 Oct 2009 11:27:26 +1000 Subject: Make sure effects are still included. --- src/declarative/fx/qfxitem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 8ba0759..6324724 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -76,6 +76,8 @@ QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform); QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QGraphicsScale) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) +#include "qfxeffects.cpp" + /*! \qmlclass Transform \brief A transformation. -- cgit v0.12 From 5e31c0cae45bae6f66decfb37825ed5d445e49e4 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 13 Oct 2009 12:36:05 +1000 Subject: More i18n --- src/declarative/extra/qmlbehavior.cpp | 2 +- src/declarative/extra/qmlxmllistmodel.cpp | 4 +- src/declarative/fx/qfxanchors.cpp | 30 ++-- src/declarative/fx/qfxflipable.cpp | 4 +- src/declarative/fx/qfxtextinput.cpp | 6 +- src/declarative/fx/qfxvisualitemmodel.cpp | 4 +- src/declarative/qml/parser/qmljs.g | 11 +- src/declarative/qml/parser/qmljsengine_p.cpp | 2 +- src/declarative/qml/parser/qmljsgrammar.cpp | 32 ++--- src/declarative/qml/parser/qmljsgrammar_p.h | 32 ++--- src/declarative/qml/parser/qmljsparser.cpp | 11 +- src/declarative/qml/qmlbinding.cpp | 3 +- src/declarative/qml/qmlcompiler.cpp | 151 ++++++++++----------- src/declarative/qml/qmlcompiler_p.h | 3 +- src/declarative/qml/qmlinfo.cpp | 53 +++----- src/declarative/qml/qmlinfo.h | 12 +- src/declarative/util/qmlanimation.cpp | 4 +- src/declarative/util/qmlpropertychanges.cpp | 6 +- .../data/unsupportedProperty.errors.txt | 2 +- 19 files changed, 171 insertions(+), 201 deletions(-) diff --git a/src/declarative/extra/qmlbehavior.cpp b/src/declarative/extra/qmlbehavior.cpp index e30bd39..f3eb014 100644 --- a/src/declarative/extra/qmlbehavior.cpp +++ b/src/declarative/extra/qmlbehavior.cpp @@ -77,7 +77,7 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) { Q_D(QmlBehavior); if (d->animation) { - qmlInfo(this) << "Can't change the animation assigned to a Behavior."; + qmlInfo(tr("Can't change the animation assigned to a Behavior."),this); return; } diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 01efa0e..fb26915 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -109,7 +109,7 @@ public: void setQuery(const QString &query) { if (query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << "An XmlRole query must not start with '/'"; + qmlInfo(tr("An XmlRole query must not start with '/'"),this); return; } m_query = query; @@ -545,7 +545,7 @@ void QmlXmlListModel::setQuery(const QString &query) { Q_D(QmlXmlListModel); if (!query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << "An XmlListModel query must start with '/' or \"//\""; + qmlInfo(tr("An XmlListModel query must start with '/' or \"//\""),this); return; } diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 64eaaaf..09776e5 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -334,7 +334,7 @@ void QFxAnchors::setFill(QFxItem *f) return; } if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling."; + qmlInfo(tr("Can't anchor to an item that isn't a parent or sibling."), d->item); return; } d->remDepend(d->fill); @@ -359,7 +359,7 @@ void QFxAnchors::setCenterIn(QFxItem* c) return; } if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling."; + qmlInfo(tr("Can't anchor to an item that isn't a parent or sibling."), d->item); return; } @@ -460,7 +460,7 @@ void QFxAnchorsPrivate::updateVerticalAnchors() --updatingVerticalAnchor; } else { // ### Make this certain :) - qmlInfo(item) << "Possible anchor loop detected on vertical anchor."; + qmlInfo(QFxAnchors::tr("Possible anchor loop detected on vertical anchor."), item); } } @@ -519,7 +519,7 @@ void QFxAnchorsPrivate::updateHorizontalAnchors() --updatingHorizontalAnchor; } else { // ### Make this certain :) - qmlInfo(item) << "Possible anchor loop detected on horizontal anchor."; + qmlInfo(QFxAnchors::tr("Possible anchor loop detected on horizontal anchor."), item); } } @@ -891,7 +891,7 @@ bool QFxAnchorsPrivate::checkHValid() const if (usedAnchors & QFxAnchors::HasLeftAnchor && usedAnchors & QFxAnchors::HasRightAnchor && usedAnchors & QFxAnchors::HasHCenterAnchor) { - qmlInfo(item) << "Can't specify left, right, and hcenter anchors."; + qmlInfo(QFxAnchors::tr("Can't specify left, right, and hcenter anchors."), item); return false; } @@ -901,16 +901,16 @@ bool QFxAnchorsPrivate::checkHValid() const bool QFxAnchorsPrivate::checkHAnchorValid(QFxAnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << "Can't anchor to a null item."; + qmlInfo(QFxAnchors::tr("Can't anchor to a null item."), item); return false; } else if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) { - qmlInfo(item) << "Can't anchor a horizontal edge to a vertical edge."; + qmlInfo(QFxAnchors::tr("Can't anchor a horizontal edge to a vertical edge."), item); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling."; + qmlInfo(QFxAnchors::tr("Can't anchor to an item that isn't a parent or sibling."), item); return false; } else if (anchor.item == item) { - qmlInfo(item) << "Can't anchor item to self."; + qmlInfo(QFxAnchors::tr("Can't anchor item to self."), item); return false; } @@ -922,13 +922,13 @@ bool QFxAnchorsPrivate::checkVValid() const if (usedAnchors & QFxAnchors::HasTopAnchor && usedAnchors & QFxAnchors::HasBottomAnchor && usedAnchors & QFxAnchors::HasVCenterAnchor) { - qmlInfo(item) << "Can't specify top, bottom, and vcenter anchors."; + qmlInfo(QFxAnchors::tr("Can't specify top, bottom, and vcenter anchors."), item); return false; } else if (usedAnchors & QFxAnchors::HasBaselineAnchor && (usedAnchors & QFxAnchors::HasTopAnchor || usedAnchors & QFxAnchors::HasBottomAnchor || usedAnchors & QFxAnchors::HasVCenterAnchor)) { - qmlInfo(item) << "Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."; + qmlInfo(QFxAnchors::tr("Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."), item); return false; } @@ -938,16 +938,16 @@ bool QFxAnchorsPrivate::checkVValid() const bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << "Can't anchor to a null item."; + qmlInfo(QFxAnchors::tr("Can't anchor to a null item."), item); return false; } else if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) { - qmlInfo(item) << "Can't anchor a vertical edge to a horizontal edge."; + qmlInfo(QFxAnchors::tr("Can't anchor a vertical edge to a horizontal edge."), item); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling."; + qmlInfo(QFxAnchors::tr("Can't anchor to an item that isn't a parent or sibling."), item); return false; } else if (anchor.item == item){ - qmlInfo(item) << "Can't anchor item to self."; + qmlInfo(QFxAnchors::tr("Can't anchor item to self."), item); return false; } diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index dc5101c..d381cfe 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -142,7 +142,7 @@ void QFxFlipable::setFront(QFxItem *front) { Q_D(QFxFlipable); if (d->front) { - qmlInfo(this) << "front is a write-once property"; + qmlInfo(tr("front is a write-once property"),this); return; } d->front = front; @@ -161,7 +161,7 @@ void QFxFlipable::setBack(QFxItem *back) { Q_D(QFxFlipable); if (d->back) { - qmlInfo(this) << "back is a write-once property"; + qmlInfo(tr("back is a write-once property"),this); return; } d->back = back; diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp index 05d2260..f5bf911 100644 --- a/src/declarative/fx/qfxtextinput.cpp +++ b/src/declarative/fx/qfxtextinput.cpp @@ -508,7 +508,7 @@ void QFxTextInputPrivate::startCreatingCursor() q->connect(cursorComponent, SIGNAL(statusChanged(int)), q, SLOT(createCursor())); }else{//isError - qmlInfo(q) << "Could not load cursor delegate"; + qmlInfo(QFxTextInput::tr("Could not load cursor delegate"), q); qWarning() << cursorComponent->errors(); } } @@ -517,7 +517,7 @@ void QFxTextInput::createCursor() { Q_D(QFxTextInput); if(d->cursorComponent->isError()){ - qmlInfo(this) << "Could not load cursor delegate"; + qmlInfo(tr("Could not load cursor delegate"),this); qWarning() << d->cursorComponent->errors(); return; } @@ -529,7 +529,7 @@ void QFxTextInput::createCursor() delete d->cursorItem; d->cursorItem = qobject_cast(d->cursorComponent->create()); if(!d->cursorItem){ - qmlInfo(this) << "Could not instantiate cursor delegate"; + qmlInfo(tr("Could not instantiate cursor delegate"),this); //The failed instantiation should print its own error messages return; } diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index 3a9e5d4..a078da6 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -275,7 +275,7 @@ public: int count = object->metaObject()->propertyCount(); for (int ii = 1; ii < count; ++ii) { const QMetaProperty &prop = object->metaObject()->property(ii); - m_roleNames.insert(prop.name(), 0); + m_roleNames.insert(QString::fromUtf8(prop.name()), 0); } } } @@ -798,7 +798,7 @@ QFxItem *QFxVisualDataModel::item(int index, const QByteArray &viewId, bool comp } if (!item) { d->m_cache.releaseItem(nobj); - qmlInfo(d->m_delegate) << "Delegate component must be Item type."; + qmlInfo(QFxVisualDataModel::tr("Delegate component must be Item type."), d->m_delegate); } return item; diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index 211887b..ed6c272 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -142,6 +142,7 @@ ****************************************************************************/ #include +#include #include @@ -2959,7 +2960,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; yylloc.startColumn += yylloc.length; yylloc.length = 0; - //const QString msg = QString::fromUtf8("Missing `;'"); + //const QString msg = qApp->translate("QmlParser", "Missing `;'"); //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); first_token = &token_buffer[0]; @@ -2984,7 +2985,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; token_buffer[1].loc = yylloc = location(lexer); if (t_action(errorState, yytoken)) { - const QString msg = QString::fromUtf8("Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); + const QString msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); action = errorState; @@ -3012,7 +3013,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { int a = t_action(errorState, *tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[*tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = *tk; @@ -3035,7 +3036,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; int a = t_action(errorState, tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = tk; @@ -3048,7 +3049,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; } } - const QString msg = QString::fromUtf8("Syntax error"); + const QString msg = qApp->translate("QmlParser", "Syntax error"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); } diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp index 7d4d6d7..32068c0 100644 --- a/src/declarative/qml/parser/qmljsengine_p.cpp +++ b/src/declarative/qml/parser/qmljsengine_p.cpp @@ -164,7 +164,7 @@ double integerFromString(const char *buf, int size, int radix) double integerFromString(const QString &str, int radix) { - QByteArray ba = str.trimmed().toUtf8(); + QByteArray ba = str.trimmed().toLatin1(); return integerFromString(ba.constData(), ba.size(), radix); } diff --git a/src/declarative/qml/parser/qmljsgrammar.cpp b/src/declarative/qml/parser/qmljsgrammar.cpp index 67f1403..da3ce2a 100644 --- a/src/declarative/qml/parser/qmljsgrammar.cpp +++ b/src/declarative/qml/parser/qmljsgrammar.cpp @@ -2,8 +2,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -11,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -22,20 +21,21 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. ** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/declarative/qml/parser/qmljsgrammar_p.h b/src/declarative/qml/parser/qmljsgrammar_p.h index 7de77c0..b297f81 100644 --- a/src/declarative/qml/parser/qmljsgrammar_p.h +++ b/src/declarative/qml/parser/qmljsgrammar_p.h @@ -2,8 +2,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -11,8 +10,8 @@ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -22,20 +21,21 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. ** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp index e805ce5..2c8162b 100644 --- a/src/declarative/qml/parser/qmljsparser.cpp +++ b/src/declarative/qml/parser/qmljsparser.cpp @@ -42,6 +42,7 @@ ****************************************************************************/ #include +#include #include @@ -1723,7 +1724,7 @@ case 337: { yylloc.startColumn += yylloc.length; yylloc.length = 0; - //const QString msg = QString::fromUtf8("Missing `;'"); + //const QString msg = qApp->translate("QmlParser", "Missing `;'"); //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); first_token = &token_buffer[0]; @@ -1748,7 +1749,7 @@ case 337: { token_buffer[1].loc = yylloc = location(lexer); if (t_action(errorState, yytoken)) { - const QString msg = QString::fromUtf8("Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); + const QString msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token_buffer[0].token])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); action = errorState; @@ -1776,7 +1777,7 @@ case 337: { for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { int a = t_action(errorState, *tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[*tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = *tk; @@ -1799,7 +1800,7 @@ case 337: { int a = t_action(errorState, tk); if (a > 0 && t_action(a, yytoken)) { - const QString msg = QString::fromUtf8("Expected token `%1'").arg(QLatin1String(spell[tk])); + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); yytoken = tk; @@ -1812,7 +1813,7 @@ case 337: { } } - const QString msg = QString::fromUtf8("Syntax error"); + const QString msg = qApp->translate("QmlParser", "Syntax error"); diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); } diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index 2435c40..6a70c1e 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -134,8 +134,7 @@ void QmlBinding::update(QmlMetaProperty::WriteFlags flags) data->updating = false; } else { - qmlInfo(data->property.object()) << "Binding loop detected for property" - << data->property.name(); + qmlInfo(tr("Binding loop detected for property \"%1\"").arg(data->property.name()), data->property.object()); } data->release(); diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 431f9f6..fa7e473 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -157,7 +157,7 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name) For example: \code - COMPILE_EXCEPTION(property, "Error for property" << property->name); + COMPILE_EXCEPTION(property, tr("Error for property \"%1\"").arg(QString::fromUtf8(property->name))); \endcode */ #define COMPILE_EXCEPTION(token, desc) \ @@ -167,9 +167,7 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name) error.setUrl(output->url); \ error.setLine((token)->location.start.line); \ error.setColumn((token)->location.start.column); \ - QDebug d(&exceptionDescription); \ - d << desc; \ - error.setDescription(exceptionDescription.trimmed()); \ + error.setDescription(desc.trimmed()); \ exceptions << error; \ return false; \ } @@ -195,7 +193,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, QString string = v->value.asScript(); if (!prop.isWritable()) - COMPILE_EXCEPTION(v, "Invalid property assignment:" << QString::fromUtf8(prop.name()) << "is a read-only property"); + COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name()))); if (prop.isEnumType()) { int value; @@ -204,7 +202,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, } else value = prop.enumerator().keyToValue(string.toUtf8().constData()); if (value == -1) - COMPILE_EXCEPTION(v, "Invalid property assignment: unknown enumeration"); + COMPILE_EXCEPTION(v, tr("Invalid property assignment: unknown enumeration")); return true; } int type = prop.userType(); @@ -212,61 +210,61 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, case -1: break; case QVariant::String: - if (!v->value.isString()) COMPILE_EXCEPTION(v, "Invalid property assignment: string expected"); + if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string expected")); break; case QVariant::Url: - if (!v->value.isString()) COMPILE_EXCEPTION(v, "Invalid property assignment: url expected"); + if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: url expected")); break; case QVariant::UInt: { bool ok; string.toUInt(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: unsigned int expected"); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected")); } break; case QVariant::Int: { bool ok; string.toInt(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: int expected"); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected")); } break; case QMetaType::Float: { bool ok; string.toFloat(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: float expected"); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected")); } break; case QVariant::Double: { bool ok; string.toDouble(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: double expected"); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected")); } break; case QVariant::Color: { QColor c = QmlStringConverters::colorFromString(string); - if (!c.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: color expected"); + if (!c.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected")); } break; case QVariant::Date: { QDate d = QDate::fromString(string, Qt::ISODate); - if (!d.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: date expected"); + if (!d.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: date expected")); } break; case QVariant::Time: { QTime time = QTime::fromString(string, Qt::ISODate); - if (!time.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: time expected"); + if (!time.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: time expected")); } break; case QVariant::DateTime: { QDateTime dateTime = QDateTime::fromString(string, Qt::ISODate); - if (!dateTime.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: datetime expected"); + if (!dateTime.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected")); } break; case QVariant::Point: @@ -274,7 +272,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, { bool ok; QPointF point = QmlStringConverters::pointFFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, "Invalid property assignment: point expected"); + if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: point expected")); } break; case QVariant::Size: @@ -282,7 +280,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, { bool ok; QSizeF size = QmlStringConverters::sizeFFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, "Invalid property assignment: size expected"); + if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: size expected")); } break; case QVariant::Rect: @@ -290,19 +288,19 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, { bool ok; QRectF rect = QmlStringConverters::rectFFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, "Invalid property assignment: rect expected"); + if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: rect expected")); } break; case QVariant::Bool: { - if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, "Invalid property assignment: boolean expected"); + if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: boolean expected")); } break; case QVariant::Vector3D: { bool ok; QVector3D point = QmlStringConverters::vector3DFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, "Invalid property assignment: 3D vector expected"); + if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 3D vector expected")); } break; default: @@ -313,7 +311,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, QmlMetaType::StringConverter converter = QmlMetaType::customStringConverter(t); if (!converter) - COMPILE_EXCEPTION(v, "Invalid property assignment: unknown type" << prop.type()); + COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName(prop.type())))); } break; } @@ -741,7 +739,7 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) } if (canDefer && !deferredList.isEmpty() && - deferredList.contains(prop->name)) + deferredList.contains(QString::fromUtf8(prop->name))) prop->isDeferred = true; } @@ -766,7 +764,7 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt) } if (canDefer && !deferredList.isEmpty() && - deferredList.contains(prop->name)) + deferredList.contains(QString::fromUtf8(prop->name))) prop->isDeferred = true; } @@ -1025,18 +1023,18 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, if (obj->properties.count() > 1 || (obj->properties.count() == 1 && obj->properties.begin().key() != "id") || !obj->scriptBlockObjects.isEmpty()) - COMPILE_EXCEPTION(obj, "Invalid component specification"); + COMPILE_EXCEPTION(obj, tr("Invalid component specification")); if (obj->properties.count()) idProp = *obj->properties.begin(); if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive()))) - COMPILE_EXCEPTION(obj, "Invalid component id specification"); + COMPILE_EXCEPTION(obj, tr("Invalid component id specification")); if (idProp) { QString idVal = idProp->values.first()->primitive(); if (compileState.ids.contains(idVal)) - COMPILE_EXCEPTION(obj, "id is not unique"); + COMPILE_EXCEPTION(obj, tr("id is not unique")); obj->id = idVal; addId(idVal, obj); @@ -1046,14 +1044,14 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, if (obj->defaultProperty && (obj->defaultProperty->value || obj->defaultProperty->values.count() > 1 || (obj->defaultProperty->values.count() == 1 && !obj->defaultProperty->values.first()->object))) - COMPILE_EXCEPTION(obj, "Invalid component body specification"); + COMPILE_EXCEPTION(obj, tr("Invalid component body specification")); Object *root = 0; if (obj->defaultProperty && obj->defaultProperty->values.count()) root = obj->defaultProperty->values.first()->object; if (!root) - COMPILE_EXCEPTION(obj, "Cannot create empty component specification"); + COMPILE_EXCEPTION(obj, tr("Cannot create empty component specification")); // Build the component tree COMPILE_CHECK(buildComponentFromRoot(root, ctxt)); @@ -1072,11 +1070,11 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script) Property *source = *script->properties.begin(); if (script->defaultProperty) - COMPILE_EXCEPTION(source, "Invalid Script block. Specify either the source property or inline script."); + COMPILE_EXCEPTION(source, tr("Invalid Script block. Specify either the source property or inline script.")); if (source->value || source->values.count() != 1 || source->values.at(0)->object || !source->values.at(0)->value.isString()) - COMPILE_EXCEPTION(source, "Invalid Script source value"); + COMPILE_EXCEPTION(source, tr("Invalid Script source value")); sourceUrl = output->url.resolved(QUrl(source->values.at(0)->value.asString())).toString(); @@ -1088,7 +1086,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script) } } else if (!script->properties.isEmpty()) { - COMPILE_EXCEPTION(*script->properties.begin(), "Properties cannot be set on Script block"); + COMPILE_EXCEPTION(*script->properties.begin(), tr("Properties cannot be set on Script block")); } else if (script->defaultProperty) { sourceUrl = output->url.toString(); @@ -1099,7 +1097,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script) if (lineNumber == 1) lineNumber = v->location.start.line; if (v->object || !v->value.isString()) - COMPILE_EXCEPTION(v, "Invalid Script block"); + COMPILE_EXCEPTION(v, tr("Invalid Script block")); if (ii == 0) { currentLocation = v->location.start; @@ -1205,7 +1203,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, Q_ASSERT(obj->metaObject()); if (prop->isEmpty()) - COMPILE_EXCEPTION(prop, "Empty property assignment"); + COMPILE_EXCEPTION(prop, tr("Empty property assignment")); QByteArray name = prop->name; Q_ASSERT(name.startsWith("on")); @@ -1224,7 +1222,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, } else { if (prop->value || prop->values.count() > 1) - COMPILE_EXCEPTION(prop, "Incorrectly specified signal"); + COMPILE_EXCEPTION(prop, tr("Incorrectly specified signal")); prop->index = sigIdx; obj->addSignalProperty(prop); @@ -1269,7 +1267,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, const BindingContext &ctxt) { if (prop->isEmpty()) - COMPILE_EXCEPTION(prop, "Empty property assignment"); + COMPILE_EXCEPTION(prop, tr("Empty property assignment")); const QMetaObject *metaObject = obj->metaObject(); Q_ASSERT(metaObject); @@ -1281,7 +1279,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, // Attached properties cannot be used on sub-objects. Sub-objects // always exist in a binding sub-context, which is what we test // for here. - COMPILE_EXCEPTION(prop, "Attached properties cannot be used here"); + COMPILE_EXCEPTION(prop, tr("Attached properties cannot be used here")); } QmlType *type = 0; @@ -1296,11 +1294,11 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, ctxt)); return true; } else if (!type || !type->attachedPropertiesType()) { - COMPILE_EXCEPTION(prop, "Non-existant attached object"); + COMPILE_EXCEPTION(prop, tr("Non-existant attached object")); } if (!prop->value) - COMPILE_EXCEPTION(prop, "Invalid attached object assignment"); + COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); Q_ASSERT(type->attachedPropertiesFunction()); prop->index = type->index(); @@ -1358,9 +1356,9 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, } else if (prop->index == -1) { if (prop->isDefault) { - COMPILE_EXCEPTION(prop->values.first(), "Cannot assign to non-existant default property"); + COMPILE_EXCEPTION(prop->values.first(), tr("Cannot assign to non-existant default property")); } else { - COMPILE_EXCEPTION(prop, "Cannot assign to non-existant property" << prop->name); + COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); } } else if (prop->value) { @@ -1388,12 +1386,12 @@ QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns, const BindingContext &ctxt) { if (!nsProp->value) - COMPILE_EXCEPTION(nsProp, "Invalid use of namespace"); + COMPILE_EXCEPTION(nsProp, tr("Invalid use of namespace")); foreach (Property *prop, nsProp->value->properties) { if (!isAttachedPropertyName(prop->name)) - COMPILE_EXCEPTION(prop, "Not an attached property name"); + COMPILE_EXCEPTION(prop, tr("Not an attached property name")); // Setup attached property data @@ -1402,10 +1400,10 @@ QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns, &type, 0, 0, 0); if (!type || !type->attachedPropertiesType()) - COMPILE_EXCEPTION(prop, "Non-existant attached object"); + COMPILE_EXCEPTION(prop, tr("Non-existant attached object")); if (!prop->value) - COMPILE_EXCEPTION(prop, "Invalid attached object assignment"); + COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); Q_ASSERT(type->attachedPropertiesFunction()); prop->index = type->index(); @@ -1577,13 +1575,13 @@ bool QmlCompiler::buildIdProperty(QmlParser::Property *prop, if (prop->value || prop->values.count() > 1 || prop->values.at(0)->object) - COMPILE_EXCEPTION(prop, "Invalid use of id property"); + COMPILE_EXCEPTION(prop, tr("Invalid use of id property")); QmlParser::Value *idValue = prop->values.at(0); QString val = idValue->primitive(); if (!isValidId(val)) - COMPILE_EXCEPTION(prop, val << "is not a valid object id"); + COMPILE_EXCEPTION(prop, tr("\"%1\" is not a valid object id").arg(val)); // We disallow id's that conflict with import prefixes and types QmlEnginePrivate::ImportedNamespace *ns = 0; @@ -1591,12 +1589,12 @@ bool QmlCompiler::buildIdProperty(QmlParser::Property *prop, QmlEnginePrivate::get(engine)->resolveType(unit->imports, val.toUtf8(), &type, 0, 0, 0, &ns); if (type) - COMPILE_EXCEPTION(idValue, "id conflicts with type name"); + COMPILE_EXCEPTION(idValue, tr("id conflicts with type name")); if (ns) - COMPILE_EXCEPTION(idValue, "id conflicts with namespace prefix"); + COMPILE_EXCEPTION(idValue, tr("id conflicts with namespace prefix")); if (compileState.ids.contains(val)) - COMPILE_EXCEPTION(prop, "id is not unique"); + COMPILE_EXCEPTION(prop, tr("id is not unique")); prop->values.at(0)->type = Value::Id; @@ -1677,7 +1675,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, prop->value, obj, ctxt.incr())); obj->addValueTypeProperty(prop); } else { - COMPILE_EXCEPTION(prop, "Invalid property access"); + COMPILE_EXCEPTION(prop, tr("Invalid property access")); } } else { @@ -1685,8 +1683,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, prop->value->metatype = QmlEnginePrivate::get(engine)->metaObjectForType(prop->type); if (!prop->value->metatype) - COMPILE_EXCEPTION(prop, "Cannot nest non-QObject property" << - prop->name); + COMPILE_EXCEPTION(prop, tr("Cannot nest non-QObject property \"%1\"").arg(QString::fromUtf8(prop->name))); obj->addGroupedProperty(prop); @@ -1702,19 +1699,19 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, const BindingContext &ctxt) { if (obj->defaultProperty) - COMPILE_EXCEPTION(obj, "Invalid property use"); + COMPILE_EXCEPTION(obj, tr("Invalid property use")); obj->metatype = type->metaObject(); foreach (Property *prop, obj->properties) { int idx = type->metaObject()->indexOfProperty(prop->name.constData()); if (idx == -1) - COMPILE_EXCEPTION(prop, "Cannot assign to non-existant property" << prop->name); + COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); QMetaProperty p = type->metaObject()->property(idx); prop->index = idx; prop->type = p.userType(); if (prop->value || prop->values.count() != 1) - COMPILE_EXCEPTION(prop, "Invalid property use"); + COMPILE_EXCEPTION(prop, tr("Invalid property use")); Value *value = prop->values.at(0); @@ -1722,7 +1719,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1; bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1; if (!isPropertyValue && !isPropertyInterceptor) { - COMPILE_EXCEPTION(prop, "Invalid property use"); + COMPILE_EXCEPTION(prop, tr("Invalid property use")); } else { COMPILE_CHECK(buildObject(value->object, ctxt)); @@ -1780,12 +1777,12 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop, // at runtime. if (!listTypeIsInterface) { if (!canCoerce(listType, v->object)) { - COMPILE_EXCEPTION(v, "Cannot assign object to list"); + COMPILE_EXCEPTION(v, tr("Cannot assign object to list")); } } } else { - COMPILE_EXCEPTION(v, "Cannot assign primitives to lists"); + COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists")); } } @@ -1804,19 +1801,19 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop, // at runtime. if (!listTypeIsInterface) { if (!canCoerce(listType, v->object)) { - COMPILE_EXCEPTION(v, "Cannot assign object to list"); + COMPILE_EXCEPTION(v, tr("Cannot assign object to list")); } } } else if (v->value.isScript()) { if (assignedBinding) - COMPILE_EXCEPTION(v, "Can only assign one binding to lists"); + COMPILE_EXCEPTION(v, tr("Can only assign one binding to lists")); assignedBinding = true; COMPILE_CHECK(buildBinding(v, prop, ctxt)); v->type = Value::PropertyBinding; } else { - COMPILE_EXCEPTION(v, "Cannot assign primitives to lists"); + COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists")); } } @@ -1944,7 +1941,7 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop, buildDynamicMeta(prop->parent, ForceCreation); v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor; } else { - COMPILE_EXCEPTION(v->object, "Cannot assign object to property"); + COMPILE_EXCEPTION(v->object, tr("Cannot assign object to property")); } } @@ -1989,12 +1986,12 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj) if (prop.isDefaultProperty) { if (seenDefaultProperty) - COMPILE_EXCEPTION(obj, "Duplicate default property"); + COMPILE_EXCEPTION(obj, tr("Duplicate default property")); seenDefaultProperty = true; } if (propNames.contains(prop.name)) - COMPILE_EXCEPTION(obj, "Duplicate property name"); + COMPILE_EXCEPTION(obj, tr("Duplicate property name")); propNames.insert(prop.name); } @@ -2002,13 +1999,13 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj) for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) { QByteArray name = obj->dynamicSignals.at(ii).name; if (methodNames.contains(name)) - COMPILE_EXCEPTION(obj, "Duplicate signal name"); + COMPILE_EXCEPTION(obj, tr("Duplicate signal name")); methodNames.insert(name); } for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) { QByteArray name = obj->dynamicSlots.at(ii).name; if (methodNames.contains(name)) - COMPILE_EXCEPTION(obj, "Duplicate method name"); + COMPILE_EXCEPTION(obj, tr("Duplicate method name")); methodNames.insert(name); } @@ -2030,7 +2027,7 @@ bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj) property = obj->getProperty(p.name); if (property->value) - COMPILE_EXCEPTION(property, "Invalid property nesting"); + COMPILE_EXCEPTION(property, tr("Invalid property nesting")); for (int ii = 0; ii < p.defaultValue->values.count(); ++ii) { Value *v = p.defaultValue->values.at(ii); @@ -2076,7 +2073,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) if (-1 != propIdx) { QMetaProperty prop = obj->metaObject()->property(propIdx); if (prop.isFinal()) - COMPILE_EXCEPTION(&p, "Cannot override FINAL property"); + COMPILE_EXCEPTION(&p, tr("Cannot override FINAL property")); } if (p.isDefaultProperty && @@ -2101,7 +2098,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) QmlEnginePrivate *priv = QmlEnginePrivate::get(engine); if (!priv->resolveType(unit->imports, p.customType, &qmltype, &url, 0, 0, 0)) - COMPILE_EXCEPTION(&p, "Invalid property type"); + COMPILE_EXCEPTION(&p, tr("Invalid property type")); if (!qmltype) { QmlCompositeTypeData *tdata = priv->typeManager.get(url); @@ -2260,24 +2257,24 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, const Object::DynamicProperty &prop) { if (!prop.defaultValue) - COMPILE_EXCEPTION(obj, "No property alias location"); + COMPILE_EXCEPTION(obj, tr("No property alias location")); if (prop.defaultValue->values.count() != 1 || prop.defaultValue->values.at(0)->object || !prop.defaultValue->values.at(0)->value.isScript()) - COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); + COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); QmlJS::AST::Node *node = prop.defaultValue->values.at(0)->value.asAST(); if (!node) - COMPILE_EXCEPTION(obj, "No property alias location"); // ### Can this happen? + COMPILE_EXCEPTION(obj, tr("No property alias location")); // ### Can this happen? QStringList alias = astNodeToStringList(node); if (alias.count() != 1 && alias.count() != 2) - COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); + COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); if (!compileState.ids.contains(alias.at(0))) - COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); + COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); Object *idObject = compileState.ids[alias.at(0)]; @@ -2289,7 +2286,7 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData()); if (-1 == propIdx) - COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location"); + COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx); writable = aliasProperty.isWritable(); @@ -2324,7 +2321,7 @@ bool QmlCompiler::buildBinding(QmlParser::Value *value, QMetaProperty mp = prop->parent->metaObject()->property(prop->index); if (!mp.isWritable() && !QmlMetaType::isList(prop->type)) - COMPILE_EXCEPTION(prop, "Invalid property assignment:" << QString::fromLatin1(prop->name) << "is a read-only property"); + COMPILE_EXCEPTION(prop, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name))); BindingReference reference; reference.expression = value->value; diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index ecf3344..6d6a25e 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -135,8 +135,9 @@ private: }; class QMetaObjectBuilder; -class Q_DECLARATIVE_EXPORT QmlCompiler +class Q_DECLARATIVE_EXPORT QmlCompiler : public QObject { + Q_OBJECT public: QmlCompiler(); diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp index e3c0225..75de985 100644 --- a/src/declarative/qml/qmlinfo.cpp +++ b/src/declarative/qml/qmlinfo.cpp @@ -42,18 +42,19 @@ #include "qmlinfo.h" #include #include +#include QT_BEGIN_NAMESPACE /*! - \class QmlInfo - \brief The QmlInfo class prints warnings messages that include the file and line number for QML types. + \fn void qmlInfo(const QString& message, QObject *object) + + \brief Prints warnings messages that include the file and line number for QML types. When QML types display warning messages, it improves tracibility if they include the QML file and line number on which the particular instance was instantiated. - QmlInfo statements work just like regular Qt qDebug() statements. To include the file and line number, an object must be passed. If the file and line number is not available for that instance (either it was not instantiated by the QML engine or location @@ -62,7 +63,7 @@ QT_BEGIN_NAMESPACE For example, \code - qmlInfo(this) << "component property is a write-once property"; + qmlInfo(object, tr("component property is a write-once property")); \endcode prints @@ -72,46 +73,26 @@ QT_BEGIN_NAMESPACE \endcode */ -/*! - Construct a QmlInfo, using \a object for file and line number - information. -*/ -QmlInfo::QmlInfo(QObject *object) -: QDebug(QtWarningMsg) +void qmlInfo(const QString& msg, QObject* object) { - *this << "QML"; - if (object) - *this << object->metaObject()->className(); + QString pos = QLatin1String("QML ") + QLatin1String(object->metaObject()->className()); QmlDeclarativeData *ddata = QmlDeclarativeData::get(object); + pos += QLatin1String("("); if (ddata) { - QString location = QLatin1String("("); if (ddata->outerContext) { - location += ddata->outerContext->baseUrl().toString(); + pos += ddata->outerContext->baseUrl().toString(); } else { - location += "unknown"; + pos += qApp->translate("QmlInfo","unknown"); } - location += QLatin1String(":"); - location += QString::number(ddata->lineNumber); - location += QLatin1String(":"); - location += QString::number(ddata->columnNumber); - location += QLatin1String(")"); - *this << qPrintable(location); + pos += QLatin1String(":"); + pos += QString::number(ddata->lineNumber); + pos += QLatin1String(":"); + pos += QString::number(ddata->columnNumber); } else { - *this << "(unknown location):"; + pos += qApp->translate("QmlInfo","unknown location"); } + pos += QLatin1String(")"); + qWarning((pos + msg).toLocal8Bit()); // XXX allow other processing? } -/*! - The destructor does nothing special. -*/ -QmlInfo::~QmlInfo() -{ -} - -/*! - \relates QmlInfo - \fn QmlInfo qmlInfo(QObject *me) - Constructs an instance of QmlInfo from \a me and returns it. -*/ - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlinfo.h b/src/declarative/qml/qmlinfo.h index da8144c..f2d17fe 100644 --- a/src/declarative/qml/qmlinfo.h +++ b/src/declarative/qml/qmlinfo.h @@ -50,17 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QmlInfo : public QDebug -{ -public: - QmlInfo(QObject *); - ~QmlInfo(); -}; - -Q_DECLARATIVE_EXPORT inline QmlInfo qmlInfo(QObject *me) -{ - return QmlInfo(me); -} +Q_DECLARATIVE_EXPORT void qmlInfo(const QString& msg, QObject *me=0); QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index a8de8d5..f42aa4e 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -224,10 +224,10 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const Q_Q(QmlAbstractAnimation); QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str); if (!prop.isValid()) { - qmlInfo(q) << "Cannot animate non-existant property" << str; + qmlInfo(QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str), q); return QmlMetaProperty(); } else if (!prop.isWritable()) { - qmlInfo(q) << "Cannot animate read-only property" << str; + qmlInfo(QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str), q); return QmlMetaProperty(); } return prop; diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index b07a79f..a112245 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -303,12 +303,12 @@ QmlMetaProperty QmlPropertyChangesPrivate::property(const QByteArray &property) { Q_Q(QmlPropertyChanges); - QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromLatin1(property)); + QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromUtf8(property)); if (!prop.isValid()) { - qmlInfo(q) << "Cannot assign to non-existant property" << property; + qmlInfo(QmlPropertyChanges::tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(property)), q); return QmlMetaProperty(); } else if (!prop.isWritable()) { - qmlInfo(q) << "Cannot assign to read-only property" << property; + qmlInfo(QmlPropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(QString::fromUtf8(property)), q); return QmlMetaProperty(); } return prop; diff --git a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt b/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt index 3a90a7d..3cd626d 100644 --- a/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/unsupportedProperty.errors.txt @@ -1 +1 @@ -3:13:Invalid property assignment: unknown type QVariant::QMatrix +3:13:Invalid property assignment: unsupported type "QMatrix" -- cgit v0.12 From 7aa4e177bbc01b7385cb345f3ad620a935dbe2d4 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 13 Oct 2009 13:06:50 +1000 Subject: i18n --- src/declarative/qml/parser/qmljs.g | 2 +- src/declarative/qml/parser/qmljslexer.cpp | 20 +-- src/declarative/qml/parser/qmljsparser.cpp | 2 +- src/declarative/qml/qmlcompiler.cpp | 143 +++++++++++---------- src/declarative/qml/qmlcompiler_p.h | 3 +- src/declarative/qml/qmlinfo.cpp | 10 +- src/declarative/qml/qmlvme.cpp | 29 ++--- tests/auto/declarative/anchors/tst_anchors.cpp | 12 +- .../auto/declarative/animations/tst_animations.cpp | 2 +- .../qmlecmascript/tst_qmlecmascript.cpp | 2 +- 10 files changed, 114 insertions(+), 111 deletions(-) diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index ed6c272..eb9a8ab 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -142,7 +142,7 @@ ****************************************************************************/ #include -#include +#include #include diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp index 54f8d78..2c03c21 100644 --- a/src/declarative/qml/parser/qmljslexer.cpp +++ b/src/declarative/qml/parser/qmljslexer.cpp @@ -48,6 +48,8 @@ #include "qmljslexer_p.h" #include "qmljsgrammar_p.h" +#include + #include #include #include @@ -548,7 +550,7 @@ int Lexer::lex() else { setDone(Bad); err = IllegalCharacter; - errmsg = QLatin1String("Illegal character"); + errmsg = qApp->translate("QmlParser", "Illegal character"); } } break; @@ -562,7 +564,7 @@ int Lexer::lex() } else if (current == 0 || isLineTerminator()) { setDone(Bad); err = UnclosedStringLiteral; - errmsg = QLatin1String("Unclosed string at end of line"); + errmsg = qApp->translate("QmlParser", "Unclosed string at end of line"); } else if (current == '\\') { state = InEscapeSequence; } else { @@ -588,7 +590,7 @@ int Lexer::lex() } else { setDone(Bad); err = IllegalEscapeSequence; - errmsg = QLatin1String("Illegal escape squence"); + errmsg = qApp->translate("QmlParser", "Illegal escape squence"); } } else if (current == 'x') state = InHexEscape; @@ -634,7 +636,7 @@ int Lexer::lex() } else { setDone(Bad); err = IllegalUnicodeEscapeSequence; - errmsg = QLatin1String("Illegal unicode escape sequence"); + errmsg = qApp->translate("QmlParser", "Illegal unicode escape sequence"); } break; case InSingleLineComment: @@ -660,7 +662,7 @@ int Lexer::lex() if (current == 0) { setDone(Bad); err = UnclosedComment; - errmsg = QLatin1String("Unclosed comment at end of file"); + errmsg = qApp->translate("QmlParser", "Unclosed comment at end of file"); driver->addComment(startpos, tokenLength(), startlineno, startcolumn); } else if (isLineTerminator()) { shiftWindowsLineBreak(); @@ -747,7 +749,7 @@ int Lexer::lex() } else { setDone(Bad); err = IllegalExponentIndicator; - errmsg = QLatin1String("Illegal syntax for exponential number"); + errmsg = qApp->translate("QmlParser", "Illegal syntax for exponential number"); } break; case InExponent: @@ -773,7 +775,7 @@ int Lexer::lex() && isIdentLetter(current)) { state = Bad; err = IllegalIdentifier; - errmsg = QLatin1String("Identifier cannot start with numeric literal"); + errmsg = qApp->translate("QmlParser", "Identifier cannot start with numeric literal"); } // terminate string @@ -1104,7 +1106,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) while (1) { if (isLineTerminator() || current == 0) { - errmsg = QLatin1String("Unterminated regular expression literal"); + errmsg = qApp->translate("QmlParser", "Unterminated regular expression literal"); return false; } else if (current != '/' || lastWasEscape == true) @@ -1128,7 +1130,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix) while (isIdentLetter(current)) { int flag = Ecma::RegExp::flagFromChar(current); if (flag == 0) { - errmsg = QString::fromLatin1("Invalid regular expression flag '%0'") + errmsg = qApp->translate("QmlParser", "Invalid regular expression flag '%0'") .arg(QChar(current)); return false; } diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp index 2c8162b..402aaeb 100644 --- a/src/declarative/qml/parser/qmljsparser.cpp +++ b/src/declarative/qml/parser/qmljsparser.cpp @@ -42,7 +42,7 @@ ****************************************************************************/ #include -#include +#include #include diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index fa7e473..c744509 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include "private/qmlcustomparser_p_p.h" #include #include @@ -157,7 +158,7 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name) For example: \code - COMPILE_EXCEPTION(property, tr("Error for property \"%1\"").arg(QString::fromUtf8(property->name))); + COMPILE_EXCEPTION(property, qApp->translate("QmlCompiler","Error for property \"%1\"").arg(QString::fromUtf8(property->name))); \endcode */ #define COMPILE_EXCEPTION(token, desc) \ @@ -193,7 +194,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, QString string = v->value.asScript(); if (!prop.isWritable()) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name()))); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name()))); if (prop.isEnumType()) { int value; @@ -202,7 +203,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, } else value = prop.enumerator().keyToValue(string.toUtf8().constData()); if (value == -1) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: unknown enumeration")); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: unknown enumeration")); return true; } int type = prop.userType(); @@ -210,61 +211,61 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, case -1: break; case QVariant::String: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string expected")); + if (!v->value.isString()) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: string expected")); break; case QVariant::Url: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: url expected")); + if (!v->value.isString()) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: url expected")); break; case QVariant::UInt: { bool ok; string.toUInt(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected")); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: unsigned int expected")); } break; case QVariant::Int: { bool ok; string.toInt(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected")); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: int expected")); } break; case QMetaType::Float: { bool ok; string.toFloat(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected")); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: float expected")); } break; case QVariant::Double: { bool ok; string.toDouble(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected")); + if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: double expected")); } break; case QVariant::Color: { QColor c = QmlStringConverters::colorFromString(string); - if (!c.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected")); + if (!c.isValid()) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: color expected")); } break; case QVariant::Date: { QDate d = QDate::fromString(string, Qt::ISODate); - if (!d.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: date expected")); + if (!d.isValid()) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: date expected")); } break; case QVariant::Time: { QTime time = QTime::fromString(string, Qt::ISODate); - if (!time.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: time expected")); + if (!time.isValid()) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: time expected")); } break; case QVariant::DateTime: { QDateTime dateTime = QDateTime::fromString(string, Qt::ISODate); - if (!dateTime.isValid()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected")); + if (!dateTime.isValid()) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: datetime expected")); } break; case QVariant::Point: @@ -272,7 +273,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, { bool ok; QPointF point = QmlStringConverters::pointFFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: point expected")); + if (!ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: point expected")); } break; case QVariant::Size: @@ -280,7 +281,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, { bool ok; QSizeF size = QmlStringConverters::sizeFFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: size expected")); + if (!ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: size expected")); } break; case QVariant::Rect: @@ -288,19 +289,19 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, { bool ok; QRectF rect = QmlStringConverters::rectFFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: rect expected")); + if (!ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: rect expected")); } break; case QVariant::Bool: { - if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: boolean expected")); + if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: boolean expected")); } break; case QVariant::Vector3D: { bool ok; QVector3D point = QmlStringConverters::vector3DFromString(string, &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 3D vector expected")); + if (!ok) COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: 3D vector expected")); } break; default: @@ -311,7 +312,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, QmlMetaType::StringConverter converter = QmlMetaType::customStringConverter(t); if (!converter) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName(prop.type())))); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName(prop.type())))); } break; } @@ -1023,18 +1024,18 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, if (obj->properties.count() > 1 || (obj->properties.count() == 1 && obj->properties.begin().key() != "id") || !obj->scriptBlockObjects.isEmpty()) - COMPILE_EXCEPTION(obj, tr("Invalid component specification")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component specification")); if (obj->properties.count()) idProp = *obj->properties.begin(); if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive()))) - COMPILE_EXCEPTION(obj, tr("Invalid component id specification")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component id specification")); if (idProp) { QString idVal = idProp->values.first()->primitive(); if (compileState.ids.contains(idVal)) - COMPILE_EXCEPTION(obj, tr("id is not unique")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","id is not unique")); obj->id = idVal; addId(idVal, obj); @@ -1044,14 +1045,14 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, if (obj->defaultProperty && (obj->defaultProperty->value || obj->defaultProperty->values.count() > 1 || (obj->defaultProperty->values.count() == 1 && !obj->defaultProperty->values.first()->object))) - COMPILE_EXCEPTION(obj, tr("Invalid component body specification")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid component body specification")); Object *root = 0; if (obj->defaultProperty && obj->defaultProperty->values.count()) root = obj->defaultProperty->values.first()->object; if (!root) - COMPILE_EXCEPTION(obj, tr("Cannot create empty component specification")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Cannot create empty component specification")); // Build the component tree COMPILE_CHECK(buildComponentFromRoot(root, ctxt)); @@ -1070,11 +1071,11 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script) Property *source = *script->properties.begin(); if (script->defaultProperty) - COMPILE_EXCEPTION(source, tr("Invalid Script block. Specify either the source property or inline script.")); + COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script block. Specify either the source property or inline script.")); if (source->value || source->values.count() != 1 || source->values.at(0)->object || !source->values.at(0)->value.isString()) - COMPILE_EXCEPTION(source, tr("Invalid Script source value")); + COMPILE_EXCEPTION(source, qApp->translate("QmlCompiler","Invalid Script source value")); sourceUrl = output->url.resolved(QUrl(source->values.at(0)->value.asString())).toString(); @@ -1086,7 +1087,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script) } } else if (!script->properties.isEmpty()) { - COMPILE_EXCEPTION(*script->properties.begin(), tr("Properties cannot be set on Script block")); + COMPILE_EXCEPTION(*script->properties.begin(), qApp->translate("QmlCompiler","Properties cannot be set on Script block")); } else if (script->defaultProperty) { sourceUrl = output->url.toString(); @@ -1097,7 +1098,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script) if (lineNumber == 1) lineNumber = v->location.start.line; if (v->object || !v->value.isString()) - COMPILE_EXCEPTION(v, tr("Invalid Script block")); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Invalid Script block")); if (ii == 0) { currentLocation = v->location.start; @@ -1203,7 +1204,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, Q_ASSERT(obj->metaObject()); if (prop->isEmpty()) - COMPILE_EXCEPTION(prop, tr("Empty property assignment")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty property assignment")); QByteArray name = prop->name; Q_ASSERT(name.startsWith("on")); @@ -1222,7 +1223,7 @@ bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj, } else { if (prop->value || prop->values.count() > 1) - COMPILE_EXCEPTION(prop, tr("Incorrectly specified signal")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Incorrectly specified signal")); prop->index = sigIdx; obj->addSignalProperty(prop); @@ -1267,7 +1268,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, const BindingContext &ctxt) { if (prop->isEmpty()) - COMPILE_EXCEPTION(prop, tr("Empty property assignment")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Empty property assignment")); const QMetaObject *metaObject = obj->metaObject(); Q_ASSERT(metaObject); @@ -1279,7 +1280,7 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, // Attached properties cannot be used on sub-objects. Sub-objects // always exist in a binding sub-context, which is what we test // for here. - COMPILE_EXCEPTION(prop, tr("Attached properties cannot be used here")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Attached properties cannot be used here")); } QmlType *type = 0; @@ -1294,11 +1295,11 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, ctxt)); return true; } else if (!type || !type->attachedPropertiesType()) { - COMPILE_EXCEPTION(prop, tr("Non-existant attached object")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Non-existant attached object")); } if (!prop->value) - COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid attached object assignment")); Q_ASSERT(type->attachedPropertiesFunction()); prop->index = type->index(); @@ -1356,9 +1357,9 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop, } else if (prop->index == -1) { if (prop->isDefault) { - COMPILE_EXCEPTION(prop->values.first(), tr("Cannot assign to non-existant default property")); + COMPILE_EXCEPTION(prop->values.first(), qApp->translate("QmlCompiler","Cannot assign to non-existant default property")); } else { - COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); } } else if (prop->value) { @@ -1386,12 +1387,12 @@ QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns, const BindingContext &ctxt) { if (!nsProp->value) - COMPILE_EXCEPTION(nsProp, tr("Invalid use of namespace")); + COMPILE_EXCEPTION(nsProp, qApp->translate("QmlCompiler","Invalid use of namespace")); foreach (Property *prop, nsProp->value->properties) { if (!isAttachedPropertyName(prop->name)) - COMPILE_EXCEPTION(prop, tr("Not an attached property name")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Not an attached property name")); // Setup attached property data @@ -1400,10 +1401,10 @@ QmlCompiler::buildPropertyInNamespace(QmlEnginePrivate::ImportedNamespace *ns, &type, 0, 0, 0); if (!type || !type->attachedPropertiesType()) - COMPILE_EXCEPTION(prop, tr("Non-existant attached object")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Non-existant attached object")); if (!prop->value) - COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid attached object assignment")); Q_ASSERT(type->attachedPropertiesFunction()); prop->index = type->index(); @@ -1575,13 +1576,13 @@ bool QmlCompiler::buildIdProperty(QmlParser::Property *prop, if (prop->value || prop->values.count() > 1 || prop->values.at(0)->object) - COMPILE_EXCEPTION(prop, tr("Invalid use of id property")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid use of id property")); QmlParser::Value *idValue = prop->values.at(0); QString val = idValue->primitive(); if (!isValidId(val)) - COMPILE_EXCEPTION(prop, tr("\"%1\" is not a valid object id").arg(val)); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","\"%1\" is not a valid object id").arg(val)); // We disallow id's that conflict with import prefixes and types QmlEnginePrivate::ImportedNamespace *ns = 0; @@ -1589,12 +1590,12 @@ bool QmlCompiler::buildIdProperty(QmlParser::Property *prop, QmlEnginePrivate::get(engine)->resolveType(unit->imports, val.toUtf8(), &type, 0, 0, 0, &ns); if (type) - COMPILE_EXCEPTION(idValue, tr("id conflicts with type name")); + COMPILE_EXCEPTION(idValue, qApp->translate("QmlCompiler","id conflicts with type name")); if (ns) - COMPILE_EXCEPTION(idValue, tr("id conflicts with namespace prefix")); + COMPILE_EXCEPTION(idValue, qApp->translate("QmlCompiler","id conflicts with namespace prefix")); if (compileState.ids.contains(val)) - COMPILE_EXCEPTION(prop, tr("id is not unique")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","id is not unique")); prop->values.at(0)->type = Value::Id; @@ -1675,7 +1676,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, prop->value, obj, ctxt.incr())); obj->addValueTypeProperty(prop); } else { - COMPILE_EXCEPTION(prop, tr("Invalid property access")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property access")); } } else { @@ -1683,7 +1684,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, prop->value->metatype = QmlEnginePrivate::get(engine)->metaObjectForType(prop->type); if (!prop->value->metatype) - COMPILE_EXCEPTION(prop, tr("Cannot nest non-QObject property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Cannot nest non-QObject property \"%1\"").arg(QString::fromUtf8(prop->name))); obj->addGroupedProperty(prop); @@ -1699,19 +1700,19 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, const BindingContext &ctxt) { if (obj->defaultProperty) - COMPILE_EXCEPTION(obj, tr("Invalid property use")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Invalid property use")); obj->metatype = type->metaObject(); foreach (Property *prop, obj->properties) { int idx = type->metaObject()->indexOfProperty(prop->name.constData()); if (idx == -1) - COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Cannot assign to non-existant property \"%1\"").arg(QString::fromUtf8(prop->name))); QMetaProperty p = type->metaObject()->property(idx); prop->index = idx; prop->type = p.userType(); if (prop->value || prop->values.count() != 1) - COMPILE_EXCEPTION(prop, tr("Invalid property use")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property use")); Value *value = prop->values.at(0); @@ -1719,7 +1720,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1; bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1; if (!isPropertyValue && !isPropertyInterceptor) { - COMPILE_EXCEPTION(prop, tr("Invalid property use")); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property use")); } else { COMPILE_CHECK(buildObject(value->object, ctxt)); @@ -1777,12 +1778,12 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop, // at runtime. if (!listTypeIsInterface) { if (!canCoerce(listType, v->object)) { - COMPILE_EXCEPTION(v, tr("Cannot assign object to list")); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Cannot assign object to list")); } } } else { - COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists")); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Cannot assign primitives to lists")); } } @@ -1801,19 +1802,19 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop, // at runtime. if (!listTypeIsInterface) { if (!canCoerce(listType, v->object)) { - COMPILE_EXCEPTION(v, tr("Cannot assign object to list")); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Cannot assign object to list")); } } } else if (v->value.isScript()) { if (assignedBinding) - COMPILE_EXCEPTION(v, tr("Can only assign one binding to lists")); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Can only assign one binding to lists")); assignedBinding = true; COMPILE_CHECK(buildBinding(v, prop, ctxt)); v->type = Value::PropertyBinding; } else { - COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists")); + COMPILE_EXCEPTION(v, qApp->translate("QmlCompiler","Cannot assign primitives to lists")); } } @@ -1941,7 +1942,7 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop, buildDynamicMeta(prop->parent, ForceCreation); v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor; } else { - COMPILE_EXCEPTION(v->object, tr("Cannot assign object to property")); + COMPILE_EXCEPTION(v->object, qApp->translate("QmlCompiler","Cannot assign object to property")); } } @@ -1986,12 +1987,12 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj) if (prop.isDefaultProperty) { if (seenDefaultProperty) - COMPILE_EXCEPTION(obj, tr("Duplicate default property")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate default property")); seenDefaultProperty = true; } if (propNames.contains(prop.name)) - COMPILE_EXCEPTION(obj, tr("Duplicate property name")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate property name")); propNames.insert(prop.name); } @@ -1999,13 +2000,13 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj) for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) { QByteArray name = obj->dynamicSignals.at(ii).name; if (methodNames.contains(name)) - COMPILE_EXCEPTION(obj, tr("Duplicate signal name")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate signal name")); methodNames.insert(name); } for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) { QByteArray name = obj->dynamicSlots.at(ii).name; if (methodNames.contains(name)) - COMPILE_EXCEPTION(obj, tr("Duplicate method name")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate method name")); methodNames.insert(name); } @@ -2027,7 +2028,7 @@ bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj) property = obj->getProperty(p.name); if (property->value) - COMPILE_EXCEPTION(property, tr("Invalid property nesting")); + COMPILE_EXCEPTION(property, qApp->translate("QmlCompiler","Invalid property nesting")); for (int ii = 0; ii < p.defaultValue->values.count(); ++ii) { Value *v = p.defaultValue->values.at(ii); @@ -2073,7 +2074,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) if (-1 != propIdx) { QMetaProperty prop = obj->metaObject()->property(propIdx); if (prop.isFinal()) - COMPILE_EXCEPTION(&p, tr("Cannot override FINAL property")); + COMPILE_EXCEPTION(&p, qApp->translate("QmlCompiler","Cannot override FINAL property")); } if (p.isDefaultProperty && @@ -2098,7 +2099,7 @@ bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode) QmlEnginePrivate *priv = QmlEnginePrivate::get(engine); if (!priv->resolveType(unit->imports, p.customType, &qmltype, &url, 0, 0, 0)) - COMPILE_EXCEPTION(&p, tr("Invalid property type")); + COMPILE_EXCEPTION(&p, qApp->translate("QmlCompiler","Invalid property type")); if (!qmltype) { QmlCompositeTypeData *tdata = priv->typeManager.get(url); @@ -2257,24 +2258,24 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, const Object::DynamicProperty &prop) { if (!prop.defaultValue) - COMPILE_EXCEPTION(obj, tr("No property alias location")); + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","No property alias location")); if (prop.defaultValue->values.count() != 1 || prop.defaultValue->values.at(0)->object || !prop.defaultValue->values.at(0)->value.isScript()) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); + COMPILE_EXCEPTION(prop.defaultValue, qApp->translate("QmlCompiler","Invalid alias location")); QmlJS::AST::Node *node = prop.defaultValue->values.at(0)->value.asAST(); if (!node) - COMPILE_EXCEPTION(obj, tr("No property alias location")); // ### Can this happen? + COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","No property alias location")); // ### Can this happen? QStringList alias = astNodeToStringList(node); if (alias.count() != 1 && alias.count() != 2) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); + COMPILE_EXCEPTION(prop.defaultValue, qApp->translate("QmlCompiler","Invalid alias location")); if (!compileState.ids.contains(alias.at(0))) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); + COMPILE_EXCEPTION(prop.defaultValue, qApp->translate("QmlCompiler","Invalid alias location")); Object *idObject = compileState.ids[alias.at(0)]; @@ -2286,7 +2287,7 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData()); if (-1 == propIdx) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); + COMPILE_EXCEPTION(prop.defaultValue, qApp->translate("QmlCompiler","Invalid alias location")); QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx); writable = aliasProperty.isWritable(); @@ -2321,7 +2322,7 @@ bool QmlCompiler::buildBinding(QmlParser::Value *value, QMetaProperty mp = prop->parent->metaObject()->property(prop->index); if (!mp.isWritable() && !QmlMetaType::isList(prop->type)) - COMPILE_EXCEPTION(prop, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name))); + COMPILE_EXCEPTION(prop, qApp->translate("QmlCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name))); BindingReference reference; reference.expression = value->value; diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 6d6a25e..cff4937 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -135,9 +135,8 @@ private: }; class QMetaObjectBuilder; -class Q_DECLARATIVE_EXPORT QmlCompiler : public QObject +class Q_DECLARATIVE_EXPORT QmlCompiler { - Q_OBJECT public: QmlCompiler(); diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp index 75de985..862d6ba 100644 --- a/src/declarative/qml/qmlinfo.cpp +++ b/src/declarative/qml/qmlinfo.cpp @@ -75,9 +75,13 @@ QT_BEGIN_NAMESPACE void qmlInfo(const QString& msg, QObject* object) { - QString pos = QLatin1String("QML ") + QLatin1String(object->metaObject()->className()); + QString pos = QLatin1String("QML"); + if (object) { + pos += " "; + pos += QLatin1String(object->metaObject()->className()); + } QmlDeclarativeData *ddata = QmlDeclarativeData::get(object); - pos += QLatin1String("("); + pos += QLatin1String(" ("); if (ddata) { if (ddata->outerContext) { pos += ddata->outerContext->baseUrl().toString(); @@ -91,7 +95,7 @@ void qmlInfo(const QString& msg, QObject* object) } else { pos += qApp->translate("QmlInfo","unknown location"); } - pos += QLatin1String(")"); + pos += QLatin1String(") "); qWarning((pos + msg).toLocal8Bit()); // XXX allow other processing? } diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 675f5ae..1f3903d 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -63,6 +63,7 @@ #include "private/qmlvmemetaobject_p.h" #include #include +#include #include #include #include @@ -75,12 +76,8 @@ QmlVME::QmlVME() #define VME_EXCEPTION(desc) \ { \ - QString str; \ - QDebug d(&str); \ - d << desc; \ - str = str.trimmed(); \ QmlError error; \ - error.setDescription(str); \ + error.setDescription(desc.trimmed()); \ error.setLine(instr.line); \ error.setUrl(comp->url); \ vmeErrors << error; \ @@ -191,7 +188,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, if(types.at(instr.create.type).component) vmeErrors << types.at(instr.create.type).component->errors(); - VME_EXCEPTION("Unable to create object of type" << types.at(instr.create.type).className); + VME_EXCEPTION(qApp->translate("QmlVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className))); } QmlDeclarativeData *ddata = QmlDeclarativeData::get(o); @@ -498,7 +495,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QMetaProperty prop = target->metaObject()->property(instr.assignCustomType.propertyIndex); if (v.isNull() || ((int)prop.type() != data.type && prop.userType() != data.type)) - VME_EXCEPTION("Cannot assign value" << primitive << "to property" << prop.name()); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name()))); void *a[] = { (void *)v.data(), 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, @@ -520,15 +517,15 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QMetaMethod method = QmlMetaType::defaultMethod(assign); if (method.signature() == 0) - VME_EXCEPTION("Cannot assign object type" << assign->metaObject()->className() << "with no default method"); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className()))); if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature())) - VME_EXCEPTION("Cannot connect mismatched signal/slot" << method.signature() << prop.method().signature()); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature()))); QMetaObject::connect(target, prop.coreIndex(), assign, method.methodIndex()); } else { - VME_EXCEPTION("Cannot assign an object to signal property" << pr); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr))); } @@ -684,7 +681,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, if (iid) ptr = assign->qt_metacast(iid); if (!ptr) - VME_EXCEPTION("Cannot assign object to list"); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot assign object to list")); if (list.qmlListInterface) { @@ -730,7 +727,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, } if (!ok) - VME_EXCEPTION("Cannot assign object to interface property"); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot assign object to interface property")); } break; @@ -741,7 +738,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.fetchAttached.id, target); if (!qmlObject) - VME_EXCEPTION("Unable to create attached object"); + VME_EXCEPTION(qApp->translate("QmlVME","Unable to create attached object")); stack.push(qmlObject); } @@ -759,7 +756,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QMetaObject::metacall(target, QMetaObject::ReadProperty, instr.fetchQmlList.property, a); if (!list) - VME_EXCEPTION("Cannot assign to null list"); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot assign to null list")); qliststack.push(ListInstance(list, instr.fetchQmlList.type)); } @@ -777,7 +774,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QMetaObject::metacall(target, QMetaObject::ReadProperty, instr.fetchQmlList.property, a); if (!list) - VME_EXCEPTION("Cannot assign to null list"); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot assign to null list")); qliststack.push(ListInstance(list, instr.fetchQmlList.type)); } @@ -796,7 +793,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, instr.fetch.property, a); if (!obj) - VME_EXCEPTION("Cannot set properties on" << target->metaObject()->property(instr.fetch.property).name() << "as it is null"); + VME_EXCEPTION(qApp->translate("QmlVME","Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.fetch.property).name()))); stack.push(obj); } diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index 38b7fe8..ec977da 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -102,7 +102,7 @@ void tst_anchors::loops() view->setUrl(QUrl("file://" SRCDIR "/data/loop1.qml")); - QString expect = "QML QFxText (" + view->url().toString() + ":7:5" + ") Possible anchor loop detected on horizontal anchor. "; + QString expect = "QML QFxText (" + view->url().toString() + ":7:5" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); @@ -117,7 +117,7 @@ void tst_anchors::loops() view->setUrl(QUrl("file://" SRCDIR "/data/loop2.qml")); - QString expect = "QML QFxImage (" + view->url().toString() + ":14:3" + ") Possible anchor loop detected on horizontal anchor. "; + QString expect = "QML QFxImage (" + view->url().toString() + ":14:3" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -133,7 +133,7 @@ void tst_anchors::illegalSets() view->setUrl(QUrl("file://" SRCDIR "/data/illegal1.qml")); - QString expect = "QML QFxRect (" + view->url().toString() + ":7:5" + ") Can't specify left, right, and hcenter anchors. "; + QString expect = "QML QFxRect (" + view->url().toString() + ":7:5" + ") Can't specify left, right, and hcenter anchors."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -146,7 +146,7 @@ void tst_anchors::illegalSets() view->setUrl(QUrl("file://" SRCDIR "/data/illegal2.qml")); - QString expect = "QML QFxText (" + view->url().toString() + ":7:5" + ") Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors. "; + QString expect = "QML QFxText (" + view->url().toString() + ":7:5" + ") Baseline anchor can't be used in conjunction with top, bottom, or vcenter anchors."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); //qApp->processEvents(); @@ -159,7 +159,7 @@ void tst_anchors::illegalSets() view->setUrl(QUrl("file://" SRCDIR "/data/illegal3.qml")); - QString expect = "QML QFxRect (" + view->url().toString() + ":9:5" + ") Can't anchor to an item that isn't a parent or sibling. "; + QString expect = "QML QFxRect (" + view->url().toString() + ":9:5" + ") Can't anchor to an item that isn't a parent or sibling."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); //qApp->processEvents(); @@ -187,7 +187,7 @@ void tst_anchors::nullItem() { QFxAnchorLine anchor; - QTest::ignoreMessage(QtWarningMsg, "QML QFxItem (unknown location): Can't anchor to a null item. "); + QTest::ignoreMessage(QtWarningMsg, "QML QFxItem (unknown location) Can't anchor to a null item."); QFxItem *item = new QFxItem; item->anchors()->setBottom(anchor); } diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index f627527..0e46224 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -152,7 +152,7 @@ void tst_animations::badProperties() QFxRect *rect = qobject_cast(c.create()); QVERIFY(rect); - QTest::ignoreMessage(QtWarningMsg, "QML QmlColorAnimation (file://" SRCDIR "/data/badproperty1.qml:22:9) Cannot animate non-existant property \"pen.colr\" "); + QTest::ignoreMessage(QtWarningMsg, "QML QmlColorAnimation (file://" SRCDIR "/data/badproperty1.qml:22:9) Cannot animate non-existant property \"pen.colr\""); rect->setState("state1"); } } diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index f976e41..7fb1703 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -154,7 +154,7 @@ void tst_qmlecmascript::methods() void tst_qmlecmascript::bindingLoop() { QmlComponent component(&engine, TEST_FILE("bindingLoop.qml")); - QString warning = "QML MyQmlObject (" + component.url().toString() + ":9:9) Binding loop detected for property \"stringProperty\" "; + QString warning = "QML MyQmlObject (" + component.url().toString() + ":9:9) Binding loop detected for property \"stringProperty\""; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); QVERIFY(object != 0); -- cgit v0.12