Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativedirparser.cpp
index 49cb40f..f7d5be3 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the QtDeclarative module of the Qt Toolkit.
 **
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 
-#include "private/qdeclarativedirparser_p.h"
+#include "qdeclarativedirparser_p.h"
 #include "qdeclarativeerror.h"
-#include <private/qdeclarativeglobal_p.h>
-#include <private/qdeclarativeutils_p.h>
+#include "qdeclarativeglobal_p.h"
 
 #include <QtCore/QTextStream>
 #include <QtCore/QFile>
@@ -104,6 +103,7 @@ bool QDeclarativeDirParser::parse()
     _errors.clear();
     _plugins.clear();
     _components.clear();
+    _scripts.clear();
 
     if (_source.isEmpty() && !_filePathSouce.isEmpty()) {
         QFile file(_filePathSouce);
@@ -141,9 +141,9 @@ bool QDeclarativeDirParser::parse()
         while (index != length) {
             const QChar ch = line.at(index);
 
-            if (QDeclarativeUtils::isSpace(ch)) {
+            if (ch.isSpace()) {
                 do { ++index; }
-                while (index != length && QDeclarativeUtils::isSpace(line.at(index)));
+                while (index != length && line.at(index).isSpace());
 
             } else if (ch == QLatin1Char('#')) {
                 // recognized a comment
@@ -153,7 +153,7 @@ bool QDeclarativeDirParser::parse()
                 const int start = index;
 
                 do { ++index; }
-                while (index != length && !QDeclarativeUtils::isSpace(line.at(index)));
+                while (index != length && !line.at(index).isSpace());
 
                 const QString lexeme = line.mid(start, index - start);
 
@@ -187,7 +187,7 @@ bool QDeclarativeDirParser::parse()
                             QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
                 continue;
             }
-            Component entry(sections[1].toUtf8(), sections[2], -1, -1);
+            Component entry(sections[1], sections[2], -1, -1);
             entry.internal = true;
             _components.append(entry);
         } else if (sections[0] == QLatin1String("typeinfo")) {
@@ -203,7 +203,7 @@ bool QDeclarativeDirParser::parse()
 
         } else if (sectionCount == 2) {
             // No version specified (should only be used for relative qmldir files)
-            const Component entry(sections[0].toUtf8(), sections[1], -1, -1);
+            const Component entry(sections[0], sections[1], -1, -1);
             _components.append(entry);
         } else if (sectionCount == 3) {
             const QString &version = sections[1];
@@ -221,9 +221,16 @@ bool QDeclarativeDirParser::parse()
                     const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
 
                     if (validVersionNumber) {
-                        const Component entry(sections[0].toUtf8(), sections[2], majorVersion, minorVersion);
-
-                        _components.append(entry);
+                        const QString &fileName = sections[2];
+
+                        if (fileName.endsWith(QLatin1String(".js"))) {
+                            // A 'js' extension indicates a namespaced script import
+                            const Script entry(sections[0], fileName, majorVersion, minorVersion);
+                            _scripts.append(entry);
+                        } else {
+                            const Component entry(sections[0], fileName, majorVersion, minorVersion);
+                            _components.append(entry);
+                        }
                     }
                 }
             }
@@ -276,6 +283,11 @@ QList<QDeclarativeDirParser::Component> QDeclarativeDirParser::components() cons
     return _components;
 }
 
+QList<QDeclarativeDirParser::Script> QDeclarativeDirParser::scripts() const
+{
+    return _scripts;
+}
+
 #ifdef QT_CREATOR
 QList<QDeclarativeDirParser::TypeInfo> QDeclarativeDirParser::typeInfos() const
 {