KCoreAddons
kpluginfactory.cpp
50 result.errorString = tr("Could not load plugin from %1: %2").arg(data.fileName(), loader.errorString());
51 result.errorText = QStringLiteral("Could not load plugin from %1: %2").arg(data.fileName(), loader.errorString());
63 qCWarning(KCOREADDONS_DEBUG) << "Expected a KPluginFactory, got a" << obj->metaObject()->className();
86 void KPluginFactory::registerPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceFunction instanceFunction)
95 qCWarning(KCOREADDONS_DEBUG) << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!";
97 d->createInstanceHash.insert(keyword, KPluginFactoryPrivate::Plugin(metaObject, instanceFunction));
105 for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
107 qCWarning(KCOREADDONS_DEBUG).nospace() << "Two plugins with the same interface (" << superClass->className()
114 // check hierarchy of newly newly registered plugin against all registered classes with the same keyword
118 for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
120 qCWarning(KCOREADDONS_DEBUG).nospace() << "Two plugins with the same interface (" << superClass->className()
127 d->createInstanceHash.insert(keyword, KPluginFactoryPrivate::Plugin(metaObject, instanceFunction));
131 void KPluginFactory::registerPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceWithMetaDataFunction instanceFunction)
140 qCWarning(KCOREADDONS_DEBUG) << "A plugin with the keyword" << keyword << "was already registered. A keyword must be unique!";
144 const QList<KPluginFactoryPrivate::PluginWithMetadata> clashes(d->createInstanceWithMetaDataHash.values(keyword));
149 for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
151 qCWarning(KCOREADDONS_DEBUG).nospace() << "Two plugins with the same interface (" << superClass->className()
158 // check hierarchy of newly newly registered plugin against all registered classes with the same keyword
162 for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper; otherSuper = otherSuper->superClass()) {
164 qCWarning(KCOREADDONS_DEBUG).nospace() << "Two plugins with the same interface (" << superClass->className()
181 qCWarning(KCOREADDONS_DEBUG) << "KPluginFactory could not create a" << className << "instance from" << data.fileName();
185 QObject *KPluginFactory::createObject(QObject *parent, const char *className, const QStringList &args)
195 KParts::Part *KPluginFactory::createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args)
205 QObject *KPluginFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
215 if ((obj = reinterpret_cast<QObject *>(createPartObject(parentWidget, parent, iface, argsStringList)))) {
234 qCWarning(KCOREADDONS_DEBUG) << "ambiguous interface requested from a DSO containing more than one plugin";
243 const QList<KPluginFactoryPrivate::PluginWithMetadata> candidates = (d->createInstanceWithMetaDataHash.values(keyword));
Q_EMITQ_EMIT
void registerPlugin()
Overload for registerPlugin<T>(const QString &keyword, CreateInstanceFunction instanceFunction)
Definition: kpluginfactory.h:747
static QStringList variantListToStringList(const QVariantList &list)
Definition: kpluginfactory.cpp:265
virtual KParts::Part * createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args)
Definition: kpluginfactory.cpp:195
void setMetaData(const KPluginMetaData &metaData)
Set the metadata about the plugin this factory generates.
Definition: kpluginfactory.cpp:80
Q_GLOBAL_STATIC(Internal::StaticControl, s_instance) class ControlPrivate
Definition: kpluginfactory.h:427
virtual QObject * createObject(QObject *parent, const char *className, const QStringList &args)
Definition: kpluginfactory.cpp:185
bool isEmpty() const const
const QMetaObject * superClass() const const
T * create(QObject *parent=nullptr, const QVariantList &args=QVariantList())
Use this method to create an object.
Definition: kpluginfactory.h:936
static QVariantList stringListToVariantList(const QStringList &list)
Definition: kpluginfactory.cpp:274
static Result< KPluginFactory > loadFactory(const KPluginMetaData &data)
Attempts to load the KPluginFactory from the given metadata.
Definition: kpluginfactory.cpp:33
virtual const QMetaObject * metaObject() const const
const char * className() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString & insert(int position, QChar ch)
QObject * instance()
QObject * instance()
Holds the result of a plugin load operation, i.e.
Definition: kpluginfactory.h:454
QString tr(const char *sourceText, const char *disambiguation, int n)
Definition: kpluginmetadata.h:87
QObject * parent() const const
Q_D(Todo)
QString errorString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 9 2023 04:03:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 9 2023 04:03:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.