FEATURE: allow entire search paths for a given key, as seen on RB#5763
svn path=/trunk/KDE/kdelibs/; revision=1192747
This commit is contained in:
parent
714578ecc3
commit
433bb098dd
@ -56,14 +56,14 @@ class ContentStructure
|
||||
|
||||
ContentStructure(const ContentStructure &other)
|
||||
{
|
||||
path = other.path;
|
||||
paths = other.paths;
|
||||
name = other.name;
|
||||
mimetypes = other.mimetypes;
|
||||
directory = other.directory;
|
||||
required = other.required;
|
||||
}
|
||||
|
||||
QString path;
|
||||
QStringList paths;
|
||||
QString name;
|
||||
QStringList mimetypes;
|
||||
bool directory : 1;
|
||||
@ -304,8 +304,16 @@ void PackageStructure::addDirectoryDefinition(const char *key,
|
||||
const QString &path, const QString &name)
|
||||
{
|
||||
ContentStructure s;
|
||||
s.name = name;
|
||||
s.path = path;
|
||||
|
||||
if (d->contents.contains(key)) {
|
||||
s = d->contents[key];
|
||||
}
|
||||
|
||||
if (!name.isEmpty()) {
|
||||
s.name = name;
|
||||
}
|
||||
|
||||
s.paths.append(path);
|
||||
s.directory = true;
|
||||
|
||||
d->contents[key] = s;
|
||||
@ -314,13 +322,26 @@ void PackageStructure::addDirectoryDefinition(const char *key,
|
||||
void PackageStructure::addFileDefinition(const char *key, const QString &path, const QString &name)
|
||||
{
|
||||
ContentStructure s;
|
||||
s.name = name;
|
||||
s.path = path;
|
||||
|
||||
if (d->contents.contains(key)) {
|
||||
s = d->contents[key];
|
||||
}
|
||||
|
||||
if (!name.isEmpty()) {
|
||||
s.name = name;
|
||||
}
|
||||
|
||||
s.paths.append(path);
|
||||
s.directory = false;
|
||||
|
||||
d->contents[key] = s;
|
||||
}
|
||||
|
||||
void PackageStructure::removeDefinition(const char *key)
|
||||
{
|
||||
d->contents.remove(key);
|
||||
}
|
||||
|
||||
QString PackageStructure::path(const char *key) const
|
||||
{
|
||||
//kDebug() << "looking for" << key;
|
||||
@ -329,8 +350,20 @@ QString PackageStructure::path(const char *key) const
|
||||
return QString();
|
||||
}
|
||||
|
||||
//kDebug() << "found" << key << "and the value is" << it.value().path;
|
||||
return it.value().path;
|
||||
//kDebug() << "found" << key << "and the value is" << it.value().paths.first();
|
||||
return it.value().paths.first();
|
||||
}
|
||||
|
||||
QStringList PackageStructure::searchPath(const char *key) const
|
||||
{
|
||||
//kDebug() << "looking for" << key;
|
||||
QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constFind(key);
|
||||
if (it == d->contents.constEnd()) {
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
//kDebug() << "found" << key << "and the value is" << it.value().paths;
|
||||
return it.value().paths;
|
||||
}
|
||||
|
||||
QString PackageStructure::name(const char *key) const
|
||||
@ -473,7 +506,7 @@ void PackageStructure::write(KConfigBase *config) const
|
||||
QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constBegin();
|
||||
while (it != d->contents.constEnd()) {
|
||||
KConfigGroup group = config->group(it.key());
|
||||
group.writeEntry("Path", it.value().path);
|
||||
group.writeEntry("Path", it.value().paths);
|
||||
group.writeEntry("Name", it.value().name);
|
||||
if (!it.value().mimetypes.isEmpty()) {
|
||||
group.writeEntry("Mimetypes", it.value().mimetypes);
|
||||
|
@ -133,6 +133,9 @@ public:
|
||||
* Adds a directory to the structure of the package. It is added as
|
||||
* a not-required element with no associated mimetypes.
|
||||
*
|
||||
* Starting in 4.6, if an entry with the given key
|
||||
* already exists, the path is added to it as a search alternative.
|
||||
*
|
||||
* @param key used as an internal label for this directory
|
||||
* @param path the path within the package for this directory
|
||||
* @param name the user visible (translated) name for the directory
|
||||
@ -143,17 +146,34 @@ public:
|
||||
* Adds a file to the structure of the package. It is added as
|
||||
* a not-required element with no associated mimetypes.
|
||||
*
|
||||
* Starting in 4.6, if an entry with the given key
|
||||
* already exists, the path is added to it as a search alternative.
|
||||
*
|
||||
* @param key used as an internal label for this file
|
||||
* @param path the path within the package for this file
|
||||
* @param name the user visible (translated) name for the file
|
||||
**/
|
||||
void addFileDefinition(const char *key, const QString &path, const QString &name);
|
||||
|
||||
/**
|
||||
* Removes a definition from the structure of the package.
|
||||
* @since 4.6
|
||||
* @param key the internal label of the file or directory to remove
|
||||
*/
|
||||
void removeDefinition(const char *key);
|
||||
|
||||
/**
|
||||
* @return path relative to the package root for the given entry
|
||||
* @deprecatd use searchPaths instead
|
||||
**/
|
||||
QString path(const char *key) const;
|
||||
|
||||
/**
|
||||
* @return a list of paths relative to the package root for the given entry
|
||||
* @since 4.6
|
||||
**/
|
||||
QStringList searchPath(const char *key) const;
|
||||
|
||||
/**
|
||||
* Get the list of files of a given type.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user