Initial bundle support
[profile/ivi/qtdeclarative.git] / src / qml / qml / qqmldirparser.cpp
index df5f7f8..2da4a33 100644 (file)
@@ -43,6 +43,7 @@
 #include "qqmlerror.h"
 #include "qqmlglobal_p.h"
 
+#include <QtQml/qqmlfile.h>
 #include <QtCore/QTextStream>
 #include <QtCore/QFile>
 #include <QtCore/QtDebug>
@@ -58,26 +59,6 @@ QQmlDirParser::~QQmlDirParser()
 {
 }
 
-QUrl QQmlDirParser::url() const
-{
-    return _url;
-}
-
-void QQmlDirParser::setUrl(const QUrl &url)
-{
-    _url = url;
-}
-
-QString QQmlDirParser::fileSource() const
-{
-    return _filePathSouce;
-}
-
-void QQmlDirParser::setFileSource(const QString &filePath)
-{
-    _filePathSouce = filePath;
-}
-
 QString QQmlDirParser::source() const
 {
     return _source;
@@ -94,6 +75,9 @@ bool QQmlDirParser::isParsed() const
     return _isParsed;
 }
 
+/*!
+\a url is used for generating errors.
+*/
 bool QQmlDirParser::parse()
 {
     if (_isParsed)
@@ -105,23 +89,6 @@ bool QQmlDirParser::parse()
     _components.clear();
     _scripts.clear();
 
-    if (_source.isEmpty() && !_filePathSouce.isEmpty()) {
-        QFile file(_filePathSouce);
-        if (!QQml_isFileCaseCorrect(_filePathSouce)) {
-            QQmlError error;
-            error.setDescription(QString::fromUtf8("cannot load module \"$$URI$$\": File name case mismatch for \"%1\"").arg(_filePathSouce));
-            _errors.prepend(error);
-            return false;
-        } else if (file.open(QFile::ReadOnly)) {
-            _source = QString::fromUtf8(file.readAll());
-        } else {
-            QQmlError error;
-            error.setDescription(QString::fromUtf8("module \"$$URI$$\" definition \"%1\" not readable").arg(_filePathSouce));
-            _errors.prepend(error);
-            return false;
-        }
-    }
-
     QTextStream stream(&_source);
     int lineNumber = 0;
 
@@ -246,7 +213,6 @@ bool QQmlDirParser::parse()
 void QQmlDirParser::reportError(int line, int column, const QString &description)
 {
     QQmlError error;
-    error.setUrl(_url);
     error.setLine(line);
     error.setColumn(column);
     error.setDescription(description);
@@ -261,6 +227,12 @@ bool QQmlDirParser::hasError() const
     return false;
 }
 
+void QQmlDirParser::setError(const QQmlError &e)
+{
+    _errors.clear();
+    _errors.append(e);
+}
+
 QList<QQmlError> QQmlDirParser::errors(const QString &uri) const
 {
     QList<QQmlError> errors = _errors;
@@ -297,16 +269,16 @@ QList<QQmlDirParser::TypeInfo> QQmlDirParser::typeInfos() const
 
 QDebug &operator<< (QDebug &debug, const QQmlDirParser::Component &component)
 {
-    return debug << qPrintable(QString("{%1 %2.%3}").arg(component.typeName)
-                                                    .arg(component.majorVersion)
-                                                    .arg(component.minorVersion));
+    const QString output = QString::fromLatin1("{%1 %2.%3}").
+        arg(component.typeName).arg(component.majorVersion).arg(component.minorVersion);
+    return debug << qPrintable(output);
 }
 
 QDebug &operator<< (QDebug &debug, const QQmlDirParser::Script &script)
 {
-    return debug << qPrintable(QString("{%1 %2.%3}").arg(script.nameSpace)
-                                                    .arg(script.majorVersion)
-                                                    .arg(script.minorVersion));
+    const QString output = QString::fromLatin1("{%1 %2.%3}").
+        arg(script.nameSpace).arg(script.majorVersion).arg(script.minorVersion);
+    return debug << qPrintable(output);
 }
 
 QT_END_NAMESPACE