Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativeengine.cpp
index 5de1e57..335eb75 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 "qdeclarativeengine_p.h"
 #include "qdeclarativeengine.h"
+#include "qdeclarativecomponentattached_p.h"
 
 #include "qdeclarativecontext_p.h"
 #include "qdeclarativecompiler_p.h"
 #include <private/qdeclarativedebugtrace_p.h>
 #include <private/qdeclarativeapplication_p.h>
 #include <private/qv8debugservice_p.h>
+#include <private/qdebugmessageservice_p.h>
 #include "qdeclarativeincubator.h"
 #include <private/qv8profilerservice_p.h>
 
+#include <QtCore/qstandardpaths.h>
+#include <QtCore/qsettings.h>
+
 #include <QtCore/qmetaobject.h>
 #include <QNetworkAccessManager>
 #include <QDebug>
@@ -83,7 +88,6 @@
 
 #include <private/qobject_p.h>
 
-#include <private/qtquick2_p.h>
 #include <private/qdeclarativelocale_p.h>
 
 #ifdef Q_OS_WIN // for %APPDATA%
@@ -159,7 +163,6 @@ void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor)
     \endcode
 */
 
-static bool qt_QmlQtModule_registered = false;
 bool QDeclarativeEnginePrivate::qml_debugging_enabled = false;
 
 void QDeclarativeEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
@@ -341,12 +344,8 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
   workerScriptEngine(0), activeVME(0),
   networkAccessManager(0), networkAccessManagerFactory(0),
   scarceResourcesRefCount(0), typeLoader(e), importDatabase(e), uniqueId(1),
-  incubatorCount(0), incubationController(0), sgContext(0), mutex(QMutex::Recursive)
+  incubatorCount(0), incubationController(0), mutex(QMutex::Recursive)
 {
-    if (!qt_QmlQtModule_registered) {
-        qt_QmlQtModule_registered = true;
-        QDeclarativeQtQuick2Module::defineModule();
-    }
 }
 
 QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate()
@@ -424,11 +423,7 @@ void QDeclarativeEnginePrivate::init()
 
     static bool firstTime = true;
     if (firstTime) {
-        // This is a nasty hack as QNetworkAccessManager will issue a 
-        // BlockingQueuedConnection to the main thread if it is initialized for the
-        // first time on a non-main thread.  This can cause a lockup if the main thread
-        // is blocking on the thread that initialize the network access manager.
-        QNetworkConfigurationManager man;
+        qmlRegisterType<QDeclarativeComponent>("QML", 1, 0, "Component");
 
         firstTime = false;
     }
@@ -451,10 +446,16 @@ void QDeclarativeEnginePrivate::init()
         QDeclarativeEngineDebugService::isDebuggingEnabled()) {
         isDebugging = true;
         QDeclarativeEngineDebugService::instance()->addEngine(q);
-        QV8DebugService::initialize();
+        QV8DebugService::initialize(v8engine());
         QV8ProfilerService::initialize();
         QDeclarativeDebugTrace::initialize();
+        QDebugMessageService::instance();
     }
+
+    QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+    offlineStoragePath = dataLocation.replace(QLatin1Char('/'), QDir::separator()) +
+                         QDir::separator() + QLatin1String("QML") +
+                         QDir::separator() + QLatin1String("OfflineStorage");
 }
 
 QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine()
@@ -714,7 +715,7 @@ QDeclarativeImageProvider::ImageType QDeclarativeEnginePrivate::getImageProvider
     return QDeclarativeImageProvider::Invalid;
 }
 
-QSGTexture *QDeclarativeEnginePrivate::getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
+QDeclarativeTextureFactory *QDeclarativeEnginePrivate::getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size)
 {
     QMutexLocker locker(&mutex);
     QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
@@ -965,7 +966,7 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
             QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(object->metaObject()->className());
             QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, typeName);
             if (data->outerContext)
-                QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Creating, data->outerContext->url, data->lineNumber);
+                QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Creating, data->outerContext->url, data->lineNumber, data->columnNumber);
         }
         QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine);
 
@@ -1544,13 +1545,13 @@ bool QDeclarativeEngine::importPlugin(const QString &filePath, const QString &ur
 void QDeclarativeEngine::setOfflineStoragePath(const QString& dir)
 {
     Q_D(QDeclarativeEngine);
-    qt_qmlsqldatabase_setOfflineStoragePath(d->v8engine(), dir);
+    d->offlineStoragePath = dir;
 }
 
 QString QDeclarativeEngine::offlineStoragePath() const
 {
     Q_D(const QDeclarativeEngine);
-    return qt_qmlsqldatabase_getOfflineStoragePath(d->v8engine());
+    return d->offlineStoragePath;
 }
 
 static void voidptr_destructor(void *v)
@@ -1578,10 +1579,7 @@ QDeclarativePropertyCache *QDeclarativeEnginePrivate::createCache(const QMetaObj
         return rv;
     } else {
         QDeclarativePropertyCache *super = cache(mo->superClass());
-        QDeclarativePropertyCache *rv = super->copy(mo->propertyCount() + mo->methodCount() - 
-                                                    mo->superClass()->propertyCount() - 
-                                                    mo->superClass()->methodCount());
-        rv->append(q, mo);
+        QDeclarativePropertyCache *rv = super->copyAndAppend(q, mo);
         propertyCache.insert(mo, rv);
         return rv;
     }
@@ -1796,14 +1794,13 @@ void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *
 
 bool QDeclarative_isFileCaseCorrect(const QString &fileName)
 {
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
     QFileInfo info(fileName);
-
-    QString absolute = info.absoluteFilePath();
+    const QString absolute = info.absoluteFilePath();
 
 #if defined(Q_OS_MAC)
-    QString canonical = info.canonicalFilePath();
-#elif defined(Q_OS_WIN32)
+    const QString canonical = info.canonicalFilePath();
+#elif defined(Q_OS_WIN)
     wchar_t buffer[1024];
 
     DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024);
@@ -1811,13 +1808,13 @@ bool QDeclarative_isFileCaseCorrect(const QString &fileName)
     rv = ::GetLongPathName(buffer, buffer, 1024);
     if (rv == 0 || rv >= 1024) return true;
 
-    QString canonical((QChar *)buffer);
+    const QString canonical = QString::fromWCharArray(buffer);
 #endif
 
-    int absoluteLength = absolute.length();
-    int canonicalLength = canonical.length();
+    const int absoluteLength = absolute.length();
+    const int canonicalLength = canonical.length();
 
-    int length = qMin(absoluteLength, canonicalLength);
+    const int length = qMin(absoluteLength, canonicalLength);
     for (int ii = 0; ii < length; ++ii) {
         const QChar &a = absolute.at(absoluteLength - 1 - ii);
         const QChar &c = canonical.at(canonicalLength - 1 - ii);