File indexing completed on 2023-12-03 10:58:38
0001 /* 0002 SPDX-FileCopyrightText: 2011 Aaron Seigo <aseigo@kde.org> 0003 SPDX-FileCopyrightText: 2023 Alexander Lohnau <alexander.lohnau@gmx.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KPACKAGE_PACKAGESTRUCTURE_H 0009 #define KPACKAGE_PACKAGESTRUCTURE_H 0010 0011 #include <QStringList> 0012 0013 #include <KPluginFactory> 0014 0015 #include <kpackage/package.h> 0016 #include <kpackage/package_export.h> 0017 0018 namespace KPackage 0019 { 0020 class PackageStructurePrivate; 0021 0022 /** 0023 * @class PackageStructure kpackage/packagestructure.h <KPackage/PackageStructure> 0024 * 0025 * This class is used to define the filesystem structure of a package type. 0026 * A PackageStructure is implemented as a dynamically loaded plugin, in the reimplementation 0027 * of initPackage the allowed fines and directories in the package are set into the package, 0028 * for instance: 0029 * 0030 * @code 0031 * package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml")); 0032 * package->setDefaultPackageRoot(QStringLiteral("plasma/wallpapers/")); 0033 * package->addDirectoryDefinition("images", QStringLiteral("images")); 0034 * package->addDirectoryDefinition("theme", QStringLiteral("theme")); 0035 * QStringList mimetypes{QStringLiteral("image/svg+xml"), QStringLiteral("image/png"), QStringLiteral("image/jpeg")}; 0036 * package->setMimeTypes("images", mimetypes); 0037 * @endcode 0038 * 0039 * @author Aaron Seigo 0040 */ 0041 class KPACKAGE_EXPORT PackageStructure : public QObject 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 explicit PackageStructure(QObject *parent = nullptr, const QVariantList &args = QVariantList()); 0047 0048 ~PackageStructure() override; 0049 0050 /** 0051 * Called when a the PackageStructure should initialize a Package with the initial 0052 * structure. This allows setting paths before setPath is called. 0053 * 0054 * Note: one special value is "metadata" which can be set to the location of KPluginMetaData 0055 * compatible .json file within the package. If not defined, it is assumed that this file 0056 * exists under the top level directory of the package. 0057 * 0058 * @param package the Package to set up. The object is empty of all definition when 0059 * first passed in. 0060 */ 0061 virtual void initPackage(Package *package); 0062 0063 /** 0064 * Called whenever the path changes so that subclasses may take 0065 * package specific actions. 0066 */ 0067 virtual void pathChanged(Package *package); 0068 0069 private: 0070 PackageStructurePrivate *d; 0071 }; 0072 0073 } // KPackage namespace 0074 0075 #endif