Changeset View
Changeset View
Standalone View
Standalone View
src/lib/plugin/kpluginfactory.h
Show First 20 Lines • Show All 380 Lines • ▼ Show 20 Line(s) | 334 | public: | |||
---|---|---|---|---|---|
381 | * to the parentWidget argument of the CreateInstanceFunction for the object. | 381 | * to the parentWidget argument of the CreateInstanceFunction for the object. | ||
382 | * \param keyword The keyword of the object. | 382 | * \param keyword The keyword of the object. | ||
383 | * \param args Additional arguments which will be passed to the object. | 383 | * \param args Additional arguments which will be passed to the object. | ||
384 | * \returns A pointer to the created object is returned, or @c nullptr if an error occurred. | 384 | * \returns A pointer to the created object is returned, or @c nullptr if an error occurred. | ||
385 | */ | 385 | */ | ||
386 | template<typename T> | 386 | template<typename T> | ||
387 | T *create(QWidget *parentWidget, QObject *parent, const QString &keyword = QString(), const QVariantList &args = QVariantList()); | 387 | T *create(QWidget *parentWidget, QObject *parent, const QString &keyword = QString(), const QVariantList &args = QVariantList()); | ||
388 | 388 | | |||
389 | #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(4, 0) | ||||
389 | /** | 390 | /** | ||
390 | * @deprecated since 4.0 use create<T>(QObject *parent, const QVariantList &args) | 391 | * @deprecated since 4.0 use create<T>(QObject *parent, const QVariantList &args) | ||
391 | */ | 392 | */ | ||
392 | #ifndef KCOREADDONS_NO_DEPRECATED | | |||
393 | template<typename T> | 393 | template<typename T> | ||
394 | KCOREADDONS_DEPRECATED | 394 | KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create<T>(QObject *parent, const QVariantList &args)") | ||
395 | T *create(QObject *parent, const QStringList &args) | 395 | T *create(QObject *parent, const QStringList &args) | ||
396 | { | 396 | { | ||
397 | return create<T>(parent, stringListToVariantList(args)); | 397 | return create<T>(parent, stringListToVariantList(args)); | ||
398 | } | 398 | } | ||
399 | #endif | | |||
400 | 399 | | |||
401 | /** | 400 | /** | ||
402 | * @deprecated since 4.0 use create<T>(QObject *parent, const QVariantList &args) | 401 | * @deprecated since 4.0 use create<T>(QObject *parent, const QVariantList &args) | ||
403 | */ | 402 | */ | ||
404 | #ifndef KCOREADDONS_NO_DEPRECATED | 403 | KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create<T>(QObject *parent, const QVariantList &args)") | ||
405 | KCOREADDONS_DEPRECATED QObject *create(QObject *parent = nullptr, const char *classname = "QObject", const QStringList &args = QStringList()) | 404 | QObject *create(QObject *parent = nullptr, const char *classname = "QObject", const QStringList &args = QStringList()) | ||
406 | { | 405 | { | ||
407 | return create(classname, nullptr, parent, stringListToVariantList(args), QString()); | 406 | return create(classname, nullptr, parent, stringListToVariantList(args), QString()); | ||
408 | } | 407 | } | ||
409 | #endif | 408 | #endif | ||
410 | 409 | | |||
411 | /** | 410 | /** | ||
412 | * \internal | 411 | * \internal | ||
413 | * Converts a QStringList to a QVariantList | 412 | * Converts a QStringList to a QVariantList | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 425 | protected: | |||
486 | void registerPlugin(const QString &keyword = QString(), CreateInstanceFunction instanceFunction | 485 | void registerPlugin(const QString &keyword = QString(), CreateInstanceFunction instanceFunction | ||
487 | = InheritanceChecker<T>().createInstanceFunction(reinterpret_cast<T *>(0))) | 486 | = InheritanceChecker<T>().createInstanceFunction(reinterpret_cast<T *>(0))) | ||
488 | { | 487 | { | ||
489 | registerPlugin(keyword, &T::staticMetaObject, instanceFunction); | 488 | registerPlugin(keyword, &T::staticMetaObject, instanceFunction); | ||
490 | } | 489 | } | ||
491 | 490 | | |||
492 | KPluginFactoryPrivate *const d_ptr; | 491 | KPluginFactoryPrivate *const d_ptr; | ||
493 | 492 | | |||
493 | #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(4, 0) | ||||
494 | /** | 494 | /** | ||
495 | * @deprecated since 4.0 use create<T>(QObject *parent, const QVariantList &args) | 495 | * @deprecated since 4.0 use create<T>(QObject *parent, const QVariantList &args) | ||
496 | */ | 496 | */ | ||
497 | #ifndef KCOREADDONS_NO_DEPRECATED | 497 | KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create<T>(QObject *parent, const QVariantList &args)") | ||
498 | virtual KCOREADDONS_DEPRECATED QObject *createObject(QObject *parent, const char *className, const QStringList &args); | 498 | virtual QObject *createObject(QObject *parent, const char *className, const QStringList &args); | ||
499 | #endif | | |||
500 | 499 | | |||
501 | /** | 500 | /** | ||
502 | * @deprecated since 4.0 use create<T>(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args) | 501 | * @deprecated since 4.0 use create<T>(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args) | ||
503 | */ | 502 | */ | ||
504 | #ifndef KCOREADDONS_NO_DEPRECATED | 503 | KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create<T>(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args)") | ||
505 | virtual KCOREADDONS_DEPRECATED KParts::Part *createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args); | 504 | virtual KParts::Part *createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args); | ||
506 | #endif | 505 | #endif | ||
507 | 506 | | |||
508 | /** | 507 | /** | ||
509 | * This function is called when the factory asked to create an Object. | 508 | * This function is called when the factory asked to create an Object. | ||
510 | * | 509 | * | ||
511 | * You may reimplement it to provide a very flexible factory. This is especially useful to | 510 | * You may reimplement it to provide a very flexible factory. This is especially useful to | ||
512 | * provide generic factories for plugins implemented using a scripting language. | 511 | * provide generic factories for plugins implemented using a scripting language. | ||
513 | * | 512 | * | ||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |