allow stripping out the name and mimetype data from the package info; only really useful for package introspection (e.g. in plasmate and other such tools) but a waste on mobile

This commit is contained in:
Aaron Seigo 2011-07-21 14:41:01 +02:00
parent 33cdfc7c77
commit f3a66f1f79
2 changed files with 29 additions and 1 deletions

View File

@ -182,12 +182,17 @@ bool Package::isValid() const
QString Package::name(const char *key) const QString Package::name(const char *key) const
{ {
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
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 QString(); return QString();
} }
return it.value().name; return it.value().name;
#else
Q_UNUSED(key);
return QString();
#endif
} }
bool Package::isRequired(const char *key) const bool Package::isRequired(const char *key) const
@ -202,6 +207,7 @@ bool Package::isRequired(const char *key) const
QStringList Package::mimeTypes(const char *key) const QStringList Package::mimeTypes(const char *key) const
{ {
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
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();
@ -212,6 +218,9 @@ QStringList Package::mimeTypes(const char *key) const
} }
return it.value().mimeTypes; return it.value().mimeTypes;
#else
return QStringList();
#endif
} }
QString Package::defaultPackageRoot() const QString Package::defaultPackageRoot() const
@ -539,9 +548,13 @@ void Package::addDirectoryDefinition(const char *key, const QString &path, const
s = d->contents[key]; s = d->contents[key];
} }
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
if (!name.isEmpty()) { if (!name.isEmpty()) {
s.name = name; s.name = name;
} }
#else
Q_UNUSED(name)
#endif
s.paths.append(path); s.paths.append(path);
s.directory = true; s.directory = true;
@ -557,9 +570,13 @@ void Package::addFileDefinition(const char *key, const QString &path, const QStr
s = d->contents[key]; s = d->contents[key];
} }
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
if (!name.isEmpty()) { if (!name.isEmpty()) {
s.name = name; s.name = name;
} }
#else
Q_UNUSED(name)
#endif
s.paths.append(path); s.paths.append(path);
s.directory = false; s.directory = false;
@ -584,17 +601,21 @@ void Package::setRequired(const char *key, bool required)
void Package::setDefaultMimeTypes(QStringList mimeTypes) void Package::setDefaultMimeTypes(QStringList mimeTypes)
{ {
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
d->mimeTypes = mimeTypes; d->mimeTypes = mimeTypes;
#endif
} }
void Package::setMimeTypes(const char *key, QStringList mimeTypes) void Package::setMimeTypes(const char *key, QStringList mimeTypes)
{ {
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
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;
#endif
} }
QList<const char*> Package::directories() const QList<const char*> Package::directories() const
@ -905,7 +926,9 @@ PackagePrivate &PackagePrivate::operator=(const PackagePrivate &rhs)
contentsPrefixPaths = rhs.contentsPrefixPaths; contentsPrefixPaths = rhs.contentsPrefixPaths;
servicePrefix = rhs.servicePrefix; servicePrefix = rhs.servicePrefix;
contents = rhs.contents; contents = rhs.contents;
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
mimeTypes = rhs.mimeTypes; mimeTypes = rhs.mimeTypes;
#endif
defaultPackageRoot = rhs.defaultPackageRoot; defaultPackageRoot = rhs.defaultPackageRoot;
servicePrefix = rhs.servicePrefix; servicePrefix = rhs.servicePrefix;
metadata = 0; metadata = 0;

View File

@ -42,15 +42,19 @@ class ContentStructure
ContentStructure(const ContentStructure &other) ContentStructure(const ContentStructure &other)
{ {
paths = other.paths; paths = other.paths;
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
name = other.name; name = other.name;
mimeTypes = other.mimeTypes; mimeTypes = other.mimeTypes;
#endif
directory = other.directory; directory = other.directory;
required = other.required; required = other.required;
} }
QStringList paths; QStringList paths;
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
QString name; QString name;
QStringList mimeTypes; QStringList mimeTypes;
#endif
bool directory : 1; bool directory : 1;
bool required : 1; bool required : 1;
}; };
@ -70,13 +74,14 @@ public:
static bool uninstallPackage(const QString &packageName, const QString &packageRoot, const QString &servicePrefix); static bool uninstallPackage(const QString &packageName, const QString &packageRoot, const QString &servicePrefix);
QWeakPointer<PackageStructure> structure; QWeakPointer<PackageStructure> structure;
QString type;
QString path; QString path;
QStringList contentsPrefixPaths; QStringList contentsPrefixPaths;
QString defaultPackageRoot; QString defaultPackageRoot;
QString servicePrefix; QString servicePrefix;
QMap<QByteArray, ContentStructure> contents; QMap<QByteArray, ContentStructure> contents;
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
QStringList mimeTypes; QStringList mimeTypes;
#endif
KPluginInfo *metadata; KPluginInfo *metadata;
bool externalPaths : 1; bool externalPaths : 1;
bool valid : 1; bool valid : 1;