collect messages from INSTALL and DEPLOYMENT file lists
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Mon, 19 Aug 2013 16:54:03 +0000 (18:54 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 27 Aug 2013 11:34:33 +0000 (13:34 +0200)
Task-number: QTBUG-14056
Change-Id: I1e014885f92b8587462d926e552834915fc1be60
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
src/linguist/lupdate/main.cpp
tests/auto/linguist/lupdate/testdata/good/proparsing/main.qml [new file with mode: 0644]
tests/auto/linguist/lupdate/testdata/good/proparsing/project.pro
tests/auto/linguist/lupdate/testdata/good/proparsing/project.ts.result
tests/auto/linguist/lupdate/testdata/good/proparsing/qml/excluded.cpp [new file with mode: 0644]
tests/auto/linguist/lupdate/testdata/good/proparsing/qml/notmain.qml [new file with mode: 0644]

index dd2133d..c0d20fa 100644 (file)
@@ -49,6 +49,7 @@
 #include <QtCore/QCoreApplication>
 #include <QtCore/QDebug>
 #include <QtCore/QDir>
+#include <QtCore/QDirIterator>
 #include <QtCore/QFile>
 #include <QtCore/QFileInfo>
 #include <QtCore/QString>
@@ -437,6 +438,41 @@ static QStringList getSources(const ProFileEvaluator &visitor, const QString &pr
     vPathsInc.removeDuplicates();
     sourceFiles += visitor.absoluteFileValues(QLatin1String("HEADERS"), projectDir, vPathsInc, 0);
 
+    QStringList installs = visitor.values(QLatin1String("INSTALLS"))
+                         + visitor.values(QLatin1String("DEPLOYMENT"));
+    installs.removeDuplicates();
+    QDir baseDir(projectDir);
+    foreach (const QString inst, installs) {
+        foreach (const QString &file, visitor.values(inst + QLatin1String(".files"))) {
+            QFileInfo info(file);
+            if (!info.isAbsolute())
+                info.setFile(baseDir.absoluteFilePath(file));
+            QStringList nameFilter;
+            QString searchPath;
+            if (info.isDir()) {
+                nameFilter << QLatin1String("*");
+                searchPath = info.filePath();
+            } else {
+                nameFilter << info.fileName();
+                searchPath = info.path();
+            }
+
+            QDirIterator iterator(searchPath, nameFilter,
+                                  QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks,
+                                  QDirIterator::Subdirectories);
+            while (iterator.hasNext()) {
+                iterator.next();
+                QFileInfo cfi = iterator.fileInfo();
+                QString ext = cfi.suffix();
+                if (ext == QLatin1String("qml")
+                    || ext == QLatin1String("js") || ext == QLatin1String("qs")
+                    || ext == QLatin1String("ui") || ext == QLatin1String("jui")) {
+                    sourceFiles << cfi.filePath();
+                }
+            }
+        }
+    }
+
     sourceFiles.removeDuplicates();
     sourceFiles.sort();
 
diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/main.qml b/tests/auto/linguist/lupdate/testdata/good/proparsing/main.qml
new file mode 100644 (file)
index 0000000..36cc5f0
--- /dev/null
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** 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, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+QtObject {
+    function translate() {
+        qsTr("From QML file in root");
+    }
+}
index a63c4e3..7c6ad99 100644 (file)
@@ -28,4 +28,7 @@ if (exists($$member($$(PATH), 0))) {
     SOURCES += main_dependpath.cpp
 }
 
+inst.files = qml *.qml
+INSTALLS += inst
+
 TRANSLATIONS = project.ts
index eb9119d..391f2f9 100644 (file)
         <translation type="unfinished"></translation>
     </message>
 </context>
+<context>
+    <name>main</name>
+    <message>
+        <location filename="main.qml" line="46"/>
+        <source>From QML file in root</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
+    <name>notmain</name>
+    <message>
+        <location filename="qml/notmain.qml" line="46"/>
+        <source>From QML file in qml</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
 </TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/qml/excluded.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/qml/excluded.cpp
new file mode 100644 (file)
index 0000000..2d1b144
--- /dev/null
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** 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, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+int main(int argc, char **argv)
+{
+     QString fake = QApplication::tr("fake", "This message will not be collected");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/qml/notmain.qml b/tests/auto/linguist/lupdate/testdata/good/proparsing/qml/notmain.qml
new file mode 100644 (file)
index 0000000..1a40221
--- /dev/null
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** 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, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+QtObject {
+    function translate() {
+        qsTr("From QML file in qml");
+    }
+}