KParts::PartLoader

KParts::PartLoader Namespace Reference

Functions

template<typename T >
static KPluginFactory::Result< T > instantiatePart (const KPluginMetaData &data, QWidget *parentWidget=nullptr, QObject *parent=nullptr, const QVariantList &args={})
 
template<class T >
static KPluginFactory::Result< T > instantiatePartForMimeType (const QString &mimeType, QWidget *parentWidget=nullptr, QObject *parent=nullptr, const QVariantList &args={})
 
KPARTS_EXPORT PartCapabilities partCapabilities (const KPluginMetaData &data)
 
KPARTS_EXPORT QList< KPluginMetaDatapartsForMimeType (const QString &mimeType)
 

Detailed Description

Helper methods for locating and loading parts.

This is based upon KPluginFactory, but it takes care of querying by mimetype, sorting the available parts by builtin preference and by user preference.

Since
5.69

Function Documentation

◆ instantiatePart()

template<typename T >
static KPluginFactory::Result< T > KParts::PartLoader::instantiatePart ( const KPluginMetaData & data,
QWidget * parentWidget = nullptr,
QObject * parent = nullptr,
const QVariantList & args = {} )
static

Attempts to create a KPart from the given metadata.

if (auto result = KParts::PartLoader::instantiatePart<MyPart>(metaData, parentWidget, parent, args)) {
// result.plugin is valid and can be accessed
} else {
// result contains information about the error
}
static KPluginFactory::Result< T > instantiatePart(const KPluginMetaData &data, QWidget *parentWidget=nullptr, QObject *parent=nullptr, const QVariantList &args={})
Attempts to create a KPart from the given metadata.
Definition partloader.h:115
Parameters
dataKPluginMetaData from which the plugin should be loaded
parentWidgetThe parent widget
parentThe parent object
argsA list of arguments to be passed to the part
Returns
Result object which contains the plugin instance and potentially error information
Since
5.100

Definition at line 115 of file partloader.h.

◆ instantiatePartForMimeType()

template<class T >
static KPluginFactory::Result< T > KParts::PartLoader::instantiatePartForMimeType ( const QString & mimeType,
QWidget * parentWidget = nullptr,
QObject * parent = nullptr,
const QVariantList & args = {} )
static

Use this method to create a KParts part.

It will try to create an object which inherits T.

if (auto result = KParts::PartLoader::instantiatePartForMimeType<KParts::ReadOnlyPart>(mimeType, parentWidget, parent, args)) {
// result.plugin is valid and can be accessed
} else {
// result contains information about the error
}
static KPluginFactory::Result< T > instantiatePartForMimeType(const QString &mimeType, QWidget *parentWidget=nullptr, QObject *parent=nullptr, const QVariantList &args={})
Use this method to create a KParts part.
Definition partloader.h:156
Template Parameters
TThe interface for which an object should be created. The object will inherit T.
Parameters
mimeTypeThe mimetype for which we need a KParts.
parentWidgetThe parent widget for the part's widget.
parentThe parent of the part.
Returns
Result object which contains the plugin instance and potentially error information
Since
5.100

Definition at line 156 of file partloader.h.

◆ partCapabilities()

KParts::PartCapabilities KParts::PartLoader::partCapabilities ( const KPluginMetaData & data)

Parses the associated capabilities from the KPart.

This parses the deprecated "ServiceTypes" array of the "KPlugin" object

Since
6.4

Definition at line 57 of file partloader.cpp.

◆ partsForMimeType()

QList< KPluginMetaData > KParts::PartLoader::partsForMimeType ( const QString & mimeType)

Locate all available KParts using KPluginMetaData::findPlugins for a mimetype.

Returns
a list of plugin metadata, sorted by preference. This takes care both of the builtin preference (set by developers) and of user preference (stored in mimeapps.list).

To load a part from one of the KPluginMetaData instances returned here, use instantiatePart()

Since
5.69

Definition at line 101 of file partloader.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.