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)
|
ContentStructure(const ContentStructure &other)
|
||||||
{
|
{
|
||||||
path = other.path;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString path;
|
QStringList paths;
|
||||||
QString name;
|
QString name;
|
||||||
QStringList mimetypes;
|
QStringList mimetypes;
|
||||||
bool directory : 1;
|
bool directory : 1;
|
||||||
@ -304,8 +304,16 @@ void PackageStructure::addDirectoryDefinition(const char *key,
|
|||||||
const QString &path, const QString &name)
|
const QString &path, const QString &name)
|
||||||
{
|
{
|
||||||
ContentStructure s;
|
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;
|
s.directory = true;
|
||||||
|
|
||||||
d->contents[key] = s;
|
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)
|
void PackageStructure::addFileDefinition(const char *key, const QString &path, const QString &name)
|
||||||
{
|
{
|
||||||
ContentStructure s;
|
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;
|
s.directory = false;
|
||||||
|
|
||||||
d->contents[key] = s;
|
d->contents[key] = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackageStructure::removeDefinition(const char *key)
|
||||||
|
{
|
||||||
|
d->contents.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
QString PackageStructure::path(const char *key) const
|
QString PackageStructure::path(const char *key) const
|
||||||
{
|
{
|
||||||
//kDebug() << "looking for" << key;
|
//kDebug() << "looking for" << key;
|
||||||
@ -329,8 +350,20 @@ QString PackageStructure::path(const char *key) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//kDebug() << "found" << key << "and the value is" << it.value().path;
|
//kDebug() << "found" << key << "and the value is" << it.value().paths.first();
|
||||||
return it.value().path;
|
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
|
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();
|
QMap<QByteArray, ContentStructure>::const_iterator it = d->contents.constBegin();
|
||||||
while (it != d->contents.constEnd()) {
|
while (it != d->contents.constEnd()) {
|
||||||
KConfigGroup group = config->group(it.key());
|
KConfigGroup group = config->group(it.key());
|
||||||
group.writeEntry("Path", it.value().path);
|
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);
|
||||||
|
@ -133,6 +133,9 @@ 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
|
||||||
|
* already exists, the path is added to it as a search alternative.
|
||||||
|
*
|
||||||
* @param key used as an internal label for this directory
|
* @param key used as an internal label for this directory
|
||||||
* @param path the path within the package for this directory
|
* @param path the path within the package for this directory
|
||||||
* @param name the user visible (translated) name for the 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
|
* 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
|
||||||
|
* already exists, the path is added to it as a search alternative.
|
||||||
|
*
|
||||||
* @param key used as an internal label for this file
|
* @param key used as an internal label for this file
|
||||||
* @param path the path within the package for this file
|
* @param path the path within the package for this file
|
||||||
* @param name the user visible (translated) name for the file
|
* @param name the user visible (translated) name for the file
|
||||||
**/
|
**/
|
||||||
void addFileDefinition(const char *key, const QString &path, const QString &name);
|
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
|
* @return path relative to the package root for the given entry
|
||||||
|
* @deprecatd use searchPaths instead
|
||||||
**/
|
**/
|
||||||
QString path(const char *key) const;
|
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.
|
* Get the list of files of a given type.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user