libplasma
Plasma::PackageStructure Class Reference
#include <packagestructure.h>
Detailed Description
A description of the expected file structure of a given package type.PackageStructure defines what is in a package. This information is used to create packages and provides a way to programatically refer to contents.
An example usage of this class might be:
PackageStructure structure; structure.addDirectoryDefinition("images", "pics/", i18n("Images")); QStringList mimetypes; mimetypes << "image/svg" << "image/png" << "image/jpeg"; structure.setMimetypes("images", mimetypes); structure.addDirectoryDefinition("scripts", "code/", i18n("Executable Scripts")); mimetypes.clear(); mimetypes << "text/\*"; structure.setMimetypes("scripts", mimetypes); structure.addFileDefinition("mainscript", "code/main.js", i18n("Main Script File")); structure.setRequired("mainscript", true);
Either way, PackageStructure creates a sort of "contract" between the packager and the application which is also self-documenting.
Definition at line 62 of file packagestructure.h.
Public Member Functions | |
| PackageStructure (const QString &type) | |
| QString | type () const |
| QList< const char * > | directories () const |
| QList< const char * > | requiredDirectories () const |
| QList< const char * > | files () const |
| QList< const char * > | requiredFiles () const |
| void | addDirectoryDefinition (const char *key, const QString &path, const QString &name) |
| void | addFileDefinition (const char *key, const QString &path, const QString &name) |
| QString | path (const char *key) const |
| QString | name (const char *key) const |
| void | setRequired (const char *key, bool required) |
| bool | required (const char *key) const |
| void | setDefaultMimetypes (QStringList mimetypes) |
| void | setMimetypes (const char *key, QStringList mimetypes) |
| QStringList | mimetypes (const char *key) const |
| PackageStructure (const PackageStructure &rhs) | |
| virtual | ~PackageStructure () |
| PackageStructure & | operator= (const PackageStructure &rhs) |
| void | write (KConfigBase *config) const |
Static Public Member Functions | |
| static PackageStructure | read (const KConfigBase *config) |
Constructor & Destructor Documentation
| Plasma::PackageStructure::PackageStructure | ( | const QString & | type | ) |
Default constructor for a package structure definition.
- type the type of package. This is often application specific.
Definition at line 61 of file packagestructure.cpp.
| Plasma::PackageStructure::PackageStructure | ( | const PackageStructure & | rhs | ) |
| Plasma::PackageStructure::~PackageStructure | ( | ) | [virtual] |
Member Function Documentation
| QString Plasma::PackageStructure::type | ( | ) | const |
| QList< const char * > Plasma::PackageStructure::directories | ( | ) | const |
| QList< const char * > Plasma::PackageStructure::requiredDirectories | ( | ) | const |
The required directories defined for this package.
Definition at line 106 of file packagestructure.cpp.
| QList< const char * > Plasma::PackageStructure::files | ( | ) | const |
The individual files, by key, that are defined for this package.
Definition at line 120 of file packagestructure.cpp.
| QList< const char * > Plasma::PackageStructure::requiredFiles | ( | ) | const |
The individual required files, by key, that are defined for this package.
Definition at line 133 of file packagestructure.cpp.
| void Plasma::PackageStructure::addDirectoryDefinition | ( | const char * | key, | |
| const QString & | path, | |||
| const QString & | name | |||
| ) |
Adds a directory to the structure of the package.
It is added as a not-required element with no associated mimetypes.
- Parameters:
-
key used as an internal label for this directory path the path within the the package for this directory name the user visible (translated) name for the directory
Definition at line 146 of file packagestructure.cpp.
| void Plasma::PackageStructure::addFileDefinition | ( | const char * | key, | |
| const QString & | path, | |||
| const QString & | name | |||
| ) |
Adds a file to the structure of the package.
It is added as a not-required element with no associated mimetypes.
- Parameters:
-
key used as an internal label for this file path the path within the the package for this file name the user visible (translated) name for the file
Definition at line 156 of file packagestructure.cpp.
| QString Plasma::PackageStructure::path | ( | const char * | key | ) | const |
- Returns:
- path relative to the package root for the given entry
Definition at line 166 of file packagestructure.cpp.
| QString Plasma::PackageStructure::name | ( | const char * | key | ) | const |
| void Plasma::PackageStructure::setRequired | ( | const char * | key, | |
| bool | required | |||
| ) |
Sets whether or not a given part of the structure is required or not.
The path must already have been added using addDirectoryDefinition or addFileDefinition.
- Parameters:
-
path the path of the entry within the package required true if this entry is required, false if not
Definition at line 186 of file packagestructure.cpp.
| bool Plasma::PackageStructure::required | ( | const char * | key | ) | const |
- Returns:
- true if the item at path exists and is required
Definition at line 196 of file packagestructure.cpp.
| void Plasma::PackageStructure::setDefaultMimetypes | ( | QStringList | mimetypes | ) |
Defines the default mimetypes for any definitions that do not have associated mimetypes.
Handy for packages with only one or predominantly one file type.
- Parameters:
-
mimetypes a list of mimetypes
Definition at line 206 of file packagestructure.cpp.
| void Plasma::PackageStructure::setMimetypes | ( | const char * | key, | |
| QStringList | mimetypes | |||
| ) |
Define mimetypes for a given part of the structure The path must already have been added using addDirectoryDefinition or addFileDefinition.
- Parameters:
-
path the path of the entry within the package mimetypes a list of mimetypes
Definition at line 211 of file packagestructure.cpp.
| QStringList Plasma::PackageStructure::mimetypes | ( | const char * | key | ) | const |
- Returns:
- the mimetypes associated with the path, if any
Definition at line 221 of file packagestructure.cpp.
| PackageStructure & Plasma::PackageStructure::operator= | ( | const PackageStructure & | rhs | ) |
| PackageStructure Plasma::PackageStructure::read | ( | const KConfigBase * | config | ) | [static] |
| void Plasma::PackageStructure::write | ( | KConfigBase * | config | ) | const |
The documentation for this class was generated from the following files:
KDE 4.0 API Reference