KPackage::PackageLoader Class

Header: #include <KPackage/PackageLoader>
CMake: find_package(KF6 REQUIRED COMPONENTS Package)
target_link_libraries(mytarget PRIVATE KF6::Package)

Public Functions

(since 5.10) void addKnownPackageStructure(const QString &packageFormat, KPackage::PackageStructure *structure)
(since 5.10) QList<KPluginMetaData> findPackages(const QString &packageFormat, const QString &packageRoot = QString(), std::function<bool (const KPluginMetaData &)> filter = std::function<bool(const KPluginMetaData &)>())
(since 6.0) QList<KPackage::Package> listKPackages(const QString &packageFormat, const QString &packageRoot = QString())
QList<KPluginMetaData> listPackages(const QString &packageFormat, const QString &packageRoot = QString())
(since 6.0) QList<KPluginMetaData> listPackagesMetadata(const QString &packageFormat, const QString &packageRoot = QString())
KPackage::Package loadPackage(const QString &packageFormat, const QString &packagePath = QString())
KPackage::PackageStructure *loadPackageStructure(const QString &packageFormat)

Static Public Members

KPackage::PackageLoader *self()

Detailed Description

This is an abstract base class which defines an interface to which the package loading logic can communicate with a parent application. The plugin loader must be set before any plugins are loaded, otherwise (for safety reasons), the default PackageLoader implementation will be used. The reimplemented version should not do more than simply returning a loaded plugin. It should not init() it, and it should not hang on to it.

Member Function Documentation

[since 5.10] void PackageLoader::addKnownPackageStructure(const QString &packageFormat, KPackage::PackageStructure *structure)

Adds a new known package structure that can be used by the functions to load packages such as loadPackage, findPackages etc

packageFormat the package format, such as "KPackage/GenericQML"

structure the package structure we want to be able to load packages from

This function was introduced in 5.10.

[since 5.10] QList<KPluginMetaData> PackageLoader::findPackages(const QString &packageFormat, const QString &packageRoot = QString(), std::function<bool (const KPluginMetaData &)> filter = std::function<bool(const KPluginMetaData &)>())

List package of a certain type that match a certain filter function

packageFormat the format of the packages to list

packageRoot the root folder where the packages are installed. If not specified the default from the packageformat will be taken.

filter a filter function that will be called on each package: will return true for the matching ones

Returns metadata for all the matching packages

This function was introduced in 5.10.

[since 6.0] QList<KPackage::Package> PackageLoader::listKPackages(const QString &packageFormat, const QString &packageRoot = QString())

List all available packages of a certain type. This should be used in case the package structure modifies the metadata or you need to access the contained files of the package.

packageFormat the format of the packages to list

packageRoot the root folder where the packages are installed. If not specified the default from the packageformat will be taken.

This function was introduced in 6.0.

QList<KPluginMetaData> PackageLoader::listPackages(const QString &packageFormat, const QString &packageRoot = QString())

List all available packages of a certain type

packageFormat the format of the packages to list

packageRoot the root folder where the packages are installed. If not specified the default from the packageformat will be taken.

Returns metadata for all the matching packages

[since 6.0] QList<KPluginMetaData> PackageLoader::listPackagesMetadata(const QString &packageFormat, const QString &packageRoot = QString())

This function was introduced in 6.0.

See also listPackages().

KPackage::Package PackageLoader::loadPackage(const QString &packageFormat, const QString &packagePath = QString())

Load a Package plugin.

packageFormat the format of the package to load

packagePath the package name: the path of the package relative to the packageFormat root path. If not specified it will have to be set manually with Package::setPath() by the caller.

Returns a Package object matching name, or an invalid package on failure

KPackage::PackageStructure *PackageLoader::loadPackageStructure(const QString &packageFormat)

Loads a PackageStructure for a given format. The structure can then be used as paramenter for a Package instance constructor

Note: The returned pointer is managed by KPackage, and should never be deleted

packageFormat the package format, such as "KPackage/GenericQML"

Returns the structure instance (ownership retained by KPackage)

[static] KPackage::PackageLoader *PackageLoader::self()

Return the active plugin loader