we need path *and* key

This commit is contained in:
Marco Martin 2012-10-15 20:41:27 +02:00
parent 05936e77d8
commit c6e84cd7d9
2 changed files with 9 additions and 7 deletions

View File

@ -60,9 +60,9 @@ QString FallbackComponent::filePath(const QString &key)
QString resolved;
foreach (const QString &path, m_candidates) {
kDebug() << "Searching for:" << path;
if (m_possiblePaths.contains(key)) {
resolved = *m_possiblePaths.object(key);
kDebug() << "Searching for:" << path + path;
if (m_possiblePaths.contains(path + key)) {
resolved = *m_possiblePaths.object(path + key);
if (!resolved.isEmpty()) {
break;
} else {
@ -71,13 +71,15 @@ QString FallbackComponent::filePath(const QString &key)
}
QDir tmpPath(m_basePath);
if (tmpPath.isAbsolute()) {
resolved = m_basePath + path;
resolved = m_basePath + path + key;
} else {
resolved = KStandardDirs::locate("data", m_basePath + '/' + path);
resolved = KStandardDirs::locate("data", m_basePath + '/' + path + key);
}
m_possiblePaths.insert(key, new QString(resolved));
m_possiblePaths.insert(path + key, new QString(resolved));
if (!resolved.isEmpty()) {
break;
}

View File

@ -55,7 +55,7 @@ public:
*
* @param key the name of the file to search for
**/
Q_INVOKABLE QString filePath(const QString& key);
Q_INVOKABLE QString filePath(const QString& key = QString());
QString basePath() const;
void setBasePath(const QString &basePath);