summaryrefslogtreecommitdiffstats
path: root/tools/linguist
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-06-29 20:25:35 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-06-29 20:25:35 (GMT)
commit3acc686f9b2de7a261fc28e256b9f87ee5e341bc (patch)
tree83f1869e327afaf0031dcbe33298236227a9d700 /tools/linguist
parentb4afd4e4cabce0347e155803afd8ff1a7b90f080 (diff)
parentf75d82c7c3364c5f4e5b3799cbeb9daae4cf6e61 (diff)
downloadQt-3acc686f9b2de7a261fc28e256b9f87ee5e341bc.zip
Qt-3acc686f9b2de7a261fc28e256b9f87ee5e341bc.tar.gz
Qt-3acc686f9b2de7a261fc28e256b9f87ee5e341bc.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (54 commits) update qml.qch to version 4.7 Undefined is undefined, and now qml warns about it Fix so window will resize with the root object (broken by Avoid duplicate code for testing initial sizes Remove an unnecessary connect() in TextInput Ensure micro focus is updated in TextEdit and TextInput Fix flow layout not taking into account whether it's width and height are implicit or not. Avoid binding loop. Ensure Loader item change listener is removed when Loader is destroyed Adapt all qmlviewer testcases to the code changes in the actual viewer. Stop QMLLauncher from crashing on exit on Mac when quitting app via the VisualDataModel hasModelChildren role shadowed user roles. Allow positioning of ListView items width sub-pixel precision. Examples clean up Docs Improve appearance when scaling Tweak Qt Demo Behaviour forget to rename the moc include when renaming deviceorientation_maemo.cpp fix namespace macros fix QML Viewer resize modes ...
Diffstat (limited to 'tools/linguist')
-rw-r--r--tools/linguist/lupdate/qdeclarative.cpp84
1 files changed, 58 insertions, 26 deletions
diff --git a/tools/linguist/lupdate/qdeclarative.cpp b/tools/linguist/lupdate/qdeclarative.cpp
index a734e99..2377416 100644
--- a/tools/linguist/lupdate/qdeclarative.cpp
+++ b/tools/linguist/lupdate/qdeclarative.cpp
@@ -87,27 +87,31 @@ protected:
virtual void endVisit(AST::CallExpression *node)
{
+ m_bSource.clear();
if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(node->base)) {
if (idExpr->name->asString() == QLatin1String("qsTr") ||
idExpr->name->asString() == QLatin1String("QT_TR_NOOP")) {
- if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) {
- AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
- const QString source = literal->value->asString();
+ if (!node->arguments)
+ return;
+ AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(node->arguments->expression);
+ if (binary) {
+ if (!createString(binary))
+ m_bSource.clear();
+ }
+ AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
+ if (literal || !m_bSource.isEmpty()) {
+ const QString source = literal ? literal->value->asString() : m_bSource;
QString comment;
bool plural = false;
AST::ArgumentList *commentNode = node->arguments->next;
- if (commentNode) {
+ if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) {
literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
comment = literal->value->asString();
AST::ArgumentList *nNode = commentNode->next;
- if (nNode) {
- AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
- if (numLiteral) {
- plural = true;
- }
- }
+ if (nNode)
+ plural = true;
}
TranslatorMessage msg(m_component, source,
@@ -126,22 +130,25 @@ protected:
QString comment;
bool plural = false;
AST::ArgumentList *sourceNode = node->arguments->next;
- if (sourceNode) {
- literal = AST::cast<AST::StringLiteral *>(sourceNode->expression);
- source = literal->value->asString();
- AST::ArgumentList *commentNode = sourceNode->next;
- if (commentNode) {
- literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
- comment = literal->value->asString();
-
- AST::ArgumentList *nNode = commentNode->next;
- if (nNode) {
- AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
- if (numLiteral) {
- plural = true;
- }
- }
- }
+ if (!sourceNode)
+ return;
+ literal = AST::cast<AST::StringLiteral *>(sourceNode->expression);
+ AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(sourceNode->expression);
+ if (binary) {
+ if (!createString(binary))
+ m_bSource.clear();
+ }
+ if (!literal && m_bSource.isEmpty())
+ return;
+ source = literal ? literal->value->asString() : m_bSource;
+ AST::ArgumentList *commentNode = sourceNode->next;
+ if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) {
+ literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
+ comment = literal->value->asString();
+
+ AST::ArgumentList *nNode = commentNode->next;
+ if (nNode)
+ plural = true;
}
TranslatorMessage msg(context, source,
@@ -156,9 +163,34 @@ protected:
}
private:
+ bool createString(AST::BinaryExpression *b) {
+ if (!b || b->op != 0)
+ return false;
+ AST::BinaryExpression *l = AST::cast<AST::BinaryExpression *>(b->left);
+ AST::BinaryExpression *r = AST::cast<AST::BinaryExpression *>(b->right);
+ AST::StringLiteral *ls = AST::cast<AST::StringLiteral *>(b->left);
+ AST::StringLiteral *rs = AST::cast<AST::StringLiteral *>(b->right);
+ if ((!l && !ls) || (!r && !rs))
+ return false;
+ if (l) {
+ if (!createString(l))
+ return false;
+ } else
+ m_bSource.prepend(ls->value->asString());
+
+ if (r) {
+ if (!createString(r))
+ return false;
+ } else
+ m_bSource.append(rs->value->asString());
+
+ return true;
+ }
+
Translator *m_translator;
QString m_fileName;
QString m_component;
+ QString m_bSource;
};
QString createErrorString(const QString &filename, const QString &code, Parser &parser)