diff options
17 files changed, 135 insertions, 158 deletions
diff --git a/bin/rename-qtdeclarative-symbols.sh b/bin/rename-qtdeclarative-symbols.sh index 0d521dd5a8..c9a70128ca 100755 --- a/bin/rename-qtdeclarative-symbols.sh +++ b/bin/rename-qtdeclarative-symbols.sh @@ -154,8 +154,6 @@ QML_SYMBOLS="\ QDeclarativeGuardedContextData QDeclarativeGuardImpl QDeclarativeHandlingSignalProfiler - QDeclarativeImageProvider - QDeclarativeImageProviderPrivate QDeclarativeImportDatabase QDeclarativeImportedNamespace QDeclarativeImports @@ -319,6 +317,8 @@ QUICK_SYMBOLS="\ QDeclarativeGestureAreaParser QDeclarativeGestureAreaPrivate QDeclarativeGraphics + QDeclarativeImageProvider + QDeclarativeImageProviderPrivate QDeclarativeItem QDeclarativeItemAccessor QDeclarativeItemChangeListener diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri index 0ce7c7ed5c..b3897637e8 100644 --- a/src/qml/qml/qml.pri +++ b/src/qml/qml/qml.pri @@ -40,7 +40,6 @@ SOURCES += \ $$PWD/qqmltypenamecache.cpp \ $$PWD/qqmlscriptstring.cpp \ $$PWD/qquickworkerscript.cpp \ - $$PWD/qqmlimageprovider.cpp \ $$PWD/qqmlnetworkaccessmanagerfactory.cpp \ $$PWD/qqmldirparser.cpp \ $$PWD/qqmlextensionplugin.cpp \ @@ -106,7 +105,6 @@ HEADERS += \ $$PWD/qqmlscriptstring.h \ $$PWD/qquickworkerscript_p.h \ $$PWD/qqmlguard_p.h \ - $$PWD/qqmlimageprovider.h \ $$PWD/qqmlnetworkaccessmanagerfactory.h \ $$PWD/qqmldirparser_p.h \ $$PWD/qqmlextensioninterface.h \ diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index ee5a0c954e..54c9d048df 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -60,7 +60,6 @@ #include "qquickworkerscript_p.h" #include "qqmlcomponent_p.h" #include "qqmlnetworkaccessmanagerfactory.h" -#include "qqmlimageprovider.h" #include "qqmldirparser_p.h" #include "qqmlextensioninterface.h" #include "qqmllist_p.h" @@ -181,6 +180,12 @@ void QQmlEnginePrivate::defineModule() qmlRegisterUncreatableType<QQmlLocale>("QtQuick",2,0,"Locale",QQmlEngine::tr("Locale cannot be instantiated. Use Qt.locale()")); } + +QQmlImageProviderBase::~QQmlImageProviderBase() +{ +} + + /*! \qmlclass Qt QQmlEnginePrivate \ingroup qml-utility-elements @@ -672,27 +677,29 @@ QNetworkAccessManager *QQmlEngine::networkAccessManager() const takes ownership of \a provider. Image providers enable support for pixmap and threaded image - requests. See the QQmlImageProvider documentation for details on + requests. See the QQuickImageProvider documentation for details on implementing and using image providers. All required image providers should be added to the engine before any QML sources files are loaded. - \sa removeImageProvider() + \sa removeImageProvider(), QQuickImageProvider */ -void QQmlEngine::addImageProvider(const QString &providerId, QQmlImageProvider *provider) +void QQmlEngine::addImageProvider(const QString &providerId, QQmlImageProviderBase *provider) { Q_D(QQmlEngine); QMutexLocker locker(&d->mutex); - d->imageProviders.insert(providerId.toLower(), QSharedPointer<QQmlImageProvider>(provider)); + d->imageProviders.insert(providerId.toLower(), QSharedPointer<QQmlImageProviderBase>(provider)); } /*! - Returns the QQmlImageProvider set for \a providerId. + Returns the image provider set for \a providerId. Returns the provider if it was found; otherwise returns 0. + + \sa QQuickImageProvider */ -QQmlImageProvider *QQmlEngine::imageProvider(const QString &providerId) const +QQmlImageProviderBase *QQmlEngine::imageProvider(const QString &providerId) const { Q_D(const QQmlEngine); QMutexLocker locker(&d->mutex); @@ -700,9 +707,9 @@ QQmlImageProvider *QQmlEngine::imageProvider(const QString &providerId) const } /*! - Removes the QQmlImageProvider for \a providerId. + Removes the image provider for \a providerId. - \sa addImageProvider() + \sa addImageProvider(), QQuickImageProvider */ void QQmlEngine::removeImageProvider(const QString &providerId) { @@ -711,54 +718,6 @@ void QQmlEngine::removeImageProvider(const QString &providerId) d->imageProviders.take(providerId); } -QQmlImageProvider::ImageType QQmlEnginePrivate::getImageProviderType(const QUrl &url) -{ - QMutexLocker locker(&mutex); - QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host()); - locker.unlock(); - if (provider) - return provider->imageType(); - return QQmlImageProvider::Invalid; -} - -QQuickTextureFactory *QQmlEnginePrivate::getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size) -{ - QMutexLocker locker(&mutex); - QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host()); - locker.unlock(); - if (provider) { - QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); - return provider->requestTexture(imageId, size, req_size); - } - return 0; -} - -QImage QQmlEnginePrivate::getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size) -{ - QMutexLocker locker(&mutex); - QImage image; - QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host()); - locker.unlock(); - if (provider) { - QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); - image = provider->requestImage(imageId, size, req_size); - } - return image; -} - -QPixmap QQmlEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size) -{ - QMutexLocker locker(&mutex); - QPixmap pixmap; - QSharedPointer<QQmlImageProvider> provider = imageProviders.value(url.host()); - locker.unlock(); - if (provider) { - QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); - pixmap = provider->requestPixmap(imageId, size, req_size); - } - return pixmap; -} - /*! Return the base URL for this engine. The base URL is only used to resolve components when a relative URL is passed to the diff --git a/src/qml/qml/qqmlengine.h b/src/qml/qml/qqmlengine.h index 04ac61c05b..41696923c5 100644 --- a/src/qml/qml/qqmlengine.h +++ b/src/qml/qml/qqmlengine.h @@ -54,6 +54,12 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +class Q_QML_EXPORT QQmlImageProviderBase +{ +public: + virtual ~QQmlImageProviderBase(); +}; + class QQmlComponent; class QQmlEnginePrivate; class QQmlImportsPrivate; @@ -62,7 +68,6 @@ class QQmlContext; class QQmlType; class QUrl; class QScriptContext; -class QQmlImageProvider; class QNetworkAccessManager; class QQmlNetworkAccessManagerFactory; class QQmlIncubationController; @@ -94,8 +99,8 @@ public: QNetworkAccessManager *networkAccessManager() const; - void addImageProvider(const QString &id, QQmlImageProvider *); - QQmlImageProvider *imageProvider(const QString &id) const; + void addImageProvider(const QString &id, QQmlImageProviderBase *); + QQmlImageProviderBase *imageProvider(const QString &id) const; void removeImageProvider(const QString &id); void setIncubationController(QQmlIncubationController *); diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h index db834489ba..73a0b5a217 100644 --- a/src/qml/qml/qqmlengine_p.h +++ b/src/qml/qml/qqmlengine_p.h @@ -63,7 +63,6 @@ #include "qqmlcontext.h" #include "qqmlcontext_p.h" #include "qqmlexpression.h" -#include "qqmlimageprovider.h" #include "qqmlproperty_p.h" #include "qqmlpropertycache_p.h" #include "qqmlmetatype_p.h" @@ -173,11 +172,7 @@ public: mutable QNetworkAccessManager *networkAccessManager; mutable QQmlNetworkAccessManagerFactory *networkAccessManagerFactory; - QHash<QString,QSharedPointer<QQmlImageProvider> > imageProviders; - QQmlImageProvider::ImageType getImageProviderType(const QUrl &url); - QQuickTextureFactory *getTextureFromProvider(const QUrl &url, QSize *size, const QSize& req_size); - QImage getImageFromProvider(const QUrl &url, QSize *size, const QSize& req_size); - QPixmap getPixmapFromProvider(const QUrl &url, QSize *size, const QSize& req_size); + QHash<QString,QSharedPointer<QQmlImageProviderBase> > imageProviders; // Scarce resources are "exceptionally high cost" QVariant types where allowing the // normal JavaScript GC to clean them up is likely to lead to out-of-memory or other diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 10276c17f8..ffc64b6edc 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -55,7 +55,6 @@ #include <QGuiApplication> #include <QOpenGLContext> -#include <QQmlImageProvider> #include <private/qqmlglobal_p.h> #include <QtQuick/private/qsgtexture_p.h> diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h index d0d8ea143b..acff222fb0 100644 --- a/src/quick/scenegraph/qsgcontextplugin_p.h +++ b/src/quick/scenegraph/qsgcontextplugin_p.h @@ -43,11 +43,10 @@ #define QSGCONTEXTPLUGIN_H #include <QtQuick/qtquickglobal.h> +#include <QtQuick/qquickimageprovider.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> -#include <QQmlImageProvider> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/qml/qml/qqmlimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp index 863093033a..4a1db050d6 100644 --- a/src/qml/qml/qqmlimageprovider.cpp +++ b/src/quick/util/qquickimageprovider.cpp @@ -39,14 +39,14 @@ ** ****************************************************************************/ -#include "qqmlimageprovider.h" +#include "qquickimageprovider.h" QT_BEGIN_NAMESPACE -class QQmlImageProviderPrivate +class QQuickImageProviderPrivate { public: - QQmlImageProvider::ImageType type; + QQuickImageProvider::ImageType type; }; /*! @@ -92,16 +92,16 @@ QQuickTextureFactory::~QQuickTextureFactory() /*! - \class QQmlImageProvider + \class QQuickImageProvider \since 4.7 - \brief The QQmlImageProvider class provides an interface for supporting pixmaps and threaded image requests in QML. + \brief The QQuickImageProvider class provides an interface for supporting pixmaps and threaded image requests in QML. - QQmlImageProvider is used to provide advanced image loading features + QQuickImageProvider is used to provide advanced image loading features in QML applications. It allows images in QML to be: \list \o Loaded using QPixmaps rather than actual image files - \o Loaded asynchronously in a separate thread, if imageType() is \l{QQmlImageProvider::ImageType}{ImageType::Image} + \o Loaded asynchronously in a separate thread, if imageType() is \l{QQuickImageProvider::ImageType}{ImageType::Image} \endlist To specify that an image should be loaded by an image provider, use the @@ -193,7 +193,7 @@ QQuickTextureFactory::~QQuickTextureFactory() \section2 Image caching - Images returned by a QQmlImageProvider are automatically cached, + Images returned by a QQuickImageProvider are automatically cached, similar to any image loaded by the QML engine. When an image with a "image://" prefix is loaded from cache, requestImage() and requestPixmap() will not be called for the relevant image provider. If an image should always @@ -205,7 +205,7 @@ QQuickTextureFactory::~QQuickTextureFactory() */ /*! - \enum QQmlImageProvider::ImageType + \enum QQuickImageProvider::ImageType Defines the type of image supported by this image provider. @@ -220,18 +220,18 @@ QQuickTextureFactory::~QQuickTextureFactory() /*! Creates an image provider that will provide images of the given \a type. */ -QQmlImageProvider::QQmlImageProvider(ImageType type) - : d(new QQmlImageProviderPrivate) +QQuickImageProvider::QQuickImageProvider(ImageType type) + : d(new QQuickImageProviderPrivate) { d->type = type; } /*! - Destroys the QQmlImageProvider + Destroys the QQuickImageProvider \note The destructor of your derived class need to be thread safe. */ -QQmlImageProvider::~QQmlImageProvider() +QQuickImageProvider::~QQuickImageProvider() { delete d; } @@ -239,7 +239,7 @@ QQmlImageProvider::~QQmlImageProvider() /*! Returns the image type supported by this provider. */ -QQmlImageProvider::ImageType QQmlImageProvider::imageType() const +QQuickImageProvider::ImageType QQuickImageProvider::imageType() const { return d->type; } @@ -263,7 +263,7 @@ QQmlImageProvider::ImageType QQmlImageProvider::imageType() const \note this method may be called by multiple threads, so ensure the implementation of this method is reentrant. */ -QImage QQmlImageProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize) +QImage QQuickImageProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize) { Q_UNUSED(id); Q_UNUSED(size); @@ -289,7 +289,7 @@ QImage QQmlImageProvider::requestImage(const QString &id, QSize *size, const QSi is used to set the \l {Item::}{width} and \l {Item::}{height} of the relevant \l Image if these values have not been set explicitly. */ -QPixmap QQmlImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) +QPixmap QQuickImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { Q_UNUSED(id); Q_UNUSED(size); @@ -320,7 +320,7 @@ QPixmap QQmlImageProvider::requestPixmap(const QString &id, QSize *size, const Q implementation of this method is reentrant. */ -QQuickTextureFactory *QQmlImageProvider::requestTexture(const QString &id, QSize *size, const QSize &requestedSize) +QQuickTextureFactory *QQuickImageProvider::requestTexture(const QString &id, QSize *size, const QSize &requestedSize) { Q_UNUSED(id); Q_UNUSED(size); diff --git a/src/qml/qml/qqmlimageprovider.h b/src/quick/util/qquickimageprovider.h index fe06925123..153a4bab8e 100644 --- a/src/qml/qml/qqmlimageprovider.h +++ b/src/quick/util/qquickimageprovider.h @@ -39,23 +39,24 @@ ** ****************************************************************************/ -#ifndef QQMLIMAGEPROVIDER_H -#define QQMLIMAGEPROVIDER_H +#ifndef QQUICKIMAGEPROVIDER_H +#define QQUICKIMAGEPROVIDER_H -#include <QtQml/qtqmlglobal.h> +#include <QtQuick/qtquickglobal.h> #include <QtGui/qimage.h> #include <QtGui/qpixmap.h> +#include <QtQml/qqmlengine.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QQmlImageProviderPrivate; +class QQuickImageProviderPrivate; class QSGTexture; class QQuickCanvas; -class Q_QML_EXPORT QQuickTextureFactory : public QObject +class Q_QUICK_EXPORT QQuickTextureFactory : public QObject { public: QQuickTextureFactory(); @@ -66,7 +67,7 @@ public: virtual int textureByteCount() const = 0; }; -class Q_QML_EXPORT QQmlImageProvider +class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase { public: enum ImageType { @@ -76,8 +77,8 @@ public: Invalid }; - QQmlImageProvider(ImageType type); - virtual ~QQmlImageProvider(); + QQuickImageProvider(ImageType type); + virtual ~QQuickImageProvider(); ImageType imageType() const; @@ -86,11 +87,11 @@ public: virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize); private: - QQmlImageProviderPrivate *d; + QQuickImageProviderPrivate *d; }; QT_END_NAMESPACE QT_END_HEADER -#endif // QQMLIMAGEPROVIDER +#endif // QQUICKIMAGEPROVIDER_H diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index aae5306aa7..350940c93c 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -41,7 +41,7 @@ #include "qquickpixmapcache_p.h" #include <qqmlnetworkaccessmanagerfactory.h> -#include <qqmlimageprovider.h> +#include <qquickimageprovider.h> #include <qqmlengine.h> #include <private/qqmlglobal_p.h> @@ -76,6 +76,16 @@ QT_BEGIN_NAMESPACE // The cache limit describes the maximum "junk" in the cache. static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded in qpixmapcache.cpp +static inline QString imageProviderId(const QUrl &url) +{ + return url.host(); +} + +static inline QString imageId(const QUrl &url) +{ + return url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); +} + QSGTexture *QQuickDefaultTextureFactory::createTexture(QQuickCanvas *) const { QSGPlainTexture *t = new QSGPlainTexture(); @@ -514,11 +524,15 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u { // fetch if (url.scheme() == QLatin1String("image")) { - // Use QmlImageProvider + // Use QQuickImageProvider QSize readSize; - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - QQmlImageProvider::ImageType imageType = ep->getImageProviderType(url); - if (imageType == QQmlImageProvider::Invalid) { + + QQuickImageProvider::ImageType imageType = QQuickImageProvider::Invalid; + QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(imageProviderId(url))); + if (provider) + imageType = provider->imageType(); + + if (imageType == QQuickImageProvider::Invalid) { QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::Loading; QString errorStr = QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString()); QImage image; @@ -526,8 +540,8 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, image); mutex.unlock(); - } else if (imageType == QQmlImageProvider::Image) { - QImage image = ep->getImageFromProvider(url, &readSize, requestSize); + } else if (imageType == QQuickImageProvider::Image) { + QImage image = provider->requestImage(imageId(url), &readSize, requestSize); QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError; QString errorStr; if (image.isNull()) { @@ -545,7 +559,7 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u mutex.unlock(); } else { - QQuickTextureFactory *t = ep->getTextureFromProvider(url, &readSize, requestSize); + QQuickTextureFactory *t = provider->requestTexture(imageId(url), &readSize, requestSize); QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError; QString errorStr; if (!t) { @@ -945,33 +959,36 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q { if (url.scheme() == QLatin1String("image")) { QSize readSize; - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - QQmlImageProvider::ImageType imageType = ep->getImageProviderType(url); + + QQuickImageProvider::ImageType imageType = QQuickImageProvider::Invalid; + QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(imageProviderId(url))); + if (provider) + imageType = provider->imageType(); switch (imageType) { - case QQmlImageProvider::Invalid: + case QQuickImageProvider::Invalid: return new QQuickPixmapData(declarativePixmap, url, requestSize, QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString())); - case QQmlImageProvider::Texture: + case QQuickImageProvider::Texture: { - QQuickTextureFactory *texture = ep->getTextureFromProvider(url, &readSize, requestSize); + QQuickTextureFactory *texture = provider->requestTexture(imageId(url), &readSize, requestSize); if (texture) { *ok = true; return new QQuickPixmapData(declarativePixmap, url, texture, QImage(), readSize, requestSize); } } - case QQmlImageProvider::Image: + case QQuickImageProvider::Image: { - QImage image = ep->getImageFromProvider(url, &readSize, requestSize); + QImage image = provider->requestImage(imageId(url), &readSize, requestSize); if (!image.isNull()) { *ok = true; return new QQuickPixmapData(declarativePixmap, url, image, readSize, requestSize); } } - case QQmlImageProvider::Pixmap: + case QQuickImageProvider::Pixmap: { - QPixmap pixmap = ep->getPixmapFromProvider(url, &readSize, requestSize); + QPixmap pixmap = provider->requestPixmap(imageId(url), &readSize, requestSize); if (!pixmap.isNull()) { *ok = true; return new QQuickPixmapData(declarativePixmap, url, pixmap.toImage(), readSize, requestSize); @@ -1180,9 +1197,11 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques if (iter == store->m_cache.end()) { if (options & QQuickPixmap::Asynchronous) { // pixmaps can only be loaded synchronously - if (url.scheme() == QLatin1String("image") - && QQmlEnginePrivate::get(engine)->getImageProviderType(url) == QQmlImageProvider::Pixmap) { - options &= ~QQuickPixmap::Asynchronous; + if (url.scheme() == QLatin1String("image")) { + QQuickImageProvider *provider = static_cast<QQuickImageProvider *>(engine->imageProvider(imageProviderId(url))); + if (provider && provider->imageType() == QQuickImageProvider::Pixmap) { + options &= ~QQuickPixmap::Asynchronous; + } } } diff --git a/src/quick/util/qquickpixmapcache_p.h b/src/quick/util/qquickpixmapcache_p.h index 0b4c2fb473..ef17a12709 100644 --- a/src/quick/util/qquickpixmapcache_p.h +++ b/src/quick/util/qquickpixmapcache_p.h @@ -47,9 +47,9 @@ #include <QtGui/qpixmap.h> #include <QtCore/qurl.h> #include <QtQuick/qtquickglobal.h> +#include <QtQuick/qquickimageprovider.h> #include <private/qintrusivelist_p.h> -#include <qqmlimageprovider.h> QT_BEGIN_HEADER diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri index c3cec91404..d720ef02c9 100644 --- a/src/quick/util/util.pri +++ b/src/quick/util/util.pri @@ -25,6 +25,7 @@ SOURCES += \ $$PWD/qquickchangeset.cpp \ $$PWD/qquicklistcompositor.cpp \ $$PWD/qquickpathinterpolator.cpp \ + $$PWD/qquickimageprovider.cpp \ $$PWD/qquicksvgparser.cpp HEADERS += \ @@ -58,4 +59,5 @@ HEADERS += \ $$PWD/qquickchangeset_p.h \ $$PWD/qquicklistcompositor_p.h \ $$PWD/qquickpathinterpolator_p.h \ + $$PWD/qquickimageprovider.h \ $$PWD/qquicksvgparser_p.h diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index bcfbcbdbf0..d58a29066d 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -32,7 +32,6 @@ PRIVATETESTS += \ qqmlcpputils \ qqmlecmascript \ qqmlexpression \ - qqmlimageprovider \ qqmlinstruction \ qqmllanguage \ qqmlproperty \ diff --git a/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro b/tests/auto/quick/qquickimageprovider/qquickimageprovider.pro index 9feeee15fd..269f06a046 100644 --- a/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro +++ b/tests/auto/quick/qquickimageprovider/qquickimageprovider.pro @@ -1,8 +1,8 @@ CONFIG += testcase -TARGET = tst_qqmlimageprovider +TARGET = tst_qquickimageprovider macx:CONFIG -= app_bundle -SOURCES += tst_qqmlimageprovider.cpp +SOURCES += tst_qquickimageprovider.cpp CONFIG += parallel_test diff --git a/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp index bc53544566..7f9a0efb33 100644 --- a/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp +++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp @@ -41,18 +41,18 @@ #include <qtest.h> #include <QtTest/QtTest> #include <QtQml/qqmlengine.h> -#include <QtQml/qqmlimageprovider.h> +#include <QtQuick/qquickimageprovider.h> #include <private/qquickimage_p.h> #include <QImageReader> #include <QWaitCondition> -Q_DECLARE_METATYPE(QQmlImageProvider*); +Q_DECLARE_METATYPE(QQuickImageProvider*); -class tst_qqmlimageprovider : public QObject +class tst_qquickimageprovider : public QObject { Q_OBJECT public: - tst_qqmlimageprovider() + tst_qquickimageprovider() { } @@ -74,15 +74,15 @@ private slots: private: QString newImageFileName() const; void fillRequestTestsData(const QString &id); - void runTest(bool async, QQmlImageProvider *provider); + void runTest(bool async, QQuickImageProvider *provider); }; -class TestQImageProvider : public QQmlImageProvider +class TestQImageProvider : public QQuickImageProvider { public: TestQImageProvider(bool *deleteWatch = 0) - : QQmlImageProvider(Image), deleteWatch(deleteWatch) + : QQuickImageProvider(Image), deleteWatch(deleteWatch) { } @@ -115,11 +115,11 @@ public: Q_DECLARE_METATYPE(TestQImageProvider*); -class TestQPixmapProvider : public QQmlImageProvider +class TestQPixmapProvider : public QQuickImageProvider { public: TestQPixmapProvider(bool *deleteWatch = 0) - : QQmlImageProvider(Pixmap), deleteWatch(deleteWatch) + : QQuickImageProvider(Pixmap), deleteWatch(deleteWatch) { } @@ -152,7 +152,7 @@ public: Q_DECLARE_METATYPE(TestQPixmapProvider*); -QString tst_qqmlimageprovider::newImageFileName() const +QString tst_qquickimageprovider::newImageFileName() const { // need to generate new filenames each time or else images are loaded // from cache and we won't get loading status changes when testing @@ -161,7 +161,7 @@ QString tst_qqmlimageprovider::newImageFileName() const return QString("image://test/image-%1.png").arg(count++); } -void tst_qqmlimageprovider::fillRequestTestsData(const QString &id) +void tst_qquickimageprovider::fillRequestTestsData(const QString &id) { QTest::addColumn<QString>("source"); QTest::addColumn<QString>("imageId"); @@ -207,7 +207,7 @@ void tst_qqmlimageprovider::fillRequestTestsData(const QString &id) << "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png"; } -void tst_qqmlimageprovider::runTest(bool async, QQmlImageProvider *provider) +void tst_qquickimageprovider::runTest(bool async, QQuickImageProvider *provider) { QFETCH(QString, source); QFETCH(QString, imageId); @@ -260,46 +260,46 @@ void tst_qqmlimageprovider::runTest(bool async, QQmlImageProvider *provider) delete obj; } -void tst_qqmlimageprovider::requestImage_sync_data() +void tst_qquickimageprovider::requestImage_sync_data() { fillRequestTestsData("qimage|sync"); } -void tst_qqmlimageprovider::requestImage_sync() +void tst_qquickimageprovider::requestImage_sync() { bool deleteWatch = false; runTest(false, new TestQImageProvider(&deleteWatch)); QVERIFY(deleteWatch); } -void tst_qqmlimageprovider::requestImage_async_data() +void tst_qquickimageprovider::requestImage_async_data() { fillRequestTestsData("qimage|async"); } -void tst_qqmlimageprovider::requestImage_async() +void tst_qquickimageprovider::requestImage_async() { bool deleteWatch = false; runTest(true, new TestQImageProvider(&deleteWatch)); QVERIFY(deleteWatch); } -void tst_qqmlimageprovider::requestPixmap_sync_data() +void tst_qquickimageprovider::requestPixmap_sync_data() { fillRequestTestsData("qpixmap"); } -void tst_qqmlimageprovider::requestPixmap_sync() +void tst_qquickimageprovider::requestPixmap_sync() { bool deleteWatch = false; runTest(false, new TestQPixmapProvider(&deleteWatch)); QVERIFY(deleteWatch); } -void tst_qqmlimageprovider::requestPixmap_async() +void tst_qquickimageprovider::requestPixmap_async() { QQmlEngine engine; - QQmlImageProvider *provider = new TestQPixmapProvider(); + QQuickImageProvider *provider = new TestQPixmapProvider(); engine.addImageProvider("test", provider); QVERIFY(engine.imageProvider("test") != 0); @@ -314,17 +314,17 @@ void tst_qqmlimageprovider::requestPixmap_async() delete obj; } -void tst_qqmlimageprovider::removeProvider_data() +void tst_qquickimageprovider::removeProvider_data() { - QTest::addColumn<QQmlImageProvider*>("provider"); + QTest::addColumn<QQuickImageProvider*>("provider"); - QTest::newRow("qimage") << static_cast<QQmlImageProvider*>(new TestQImageProvider); - QTest::newRow("qpixmap") << static_cast<QQmlImageProvider*>(new TestQPixmapProvider); + QTest::newRow("qimage") << static_cast<QQuickImageProvider*>(new TestQImageProvider); + QTest::newRow("qpixmap") << static_cast<QQuickImageProvider*>(new TestQPixmapProvider); } -void tst_qqmlimageprovider::removeProvider() +void tst_qquickimageprovider::removeProvider() { - QFETCH(QQmlImageProvider*, provider); + QFETCH(QQuickImageProvider*, provider); QQmlEngine engine; @@ -353,10 +353,10 @@ void tst_qqmlimageprovider::removeProvider() delete obj; } -class TestThreadProvider : public QQmlImageProvider +class TestThreadProvider : public QQuickImageProvider { public: - TestThreadProvider() : QQmlImageProvider(Image), ok(false) {} + TestThreadProvider() : QQuickImageProvider(Image), ok(false) {} ~TestThreadProvider() {} @@ -384,7 +384,7 @@ class TestThreadProvider : public QQmlImageProvider }; -void tst_qqmlimageprovider::threadTest() +void tst_qquickimageprovider::threadTest() { QQmlEngine engine; @@ -419,6 +419,6 @@ void tst_qqmlimageprovider::threadTest() } -QTEST_MAIN(tst_qqmlimageprovider) +QTEST_MAIN(tst_qquickimageprovider) -#include "tst_qqmlimageprovider.moc" +#include "tst_qquickimageprovider.moc" diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp index 855322e376..8d2eb66e08 100644 --- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp +++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp @@ -42,7 +42,7 @@ #include <QtTest/QtTest> #include <QtQuick/private/qquickpixmapcache_p.h> #include <QtQml/qqmlengine.h> -#include <QtQml/qqmlimageprovider.h> +#include <QtQuick/qquickimageprovider.h> #include <QNetworkReply> #include "../../shared/util.h" #include "testhttpserver.h" @@ -335,11 +335,11 @@ void tst_qquickpixmapcache::cancelcrash() } } -class MyPixmapProvider : public QQmlImageProvider +class MyPixmapProvider : public QQuickImageProvider { public: MyPixmapProvider() - : QQmlImageProvider(Pixmap) {} + : QQuickImageProvider(Pixmap) {} virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) { Q_UNUSED(d) diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 4065dbf508..45fa9763da 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -15,6 +15,7 @@ PRIVATETESTS += \ qquickapplication \ qquickbehaviors \ qquickfontloader \ + qquickimageprovider \ qquickpath \ qquicksmoothedanimation \ qquickspringanimation \ |