diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-10-13 02:36:05 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-10-13 02:36:05 (GMT) |
commit | 5e31c0cae45bae6f66decfb37825ed5d445e49e4 (patch) | |
tree | 3feade068e8543f56a0eec9054fdba0dfb83740c /src/declarative/qml | |
parent | d71db342a34690438878684f054dca820f77b1b9 (diff) | |
download | Qt-5e31c0cae45bae6f66decfb37825ed5d445e49e4.zip Qt-5e31c0cae45bae6f66decfb37825ed5d445e49e4.tar.gz Qt-5e31c0cae45bae6f66decfb37825ed5d445e49e4.tar.bz2 |
More i18n
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/parser/qmljs.g | 11 | ||||
-rw-r--r-- | src/declarative/qml/parser/qmljsengine_p.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/parser/qmljsgrammar.cpp | 32 | ||||
-rw-r--r-- | src/declarative/qml/parser/qmljsgrammar_p.h | 32 | ||||
-rw-r--r-- | src/declarative/qml/parser/qmljsparser.cpp | 11 | ||||
-rw-r--r-- | src/declarative/qml/qmlbinding.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 151 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler_p.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlinfo.cpp | 53 | ||||
-rw-r--r-- | src/declarative/qml/qmlinfo.h | 12 |
10 files changed, 140 insertions, 170 deletions
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 <QtCore/QtDebug> +#include <QApplication> #include <string.h> @@ -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 <QtCore/QtDebug> +#include <QApplication> #include <string.h> @@ -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 <private/qmldeclarativedata_p.h> #include <QtDeclarative/qmlcontext.h> +#include <QtGui/qapplication.h> 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 |