mimetype -> mimeType
This commit is contained in:
parent
1040d71ad0
commit
7e99f4c2cd
@ -59,14 +59,14 @@ class ContentStructure
|
|||||||
{
|
{
|
||||||
paths = other.paths;
|
paths = other.paths;
|
||||||
name = other.name;
|
name = other.name;
|
||||||
mimetypes = other.mimetypes;
|
mimeTypes = other.mimeTypes;
|
||||||
directory = other.directory;
|
directory = other.directory;
|
||||||
required = other.required;
|
required = other.required;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
QString name;
|
QString name;
|
||||||
QStringList mimetypes;
|
QStringList mimeTypes;
|
||||||
bool directory : 1;
|
bool directory : 1;
|
||||||
bool required : 1;
|
bool required : 1;
|
||||||
};
|
};
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
QString packageRoot;
|
QString packageRoot;
|
||||||
QString servicePrefix;
|
QString servicePrefix;
|
||||||
QMap<QByteArray, ContentStructure> contents;
|
QMap<QByteArray, ContentStructure> contents;
|
||||||
QStringList mimetypes;
|
QStringList mimeTypes;
|
||||||
PackageMetadata *metadata;
|
PackageMetadata *metadata;
|
||||||
bool externalPaths;
|
bool externalPaths;
|
||||||
};
|
};
|
||||||
@ -411,33 +411,33 @@ bool PackageStructure::isRequired(const char *key) const
|
|||||||
return it.value().required;
|
return it.value().required;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageStructure::setDefaultMimetypes(QStringList mimetypes)
|
void PackageStructure::setDefaultMimetypes(QStringList mimeTypes)
|
||||||
{
|
{
|
||||||
d->mimetypes = mimetypes;
|
d->mimeTypes = mimeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageStructure::setMimetypes(const char *key, QStringList mimetypes)
|
void PackageStructure::setMimetypes(const char *key, QStringList mimeTypes)
|
||||||
{
|
{
|
||||||
QMap<QByteArray, ContentStructure>::iterator it = d->contents.find(key);
|
QMap<QByteArray, ContentStructure>::iterator it = d->contents.find(key);
|
||||||
if (it == d->contents.end()) {
|
if (it == d->contents.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
it.value().mimetypes = mimetypes;
|
it.value().mimeTypes = mimeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PackageStructure::mimetypes(const char *key) const
|
QStringList PackageStructure::mimeTypes(const char *key) const
|
||||||
{
|
{
|
||||||
QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
|
QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
|
||||||
if (it == d->contents.constEnd()) {
|
if (it == d->contents.constEnd()) {
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it.value().mimetypes.isEmpty()) {
|
if (it.value().mimeTypes.isEmpty()) {
|
||||||
return d->mimetypes;
|
return d->mimeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return it.value().mimetypes;
|
return it.value().mimeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageStructure::setPath(const QString &path)
|
void PackageStructure::setPath(const QString &path)
|
||||||
@ -481,7 +481,7 @@ void PackageStructure::pathChanged()
|
|||||||
void PackageStructure::read(const KConfigBase *config)
|
void PackageStructure::read(const KConfigBase *config)
|
||||||
{
|
{
|
||||||
d->contents.clear();
|
d->contents.clear();
|
||||||
d->mimetypes.clear();
|
d->mimeTypes.clear();
|
||||||
KConfigGroup general(config, QString());
|
KConfigGroup general(config, QString());
|
||||||
d->type = general.readEntry("Type", QString());
|
d->type = general.readEntry("Type", QString());
|
||||||
d->contentsPrefixPaths = general.readEntry("ContentsPrefixPaths", d->contentsPrefixPaths);
|
d->contentsPrefixPaths = general.readEntry("ContentsPrefixPaths", d->contentsPrefixPaths);
|
||||||
@ -495,7 +495,7 @@ void PackageStructure::read(const KConfigBase *config)
|
|||||||
|
|
||||||
QString path = entry.readEntry("Path", QString());
|
QString path = entry.readEntry("Path", QString());
|
||||||
QString name = entry.readEntry("Name", QString());
|
QString name = entry.readEntry("Name", QString());
|
||||||
QStringList mimetypes = entry.readEntry("Mimetypes", QStringList());
|
QStringList mimeTypes = entry.readEntry("Mimetypes", QStringList());
|
||||||
bool directory = entry.readEntry("Directory", false);
|
bool directory = entry.readEntry("Directory", false);
|
||||||
bool required = entry.readEntry("Required", false);
|
bool required = entry.readEntry("Required", false);
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ void PackageStructure::read(const KConfigBase *config)
|
|||||||
addFileDefinition(key, path, name);
|
addFileDefinition(key, path, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMimetypes(key, mimetypes);
|
setMimetypes(key, mimeTypes);
|
||||||
setRequired(key, required);
|
setRequired(key, required);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,8 +523,8 @@ void PackageStructure::write(KConfigBase *config) const
|
|||||||
KConfigGroup group = config->group(it.key());
|
KConfigGroup group = config->group(it.key());
|
||||||
group.writeEntry("Path", it.value().paths);
|
group.writeEntry("Path", it.value().paths);
|
||||||
group.writeEntry("Name", it.value().name);
|
group.writeEntry("Name", it.value().name);
|
||||||
if (!it.value().mimetypes.isEmpty()) {
|
if (!it.value().mimeTypes.isEmpty()) {
|
||||||
group.writeEntry("Mimetypes", it.value().mimetypes);
|
group.writeEntry("Mimetypes", it.value().mimeTypes);
|
||||||
}
|
}
|
||||||
if (it.value().directory) {
|
if (it.value().directory) {
|
||||||
group.writeEntry("Directory", true);
|
group.writeEntry("Directory", true);
|
||||||
@ -608,7 +608,6 @@ void PackageStructurePrivate::createPackageMetadata(const QString &path)
|
|||||||
metadata = new PackageMetadata(metadataPath);
|
metadata = new PackageMetadata(metadataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME KDE5: should be const
|
|
||||||
PackageMetadata PackageStructure::metadata()
|
PackageMetadata PackageStructure::metadata()
|
||||||
{
|
{
|
||||||
if (!d->metadata && !d->path.isEmpty()) {
|
if (!d->metadata && !d->path.isEmpty()) {
|
||||||
@ -618,15 +617,15 @@ PackageMetadata PackageStructure::metadata()
|
|||||||
d->createPackageMetadata(d->path);
|
d->createPackageMetadata(d->path);
|
||||||
} else if (fileInfo.exists()) {
|
} else if (fileInfo.exists()) {
|
||||||
KArchive *archive = 0;
|
KArchive *archive = 0;
|
||||||
KMimeType::Ptr mimetype = KMimeType::findByPath(d->path);
|
KMimeType::Ptr mimeType = KMimeType::findByPath(d->path);
|
||||||
|
|
||||||
if (mimetype->is("application/zip")) {
|
if (mimeType->is("application/zip")) {
|
||||||
archive = new KZip(d->path);
|
archive = new KZip(d->path);
|
||||||
} else if (mimetype->is("application/x-compressed-tar") ||
|
} else if (mimeType->is("application/x-compressed-tar") ||
|
||||||
mimetype->is("application/x-tar")|| mimetype->is("application/x-bzip-compressed-tar")) {
|
mimeType->is("application/x-tar")|| mimeType->is("application/x-bzip-compressed-tar")) {
|
||||||
archive = new KTar(d->path);
|
archive = new KTar(d->path);
|
||||||
} else {
|
} else {
|
||||||
kWarning() << "Could not open package file, unsupported archive format:" << d->path << mimetype->name();
|
kWarning() << "Could not open package file, unsupported archive format:" << d->path << mimeType->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (archive && archive->open(QIODevice::ReadOnly)) {
|
if (archive && archive->open(QIODevice::ReadOnly)) {
|
||||||
|
@ -51,14 +51,14 @@ class PackageStructurePrivate;
|
|||||||
PackageStructure structure;
|
PackageStructure structure;
|
||||||
|
|
||||||
structure.addDirectoryDefinition("images", "pics/", i18n("Images"));
|
structure.addDirectoryDefinition("images", "pics/", i18n("Images"));
|
||||||
QStringList mimetypes;
|
QStringList mimeTypes;
|
||||||
mimetypes << "image/svg" << "image/png" << "image/jpeg";
|
mimeTypes << "image/svg" << "image/png" << "image/jpeg";
|
||||||
structure.setMimetypes("images", mimetypes);
|
structure.setMimetypes("images", mimeTypes);
|
||||||
|
|
||||||
structure.addDirectoryDefinition("scripts", "code/", i18n("Executable Scripts"));
|
structure.addDirectoryDefinition("scripts", "code/", i18n("Executable Scripts"));
|
||||||
mimetypes.clear();
|
mimeTypes.clear();
|
||||||
mimetypes << "text/\*";
|
mimeTypes << "text/\*";
|
||||||
structure.setMimetypes("scripts", mimetypes);
|
structure.setMimetypes("scripts", mimeTypes);
|
||||||
|
|
||||||
structure.addFileDefinition("mainscript", "code/main.js", i18n("Main Script File"));
|
structure.addFileDefinition("mainscript", "code/main.js", i18n("Main Script File"));
|
||||||
structure.setRequired("mainscript", true);
|
structure.setRequired("mainscript", true);
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a directory to the structure of the package. It is added as
|
* Adds a directory to the structure of the package. It is added as
|
||||||
* a not-required element with no associated mimetypes.
|
* a not-required element with no associated mimeTypes.
|
||||||
*
|
*
|
||||||
* Starting in 4.6, if an entry with the given key
|
* Starting in 4.6, if an entry with the given key
|
||||||
* already exists, the path is added to it as a search alternative.
|
* already exists, the path is added to it as a search alternative.
|
||||||
@ -144,7 +144,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a file to the structure of the package. It is added as
|
* Adds a file to the structure of the package. It is added as
|
||||||
* a not-required element with no associated mimetypes.
|
* a not-required element with no associated mimeTypes.
|
||||||
*
|
*
|
||||||
* Starting in 4.6, if an entry with the given key
|
* Starting in 4.6, if an entry with the given key
|
||||||
* already exists, the path is added to it as a search alternative.
|
* already exists, the path is added to it as a search alternative.
|
||||||
@ -206,28 +206,28 @@ public:
|
|||||||
bool isRequired(const char *key) const;
|
bool isRequired(const char *key) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the default mimetypes for any definitions that do not have
|
* Defines the default mimeTypes for any definitions that do not have
|
||||||
* associated mimetypes. Handy for packages with only one or predominantly
|
* associated mimeTypes. Handy for packages with only one or predominantly
|
||||||
* one file type.
|
* one file type.
|
||||||
*
|
*
|
||||||
* @param mimetypes a list of mimetypes
|
* @param mimeTypes a list of mimeTypes
|
||||||
**/
|
**/
|
||||||
void setDefaultMimetypes(QStringList mimetypes);
|
void setDefaultMimetypes(QStringList mimeTypes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define mimetypes for a given part of the structure
|
* Define mimeTypes for a given part of the structure
|
||||||
* The path must already have been added using addDirectoryDefinition
|
* The path must already have been added using addDirectoryDefinition
|
||||||
* or addFileDefinition.
|
* or addFileDefinition.
|
||||||
*
|
*
|
||||||
* @param key the entry within the package
|
* @param key the entry within the package
|
||||||
* @param mimetypes a list of mimetypes
|
* @param mimeTypes a list of mimeTypes
|
||||||
**/
|
**/
|
||||||
void setMimetypes(const char *key, QStringList mimetypes);
|
void setMimetypes(const char *key, QStringList mimeTypes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the mimetypes associated with the path, if any
|
* @return the mimeTypes associated with the path, if any
|
||||||
**/
|
**/
|
||||||
QStringList mimetypes(const char *key) const;
|
QStringList mimeTypes(const char *key) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the path to the package. Useful for package formats
|
* Sets the path to the package. Useful for package formats
|
||||||
|
Loading…
Reference in New Issue
Block a user