summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-02-16 03:50:28 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-02-16 03:50:28 (GMT)
commita17c34cdddf4bcc619fa660ea520400a1329b34e (patch)
treee279b9621f4a5739bdb443dd6cc7e70745abe86c /src/declarative
parent2ad3954c6a383553f000d5d223eff4acf34d3c77 (diff)
parent6f3649260d157584361112a94733b92f10c01b84 (diff)
downloadQt-a17c34cdddf4bcc619fa660ea520400a1329b34e.zip
Qt-a17c34cdddf4bcc619fa660ea520400a1329b34e.tar.gz
Qt-a17c34cdddf4bcc619fa660ea520400a1329b34e.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/debugger/qmldebug.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp4
-rw-r--r--src/declarative/qml/qml.pri2
-rw-r--r--src/declarative/qml/qmlcleanup.cpp4
-rw-r--r--src/declarative/qml/qmlcompositetypedata_p.h2
-rw-r--r--src/declarative/qml/qmlengine.cpp89
-rw-r--r--src/declarative/qml/qmlengine.h5
-rw-r--r--src/declarative/qml/qmlengine_p.h7
-rw-r--r--src/declarative/qml/qmlimageprovider.cpp68
-rw-r--r--src/declarative/qml/qmlimageprovider.h64
-rw-r--r--src/declarative/qml/qmlmetatype.cpp3
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp4
-rw-r--r--src/declarative/qml/qmlscriptstring.h4
-rw-r--r--src/declarative/qml/qmlsqldatabase.cpp3
-rw-r--r--src/declarative/qml/qmlsqldatabase_p.h4
-rw-r--r--src/declarative/qml/qmlstringconverters_p.h4
-rw-r--r--src/declarative/qml/qmlworkerscript.cpp10
-rw-r--r--src/declarative/qml/qmlxmlhttprequest.cpp8
-rw-r--r--src/declarative/qml/qmlxmlhttprequest_p.h4
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp42
-rw-r--r--src/declarative/util/qmlstategroup.cpp4
-rw-r--r--src/declarative/util/qmlstyledtext.cpp4
-rw-r--r--src/declarative/util/qmlstyledtext_p.h5
-rw-r--r--src/declarative/util/qmlxmllistmodel.cpp4
26 files changed, 318 insertions, 52 deletions
diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp
index dc779ac..41e27bc 100644
--- a/src/declarative/debugger/qmldebug.cpp
+++ b/src/declarative/debugger/qmldebug.cpp
@@ -47,6 +47,8 @@
#include <private/qobject_p.h>
+QT_BEGIN_NAMESPACE
+
class QmlEngineDebugClient : public QmlDebugClient
{
public:
@@ -142,8 +144,6 @@ void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugExpressionQuery *q
}
}
-
-Q_DECLARE_METATYPE(QmlDebugObjectReference);
void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o,
bool simple)
{
@@ -932,3 +932,7 @@ bool QmlDebugPropertyReference::hasNotifySignal() const
{
return m_hasNotifySignal;
}
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QmlDebugObjectReference);
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
index 5b02158..22eabdd 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
@@ -87,9 +87,6 @@ public:
return item == other.item && anchorLine == other.anchorLine;
}
};
-Q_DECLARE_METATYPE(QmlGraphicsAnchorLine)
-
-
class QmlGraphicsAnchorsPrivate : public QObjectPrivate, public QmlGraphicsItemChangeListener
{
@@ -171,4 +168,7 @@ public:
};
QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QmlGraphicsAnchorLine)
+
#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index 9fd8702..2fbf18b 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -2070,10 +2070,6 @@ void QmlGraphicsItem::setBaselineOffset(qreal offset)
color: "blue"
width: 100; height: 100
Rectangle {
- color: "green"
- width: 25; height: 25
- }
- Rectangle {
color: "red"
x: 25; y: 25; width: 50; height: 50
rotation: 30
@@ -2884,6 +2880,6 @@ int QmlGraphicsItemPrivate::restart(QTime &t)
return n;
}
-#include <moc_qmlgraphicsitem.cpp>
-
QT_END_NAMESPACE
+
+#include <moc_qmlgraphicsitem.cpp>
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
index b4487a6..cc416d0 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
@@ -62,8 +62,6 @@
#include <private/qobject_p.h>
-QML_DECLARE_TYPE(QListModelInterface)
-
QT_BEGIN_NAMESPACE
QHash<QObject*, QmlGraphicsVisualItemModelAttached*> QmlGraphicsVisualItemModelAttached::attachedProperties;
@@ -1110,4 +1108,6 @@ void QmlGraphicsVisualDataModel::_q_destroyingPackage(QmlPackage *package)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QListModelInterface)
+
#include <qmlgraphicsvisualitemmodel.moc>
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index cd2fbff..021ef9e 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -50,6 +50,7 @@ SOURCES += \
$$PWD/qmltypenamescriptclass.cpp \
$$PWD/qmllistscriptclass.cpp \
$$PWD/qmlworkerscript.cpp \
+ $$PWD/qmlimageprovider.cpp \
$$PWD/qmlnetworkaccessmanagerfactory.cpp
HEADERS += \
$$PWD/qmlparser_p.h \
@@ -117,6 +118,7 @@ HEADERS += \
$$PWD/qmlworkerscript_p.h \
$$PWD/qmlscriptclass_p.h \
$$PWD/qmlguard_p.h \
+ $$PWD/qmlimageprovider.h \
$$PWD/qmlnetworkaccessmanagerfactory.h
QT += sql
include(parser/parser.pri)
diff --git a/src/declarative/qml/qmlcleanup.cpp b/src/declarative/qml/qmlcleanup.cpp
index 599e4e7..e7767d2 100644
--- a/src/declarative/qml/qmlcleanup.cpp
+++ b/src/declarative/qml/qmlcleanup.cpp
@@ -43,6 +43,8 @@
#include "qmlengine_p.h"
+QT_BEGIN_NAMESPACE
+
/*!
\internal
\class QmlCleanup
@@ -82,4 +84,4 @@ QmlCleanup::~QmlCleanup()
prev = 0;
next = 0;
}
-
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h
index c8b9f25..5358963 100644
--- a/src/declarative/qml/qmlcompositetypedata_p.h
+++ b/src/declarative/qml/qmlcompositetypedata_p.h
@@ -146,5 +146,7 @@ public:
QByteArray data;
};
+QT_END_NAMESPACE
+
#endif // QMLCOMPOSITETYPEDATA_P_H
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 35fc3d4..7da24f4 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -65,6 +65,7 @@
#include "qmlcomponent_p.h"
#include "qmlscriptclass_p.h"
#include "qmlnetworkaccessmanagerfactory.h"
+#include "qmlimageprovider.h"
#include <qfxperf_p_p.h>
@@ -85,6 +86,7 @@
#include <QtCore/qthread.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
+#include <QtCore/qmutex.h>
#include <QtGui/qcolor.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qsound.h>
@@ -432,6 +434,7 @@ QmlContext *QmlEngine::rootContext()
void QmlEngine::setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *factory)
{
Q_D(QmlEngine);
+ QMutexLocker locker(&d->mutex);
d->networkAccessManagerFactory = factory;
}
@@ -446,17 +449,24 @@ QmlNetworkAccessManagerFactory *QmlEngine::networkAccessManagerFactory() const
return d->networkAccessManagerFactory;
}
+QNetworkAccessManager *QmlEnginePrivate::createNetworkAccessManager(QObject *parent) const
+{
+ QMutexLocker locker(&mutex);
+ QNetworkAccessManager *nam;
+ if (networkAccessManagerFactory) {
+ nam = networkAccessManagerFactory->create(parent);
+ } else {
+ nam = new QNetworkAccessManager(parent);
+ }
+
+ return nam;
+}
+
QNetworkAccessManager *QmlEnginePrivate::getNetworkAccessManager() const
{
Q_Q(const QmlEngine);
-
- if (!networkAccessManager) {
- if (networkAccessManagerFactory) {
- networkAccessManager = networkAccessManagerFactory->create(const_cast<QmlEngine*>(q));
- } else {
- networkAccessManager = new QNetworkAccessManager(const_cast<QmlEngine*>(q));
- }
- }
+ if (!networkAccessManager)
+ networkAccessManager = createNetworkAccessManager(const_cast<QmlEngine*>(q));
return networkAccessManager;
}
@@ -478,6 +488,69 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const
}
/*!
+ Sets the \a provider to use for images requested via the \e image: url
+ scheme, with host \a providerId.
+
+ QmlImageProvider allows images to be provided to QML asynchronously.
+ The image request will be run in a low priority thread. This allows
+ potentially costly image loading to be done in the background, without
+ affecting the performance of the UI.
+
+ Note that images loaded from a QmlImageProvider are cached by
+ QPixmapCache, similar to any image loaded by QML.
+
+ The QmlEngine assumes ownership of the provider.
+
+ This example creates a provider with id \e colors:
+
+ \snippet examples/declarative/imageprovider/main.cpp 0
+
+ \snippet examples/declarative/imageprovider/view.qml 0
+
+ \sa removeImageProvider()
+*/
+void QmlEngine::addImageProvider(const QString &providerId, QmlImageProvider *provider)
+{
+ Q_D(QmlEngine);
+ QMutexLocker locker(&d->mutex);
+ d->imageProviders.insert(providerId, provider);
+}
+
+/*!
+ Returns the QmlImageProvider set for \a providerId.
+*/
+QmlImageProvider *QmlEngine::imageProvider(const QString &providerId) const
+{
+ Q_D(const QmlEngine);
+ QMutexLocker locker(&d->mutex);
+ return d->imageProviders.value(providerId);
+}
+
+/*!
+ Removes the QmlImageProvider for \a providerId.
+
+ Returns the provider if it was found; otherwise returns 0.
+
+ \sa addImageProvider()
+*/
+void QmlEngine::removeImageProvider(const QString &providerId)
+{
+ Q_D(QmlEngine);
+ QMutexLocker locker(&d->mutex);
+ delete d->imageProviders.take(providerId);
+}
+
+QImage QmlEnginePrivate::getImageFromProvider(const QUrl &url)
+{
+ QMutexLocker locker(&mutex);
+ QImage image;
+ QmlImageProvider *provider = imageProviders.value(url.host());
+ if (provider)
+ image = provider->request(url.path().mid(1));
+ return image;
+}
+
+/*!
Return the base URL for this engine. The base URL is only used to resolve
components when a relative URL is passed to the QmlComponent constructor.
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
index 7ee014a..a59a1ba 100644
--- a/src/declarative/qml/qmlengine.h
+++ b/src/declarative/qml/qmlengine.h
@@ -62,6 +62,7 @@ class QmlType;
class QUrl;
class QScriptEngine;
class QScriptContext;
+class QmlImageProvider;
class QNetworkAccessManager;
class QmlNetworkAccessManagerFactory;
class Q_DECLARATIVE_EXPORT QmlEngine : public QObject
@@ -83,6 +84,10 @@ public:
QNetworkAccessManager *networkAccessManager() const;
+ void addImageProvider(const QString &id, QmlImageProvider *);
+ QmlImageProvider *imageProvider(const QString &id) const;
+ void removeImageProvider(const QString &id);
+
void setOfflineStoragePath(const QString& dir);
QString offlineStoragePath() const;
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 13ed5ef..87864b7 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -75,6 +75,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qpair.h>
#include <QtCore/qstack.h>
+#include <QtCore/qmutex.h>
#include <QtScript/qscriptengine.h>
#include <private/qobject_p.h>
@@ -211,10 +212,16 @@ public:
bool inBeginCreate;
+ QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
QNetworkAccessManager *getNetworkAccessManager() const;
mutable QNetworkAccessManager *networkAccessManager;
mutable QmlNetworkAccessManagerFactory *networkAccessManagerFactory;
+ QHash<QString,QmlImageProvider*> imageProviders;
+ QImage getImageFromProvider(const QUrl &url);
+
+ mutable QMutex mutex;
+
QmlCompositeTypeManager typeManager;
QStringList fileImportPath;
QString offlineStoragePath;
diff --git a/src/declarative/qml/qmlimageprovider.cpp b/src/declarative/qml/qmlimageprovider.cpp
new file mode 100644
index 0000000..ebb8656
--- /dev/null
+++ b/src/declarative/qml/qmlimageprovider.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlimageprovider.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QmlImageProvider
+ \brief The QmlImageProvider class provides an interface for threaded image requests.
+
+ Note: the request() method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+
+ \sa QmlEngine::addImageProvider()
+*/
+QmlImageProvider::~QmlImageProvider()
+{
+}
+
+/*!
+ \fn QImage QmlImageProvider::request(const QString &id)
+
+ Implement this method to return the image with \a id.
+
+ Note: this method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlimageprovider.h b/src/declarative/qml/qmlimageprovider.h
new file mode 100644
index 0000000..9804815
--- /dev/null
+++ b/src/declarative/qml/qmlimageprovider.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLIMAGEPROVIDER_H
+#define QMLIMAGEPROVIDER_H
+
+#include <QtGui/qimage.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QmlImageProvider
+{
+public:
+ virtual ~QmlImageProvider();
+ virtual QImage request(const QString &id) = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMLIMAGEPROVIDER
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index e66f600..7dfc48d 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -840,6 +840,8 @@ QList<QmlType*> QmlMetaType::qmlTypes()
return data->nameToType.values();
}
+QT_END_NAMESPACE
+
#include <QtGui/qfont.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qbrush.h>
@@ -867,6 +869,7 @@ QList<QmlType*> QmlMetaType::qmlTypes()
Q_DECLARE_METATYPE(QScriptValue);
+QT_BEGIN_NAMESPACE
/*!
Copies \a copy into \a data, assuming they both are of type \a type. If
\a copy is zero, a default type is copied. Returns true if the copy was
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
index 04cffe1..a0a7cea 100644
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ b/src/declarative/qml/qmlpropertycache.cpp
@@ -45,10 +45,10 @@
#include "qmlbinding.h"
#include "qdebug.h"
-QT_BEGIN_NAMESPACE
-
Q_DECLARE_METATYPE(QScriptValue);
+QT_BEGIN_NAMESPACE
+
void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
{
propType = p.userType();
diff --git a/src/declarative/qml/qmlscriptstring.h b/src/declarative/qml/qmlscriptstring.h
index 73a473f..d07137e 100644
--- a/src/declarative/qml/qmlscriptstring.h
+++ b/src/declarative/qml/qmlscriptstring.h
@@ -77,10 +77,10 @@ private:
QSharedDataPointer<QmlScriptStringPrivate> d;
};
-Q_DECLARE_METATYPE(QmlScriptString);
-
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QmlScriptString);
+
QT_END_HEADER
#endif // QMLSCRIPTSTRING_H
diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp
index 684caa2..9c951fc 100644
--- a/src/declarative/qml/qmlsqldatabase.cpp
+++ b/src/declarative/qml/qmlsqldatabase.cpp
@@ -65,6 +65,8 @@
Q_DECLARE_METATYPE(QSqlDatabase)
Q_DECLARE_METATYPE(QSqlQuery)
+QT_BEGIN_NAMESPACE
+
class QmlSqlQueryScriptClass: public QScriptClass {
public:
QmlSqlQueryScriptClass(QScriptEngine *engine) : QScriptClass(engine)
@@ -423,3 +425,4 @@ We add a "forwardOnly" property that stops Qt caching results (code promises to
through the data.
*/
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlsqldatabase_p.h b/src/declarative/qml/qmlsqldatabase_p.h
index 5a38bf0..9965a2b 100644
--- a/src/declarative/qml/qmlsqldatabase_p.h
+++ b/src/declarative/qml/qmlsqldatabase_p.h
@@ -42,6 +42,7 @@
#ifndef QMLSQLDATABASE_P_H
#define QMLSQLDATABASE_P_H
+#include <QtScript/qscriptengine.h>
//
// W A R N I N G
// -------------
@@ -52,9 +53,12 @@
//
// We mean it.
//
+QT_BEGIN_NAMESPACE
class QScriptEngine;
void qt_add_qmlsqldatabase(QScriptEngine *engine);
+QT_END_NAMESPACE
+
#endif // QMLSQLDATABASE_P_H
diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h
index dfc59ce..46b2de6 100644
--- a/src/declarative/qml/qmlstringconverters_p.h
+++ b/src/declarative/qml/qmlstringconverters_p.h
@@ -56,6 +56,8 @@
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
+QT_BEGIN_NAMESPACE
+
class QColor;
class QPointF;
class QSizeF;
@@ -64,8 +66,6 @@ class QString;
class QByteArray;
class QVector3D;
-QT_BEGIN_NAMESPACE
-
// XXX - Bauhaus currently uses these methods which is why they're exported
namespace QmlStringConverters
{
diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp
index 5e39eaf..ec790ca 100644
--- a/src/declarative/qml/qmlworkerscript.cpp
+++ b/src/declarative/qml/qmlworkerscript.cpp
@@ -55,6 +55,7 @@
#include <QtDeclarative/qmlinfo.h>
#include "qmlnetworkaccessmanagerfactory.h"
+
QT_BEGIN_NAMESPACE
class WorkerDataEvent : public QEvent
@@ -238,8 +239,13 @@ private:
QAtomicInt m_ref;
QmlWorkerListModel *m_model;
};
+
+QT_END_NAMESPACE
+
Q_DECLARE_METATYPE(QmlWorkerListModelAgent::VariantRef);
+QT_BEGIN_NAMESPACE
+
QmlWorkerScriptEnginePrivate::QmlWorkerScriptEnginePrivate(QmlEngine *engine)
: workerEngine(0), qmlengine(engine), m_nextId(0)
{
@@ -1030,8 +1036,10 @@ QVariant QmlWorkerListModel::data(int index, int role) const
return m_values.at(index).value(role);
}
+QT_END_NAMESPACE
+
QML_DEFINE_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel)
#include "qmlworkerscript.moc"
-QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp
index 1883d1b..54e26df 100644
--- a/src/declarative/qml/qmlxmlhttprequest.cpp
+++ b/src/declarative/qml/qmlxmlhttprequest.cpp
@@ -91,7 +91,7 @@
#define D(arg) (arg)->release()
#define A(arg) (arg)->addref()
-namespace {
+QT_BEGIN_NAMESPACE
class DocumentImpl;
class NodeImpl
@@ -315,12 +315,14 @@ public:
static QScriptValue load(QScriptEngine *engine, const QString &data);
};
-}; // namespace
+QT_END_NAMESPACE
Q_DECLARE_METATYPE(Node);
Q_DECLARE_METATYPE(NodeList);
Q_DECLARE_METATYPE(NamedNodeMap);
+QT_BEGIN_NAMESPACE
+
void NodeImpl::addref()
{
A(document);
@@ -1624,4 +1626,6 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine)
engine->globalObject().setProperty(QLatin1String("DOMException"), domExceptionPrototype);
}
+QT_END_NAMESPACE
+
#include <qmlxmlhttprequest.moc>
diff --git a/src/declarative/qml/qmlxmlhttprequest_p.h b/src/declarative/qml/qmlxmlhttprequest_p.h
index dfed5d2..3a81278 100644
--- a/src/declarative/qml/qmlxmlhttprequest_p.h
+++ b/src/declarative/qml/qmlxmlhttprequest_p.h
@@ -42,6 +42,7 @@
#ifndef QMLXMLHTTPREQUEST_P_H
#define QMLXMLHTTPREQUEST_P_H
+#include <QtScript/qscriptengine.h>
//
// W A R N I N G
// -------------
@@ -52,9 +53,12 @@
//
// We mean it.
//
+QT_BEGIN_NAMESPACE
class QScriptEngine;
void qt_add_qmlxmlhttprequest(QScriptEngine *engine);
+QT_END_NAMESPACE
+
#endif // QMLXMLHTTPREQUEST_P_H
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
index c03b5df..4e581bd 100644
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ b/src/declarative/util/qmlpixmapcache.cpp
@@ -41,11 +41,13 @@
#include "qmlpixmapcache_p.h"
#include "qmlnetworkaccessmanagerfactory.h"
+#include "qmlimageprovider.h"
#include "qfxperf_p_p.h"
#include <qmlengine.h>
#include <private/qmlglobal_p.h>
+#include <private/qmlengine_p.h>
#include <QCoreApplication>
#include <QImageReader>
@@ -82,7 +84,7 @@ class QmlImageReaderEvent : public QEvent
public:
enum ReadError { NoError, Loading, Decoding };
- QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, QImage &img)
+ QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, const QImage &img)
: QEvent(QEvent::User), error(err), errorString(errStr), image(img) {}
ReadError error;
@@ -143,13 +145,8 @@ private slots:
private:
QNetworkAccessManager *networkAccessManager() {
- if (!accessManager) {
- if (engine && engine->networkAccessManagerFactory()) {
- accessManager = engine->networkAccessManagerFactory()->create(this);
- } else {
- accessManager = new QNetworkAccessManager(this);
- }
- }
+ if (!accessManager)
+ accessManager = QmlEnginePrivate::get(engine)->createNetworkAccessManager(this);
return accessManager;
}
@@ -197,21 +194,32 @@ bool QmlImageRequestHandler::event(QEvent *event)
break;
}
- QmlPixmapReply *runningJob = reader->jobs.takeFirst();
+ QmlPixmapReply *runningJob = reader->jobs.takeLast();
runningJob->addRef();
runningJob->setLoading();
QUrl url = runningJob->url();
reader->mutex.unlock();
// fetch
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- QNetworkReply *reply = networkAccessManager()->get(req);
+ if (url.scheme() == QLatin1String("image")) {
+ QImage image = QmlEnginePrivate::get(engine)->getImageFromProvider(url);
+ QmlImageReaderEvent::ReadError errorCode = QmlImageReaderEvent::NoError;
+ QString errorStr;
+ if (image.isNull()) {
+ errorCode = QmlImageReaderEvent::Loading;
+ errorStr = QLatin1String("Failed to get image from provider: ") + url.toString();
+ }
+ QCoreApplication::postEvent(runningJob, new QmlImageReaderEvent(errorCode, errorStr, image));
+ } else {
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ QNetworkReply *reply = networkAccessManager()->get(req);
- QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
- QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
+ QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
+ QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
- replies.insert(reply, runningJob);
+ replies.insert(reply, runningJob);
+ }
}
return true;
}
@@ -600,6 +608,6 @@ int QmlPixmapCache::pendingRequests()
return qmlActivePixmapReplies()->count();
}
-#include <qmlpixmapcache.moc>
-
QT_END_NAMESPACE
+
+#include <qmlpixmapcache.moc>
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
index d4db2b9..aad19d9 100644
--- a/src/declarative/util/qmlstategroup.cpp
+++ b/src/declarative/util/qmlstategroup.cpp
@@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup)
-
class QmlStateGroupPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlStateGroup)
@@ -421,3 +419,5 @@ void QmlStateGroup::removeState(QmlState *state)
}
QT_END_NAMESPACE
+
+QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup)
diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qmlstyledtext.cpp
index 36b5e49..63f341e 100644
--- a/src/declarative/util/qmlstyledtext.cpp
+++ b/src/declarative/util/qmlstyledtext.cpp
@@ -58,6 +58,8 @@
The opening and closing tags must be correctly nested.
*/
+QT_BEGIN_NAMESPACE
+
class QmlStyledTextPrivate
{
public:
@@ -341,3 +343,5 @@ QStringRef QmlStyledTextPrivate::parseValue(const QChar *&ch, const QString &tex
return QStringRef(&textIn, valStart, valLength);
}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qmlstyledtext_p.h
index 0cfb43e..502a4b5 100644
--- a/src/declarative/util/qmlstyledtext_p.h
+++ b/src/declarative/util/qmlstyledtext_p.h
@@ -44,10 +44,13 @@
#include <QSizeF>
+QT_BEGIN_NAMESPACE
+
class QPainter;
class QPointF;
class QString;
class QmlStyledTextPrivate;
+
class Q_DECLARATIVE_EXPORT QmlStyledText
{
public:
@@ -60,4 +63,6 @@ private:
QmlStyledTextPrivate *d;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp
index d31fadf..b2c2e61 100644
--- a/src/declarative/util/qmlxmllistmodel.cpp
+++ b/src/declarative/util/qmlxmllistmodel.cpp
@@ -126,8 +126,6 @@ private:
QString m_query;
};
-QML_DECLARE_TYPE(QmlXmlListModelRole)
-
class QmlXmlListModelPrivate;
struct QmlXmlRoleList : public QmlConcreteList<QmlXmlListModelRole *>
{
@@ -725,4 +723,6 @@ void QmlXmlListModel::queryCompleted(int id, int size)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlXmlListModelRole)
+
#include <qmlxmllistmodel.moc>