Don't inherit from QFactoryInterface for image plugins

QFactoryInterface is obsolete now that we have the new plugins loading
mechanism, where we can get the keys out of the plugin without
having to load it. Remove it from QImageIOHandlerFactoryInterface
as a first step of getting completely rid of it.

Change-Id: I856b149dd20131e1cdcdcb271c1a355c9e0da6ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2012-05-27 03:40:00 +02:00 committed by Qt by Nokia
parent 21019539fb
commit c9d040c1f5
8 changed files with 13 additions and 54 deletions

View File

@ -171,9 +171,9 @@
support for different image formats to Qt.
Writing an image I/O plugin is achieved by subclassing this
base class, reimplementing the pure virtual functions capabilities(),
create(), and keys(), and exporting the class with the
Q_EXPORT_PLUGIN2() macro. See \l{How to Create Qt Plugins} for details.
base class, reimplementing the pure virtual functions capabilities()
and create(), and exporting the class with the
Q_PLUGIN_METADATA() macro. See \l{How to Create Qt Plugins} for details.
An image format plugin can support three capabilities: reading (\l
CanRead), writing (\l CanWrite) and \e incremental reading (\l
@ -182,8 +182,15 @@
create() should create an instance of your QImageIOHandler
subclass, with the provided device and format properly set, and
return this handler. You must also reimplement keys() so that Qt
knows which image formats your plugin supports.
return this handler.
The json metadata file for the plugin needs to contain information
about the image formats the plugins supports. For a jpeg plugin, this
could e.g. look as follows:
\code
{ "Keys": [ "jpg", "jpeg" ] }
\endcode
Different plugins can support different capabilities. For example,
you may have one plugin that supports reading the GIF format, and
@ -205,17 +212,6 @@
\value CanReadIncremental The plugin can read images incrementally.
*/
/*!
\class QImageIOHandlerFactoryInterface
\brief The QImageIOHandlerFactoryInterface class provides the factory
interface for QImageIOPlugin.
\reentrant
\internal
\sa QImageIOPlugin
*/
#include "qimageiohandler.h"
#include <qbytearray.h>
@ -546,17 +542,6 @@ QImageIOPlugin::~QImageIOPlugin()
\l CanWrite.
*/
/*!
\fn QImageIOPlugin::keys() const
Returns the list of image keys this plugin supports.
These keys are usually the names of the image formats that are implemented
in the plugin (e.g., "jpg" or "gif").
\sa capabilities()
*/
/*!
\fn QImageIOHandler *QImageIOPlugin::create(QIODevice *device, const QByteArray &format) const

View File

@ -114,18 +114,11 @@ private:
Q_DISABLE_COPY(QImageIOHandler)
};
struct Q_GUI_EXPORT QImageIOHandlerFactoryInterface : public QFactoryInterface
{
virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const = 0;
};
#define QImageIOHandlerFactoryInterface_iid "org.qt-project.Qt.QImageIOHandlerFactoryInterface"
Q_DECLARE_INTERFACE(QImageIOHandlerFactoryInterface, QImageIOHandlerFactoryInterface_iid)
class Q_GUI_EXPORT QImageIOPlugin : public QObject, public QImageIOHandlerFactoryInterface
class Q_GUI_EXPORT QImageIOPlugin : public QObject
{
Q_OBJECT
Q_INTERFACES(QImageIOHandlerFactoryInterface:QFactoryInterface)
public:
explicit QImageIOPlugin(QObject *parent = 0);
virtual ~QImageIOPlugin();
@ -138,7 +131,6 @@ public:
Q_DECLARE_FLAGS(Capabilities, Capability)
virtual Capabilities capabilities(QIODevice *device, const QByteArray &format) const = 0;
virtual QStringList keys() const = 0;
virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const = 0;
};

View File

@ -62,11 +62,6 @@ QGifPlugin::~QGifPlugin()
{
}
QStringList QGifPlugin::keys() const
{
return QStringList() << QLatin1String("gif");
}
QImageIOPlugin::Capabilities QGifPlugin::capabilities(QIODevice *device, const QByteArray &format) const
{
if (format == "gif" || (device && device->isReadable() && QGifHandler::canRead(device)))

View File

@ -57,7 +57,6 @@ public:
QGifPlugin();
~QGifPlugin();
QStringList keys() const;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
};

View File

@ -45,11 +45,6 @@
QT_BEGIN_NAMESPACE
QStringList QICOPlugin::keys() const
{
return QStringList() << QLatin1String("ico");
}
QImageIOPlugin::Capabilities QICOPlugin::capabilities(QIODevice *device, const QByteArray &format) const
{
if (format == "ico")

View File

@ -56,7 +56,6 @@ class QICOPlugin : public QImageIOPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "ico.json")
public:
QStringList keys() const;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
};

View File

@ -50,11 +50,6 @@
QT_BEGIN_NAMESPACE
QStringList QJpegPlugin::keys() const
{
return QStringList() << QLatin1String("jpeg") << QLatin1String("jpg");
}
QImageIOPlugin::Capabilities QJpegPlugin::capabilities(QIODevice *device, const QByteArray &format) const
{
if (format == "jpeg" || format == "jpg")

View File

@ -55,7 +55,6 @@ class QJpegPlugin : public QImageIOPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "jpeg.json")
public:
QStringList keys() const;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
};