Provide imageType() from QQmlImageProviderBase
authorMatthew Vogt <matthew.vogt@nokia.com>
Wed, 21 Mar 2012 07:55:07 +0000 (17:55 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 21 Mar 2012 08:41:49 +0000 (09:41 +0100)
Clients who are only interested in the type of image data provided
by an image provider should not need to cast the base pointer to
a QQuickImageProvider to access this information.

Also make the QQmlImageProviderBase constructor private to prevent
unwanted inheritance; all implementors should use the
QQuickImageProvider class.

Change-Id: Ia2dd2595c2711fa7df47265c9857f45ef0f4cc41
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
src/qml/qml/qqmlengine.cpp
src/qml/qml/qqmlengine.h
src/quick/util/qquickimageprovider.cpp
src/quick/util/qquickimageprovider.h

index b1fcadd..6729960 100644 (file)
@@ -177,6 +177,38 @@ void QQmlEnginePrivate::defineModule()
 }
 
 
+/*!
+    \class QQmlImageProviderBase
+    \brief The QQmlImageProviderBase class is used to register image providers in the QML engine.
+    \mainclass
+
+    Image providers must be registered with the QML engine.  The only information the QML
+    engine knows about image providers is the type of image data they provide.  To use an
+    image provider to acquire image data, you must cast the QQmlImageProviderBase pointer
+    to a QQuickImageProvider pointer.
+
+    \sa QQuickImageProvider, QQuickTextureFactory
+*/
+
+/*!
+    \enum QQmlImageProviderBase::ImageType
+
+    Defines the type of image supported by this image provider.
+
+    \value Image The Image Provider provides QImage images.
+        The QQuickImageProvider::requestImage() method will be called for all image requests.
+    \value Pixmap The Image Provider provides QPixmap images.
+        The QQuickImageProvider::requestPixmap() method will be called for all image requests.
+    \value Texture The Image Provider provides QSGTextureProvider based images.
+        The QQuickImageProvider::requestTexture() method will be called for all image requests. \omitvalue
+*/
+
+/*! \internal */
+QQmlImageProviderBase::QQmlImageProviderBase()
+{
+}
+
+/*! \internal */
 QQmlImageProviderBase::~QQmlImageProviderBase()
 {
 }
@@ -679,7 +711,7 @@ QNetworkAccessManager *QQmlEngine::networkAccessManager() const
   All required image providers should be added to the engine before any
   QML sources files are loaded.
 
-  \sa removeImageProvider(), QQuickImageProvider
+  \sa removeImageProvider(), QQuickImageProvider, QQmlImageProviderBase
 */
 void QQmlEngine::addImageProvider(const QString &providerId, QQmlImageProviderBase *provider)
 {
index 4169692..21a03d6 100644 (file)
@@ -57,7 +57,20 @@ QT_BEGIN_NAMESPACE
 class Q_QML_EXPORT QQmlImageProviderBase
 {
 public:
+    enum ImageType {
+        Image,
+        Pixmap,
+        Texture,
+        Invalid
+    };
+
     virtual ~QQmlImageProviderBase();
+
+    virtual ImageType imageType() const = 0;
+
+private:
+    friend class QQuickImageProvider;
+    QQmlImageProviderBase();
 };
 
 class QQmlComponent;
index a5d2720..1d838ca 100644 (file)
@@ -222,19 +222,6 @@ QImage QQuickTextureFactory::image() const
 */
 
 /*!
-    \enum QQuickImageProvider::ImageType
-
-    Defines the type of image supported by this image provider.
-
-    \value Image The Image Provider provides QImage images. The 
-        requestImage() method will be called for all image requests.
-    \value Pixmap The Image Provider provides QPixmap images. The 
-        requestPixmap() method will be called for all image requests.
-    \value Texture The Image Provider provides QSGTextureProvider based images.
-        The requestTexture() method will be called for all image requests. \omitvalue
-*/
-
-/*!
     Creates an image provider that will provide images of the given \a type.
 */
 QQuickImageProvider::QQuickImageProvider(ImageType type)
index 2a5d146..252d57b 100644 (file)
@@ -71,13 +71,6 @@ public:
 class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase
 {
 public:
-    enum ImageType {
-        Image,
-        Pixmap,
-        Texture,
-        Invalid
-    };
-
     QQuickImageProvider(ImageType type);
     virtual ~QQuickImageProvider();