* api docu fixes

* allow setting a default mimetype for a package

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=676513
This commit is contained in:
Aaron J. Seigo 2007-06-17 01:04:59 +00:00
parent 7afda6a7f8
commit 0174be3330
2 changed files with 22 additions and 1 deletions

View File

@ -45,6 +45,7 @@ class PackageStructure::Private
public:
QString type;
QHash<const char*, ContentStructure> contents;
QStringList mimetypes;
};
PackageStructure::PackageStructure(const QString &type)
@ -164,6 +165,11 @@ bool PackageStructure::required(const char* key)
return it.value().required;
}
void PackageStructure::setDefaultMimetypes(QStringList mimetypes)
{
d->mimetypes = mimetypes;
}
void PackageStructure::setMimetypes(const char* key, QStringList mimetypes)
{
QHash<const char*, ContentStructure>::iterator it = d->contents.find(key);
@ -181,6 +187,10 @@ QStringList PackageStructure::mimetypes(const char* key)
return QStringList();
}
if (it.value().mimetypes.isEmpty()) {
return d->mimetypes;
}
return it.value().mimetypes;
}

View File

@ -38,7 +38,7 @@ namespace Plasma
@code
PackageStructure structure;
structure.addDirectoryDefinition("images", "pics/", i18n("Images");
structure.addDirectoryDefinition("images", "pics/", i18n("Images"));
QStringList mimetypes;
mimetypes << "image/svg" << "image/png" << "image/jpeg";
structure.setMimetypes("images", mimetypes);
@ -118,6 +118,7 @@ public:
* or addFileDefinition.
*
* @param path the path of the entry within the package
* @param required true if this entry is required, false if not
*/
void setRequired(const char* key, bool required);
@ -126,12 +127,22 @@ public:
**/
bool required(const char* key);
/**
* Defines the default mimetypes for any definitions that do not have
* associated mimetypes. Handy for packages with only one or predominantly
* one file type.
*
* @param mimetypes a list of mimetypes
**/
void setDefaultMimetypes(QStringList mimetypes);
/**
* Define mimetypes for a given part of the structure
* The path must already have been added using addDirectoryDefinition
* or addFileDefinition.
*
* @param path the path of the entry within the package
* @param mimetypes a list of mimetypes
**/
void setMimetypes(const char* key, QStringList mimetypes);