KCoreAddons
kpluginfactory.cpp
45 void KPluginFactory::registerPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceFunction instanceFunction)
54 qCWarning(KCOREADDONS_DEBUG) << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!";
56 d->createInstanceHash.insert(keyword, KPluginFactoryPrivate::Plugin(metaObject, instanceFunction));
62 for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
64 qCWarning(KCOREADDONS_DEBUG) << "Two plugins with the same interface(" << superClass->className()
73 for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
75 qCWarning(KCOREADDONS_DEBUG) << "Two plugins with the same interface(" << superClass->className()
81 d->createInstanceHash.insert(keyword, KPluginFactoryPrivate::Plugin(metaObject, instanceFunction));
85 void KPluginFactory::registerPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceWithMetaDataFunction instanceFunction)
94 qCWarning(KCOREADDONS_DEBUG) << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!";
98 const QList<KPluginFactoryPrivate::PluginWithMetadata> clashes(d->createInstanceWithMetaDataHash.values(keyword));
102 for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
104 qCWarning(KCOREADDONS_DEBUG) << "Two plugins with the same interface(" << superClass->className()
113 for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
115 qCWarning(KCOREADDONS_DEBUG) << "Two plugins with the same interface(" << superClass->className()
126 QObject *KPluginFactory::createObject(QObject *parent, const char *className, const QStringList &args)
136 KParts::Part *KPluginFactory::createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args)
146 QObject *KPluginFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
156 if ((obj = reinterpret_cast<QObject *>(createPartObject(parentWidget, parent, iface, argsStringList)))) {
175 qCWarning(KCOREADDONS_DEBUG) << "ambiguous interface requested from a DSO containing more than one plugin";
184 const QList<KPluginFactoryPrivate::PluginWithMetadata> candidates = (d->createInstanceWithMetaDataHash.values(keyword));
191 qCWarning(KCOREADDONS_DEBUG) << "ambiguous interface requested from a DSO containing more than one plugin";
static QVariantList stringListToVariantList(const QStringList &list)
Definition: kpluginfactory.cpp:215
void setMetaData(const KPluginMetaData &metaData)
Set the metadata about the plugin this factory generates.
Definition: kpluginfactory.cpp:39
T * create(QObject *parent=nullptr, const QVariantList &args=QVariantList())
Use this method to create an object.
Definition: kpluginfactory.h:768
const QMetaObject * superClass() const const
QObject *(* CreateInstanceFunction)(QWidget *, QObject *, const QVariantList &)
Function pointer type to a function that instantiates a plugin.
Definition: kpluginfactory.h:518
virtual const QMetaObject * metaObject() const const
QString & insert(int position, QChar ch)
static QStringList variantListToStringList(const QVariantList &list)
Definition: kpluginfactory.cpp:206
bool isEmpty() const const
T & first()
QObject *(*)(QWidget *, QObject *, const KPluginMetaData &, const QVariantList &) CreateInstanceWithMetaDataFunction
Function pointer type to a function that instantiates a plugin, also taking a plugin metadata argumen...
Definition: kpluginfactory.h:548
void registerPlugin(const QString &keyword, CreateInstanceFunction instanceFunction)
Registers a metadata-less plugin with the factory.
Definition: kpluginfactory.h:600
virtual KParts::Part * createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args)
Definition: kpluginfactory.cpp:136
void insert(int i, const T &value)
This class allows easily accessing some standardized values from the JSON metadata that can be embedd...
Definition: kpluginmetadata.h:85
QObject * parent() const const
virtual QObject * createObject(QObject *parent, const char *className, const QStringList &args)
Definition: kpluginfactory.cpp:126
KPluginFactory provides a convenient way to provide factory-style plugins.
Definition: kpluginfactory.h:403
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:01:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:01:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.