summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qpluginloader.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2013-08-22 13:16:34 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-04 09:38:35 +0200
commit8b7a8efe66afecde87b45adf1c6e850f63670f86 (patch)
treee0396d4777bc53c912a29b84baa6d47ad75d1c01 /src/corelib/plugin/qpluginloader.cpp
parent500deb9a08242d177fdad9a8b5a57b560e754db1 (diff)
QPluginLoader: add 'staticPlugins' function
Currently there is no API to extract the meta data from static plugins. This is needed in e.g QtDeclarative for loading static module plugins. This patch moves the 'staticPlugins' function from QLibraryPrivate into QPluginLoader, and makes it public. As such, we now also export QStaticPlugin. Since an application developer cannot do much with raw metadata, we add a new function QStaticPlugin::metaData() that returns the QJsonObject for the plugin. The old metaData function is renamed 'rawMetaData'. Change-Id: Idb0bf9ad8ebb13340565512e1998b26e762a357e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/plugin/qpluginloader.cpp')
-rw-r--r--src/corelib/plugin/qpluginloader.cpp48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 5a59942aad..46844acb01 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -107,6 +107,33 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \class QStaticPlugin
+ \inmodule QtCore
+ \since 5.2
+
+ \brief QStaticPlugin is a struct containing a reference to a
+ static plugin instance together with its meta data.
+
+ \sa QPluginLoader, {How to Create Qt Plugins}
+*/
+
+/*!
+ \fn QObject *QStaticPlugin::instance()
+
+ Returns the plugin instance.
+
+ \sa QPluginLoader::staticInstances()
+*/
+
+/*!
+ \fn const char *QStaticPlugin::rawMetaData()
+
+ Returns the raw meta data for the plugin.
+
+ \sa metaData(), Q_PLUGIN_METADATA()
+*/
+
+/*!
Constructs a plugin loader with the given \a parent.
*/
QPluginLoader::QPluginLoader(QObject *parent)
@@ -407,6 +434,7 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin plugin)
/*!
Returns a list of static plugin instances (root components) held
by the plugin loader.
+ \sa staticPlugins()
*/
QObjectList QPluginLoader::staticInstances()
{
@@ -419,8 +447,14 @@ QObjectList QPluginLoader::staticInstances()
return instances;
}
-
-QVector<QStaticPlugin> QLibraryPrivate::staticPlugins()
+/*!
+ Returns a list of QStaticPlugins held by the plugin
+ loader. The function is similar to \l staticInstances()
+ with the addition that a QStaticPlugin also contains
+ meta data information.
+ \sa staticInstances()
+*/
+QVector<QStaticPlugin> QPluginLoader::staticPlugins()
{
StaticPluginList *plugins = staticPluginList();
if (plugins)
@@ -428,6 +462,16 @@ QVector<QStaticPlugin> QLibraryPrivate::staticPlugins()
return QVector<QStaticPlugin>();
}
+/*!
+ Returns a the meta data for the plugin as a QJsonObject.
+
+ \sa rawMetaData()
+*/
+QJsonObject QStaticPlugin::metaData() const
+{
+ return QLibraryPrivate::fromRawMetaData(rawMetaData()).object();
+}
+
QT_END_NAMESPACE
#endif // QT_NO_LIBRARY