Commit 031666c6 authored by Tobias Hunger's avatar Tobias Hunger

Rewrite SettingsAccessor::settingsFiles()

This no longer has the default name first, but that does
not matter since we check all files anyway.

Change-Id: Ib3505d2cafa57e86290237e74dd1f89374da4509
Reviewed-by: default avatarDaniel Teske <>
parent 327abfb3
...@@ -776,24 +776,28 @@ bool SettingsAccessor::addVersionUpgrader(VersionUpgrader *upgrader) ...@@ -776,24 +776,28 @@ bool SettingsAccessor::addVersionUpgrader(VersionUpgrader *upgrader)
return true; return true;
} }
/* Will always return the default name first */ /* Will always return the default name first (if applicable) */
QList<FileName> SettingsAccessor::settingsFiles(const QString &suffix) const QList<FileName> SettingsAccessor::settingsFiles(const QString &suffix) const
{ {
const QString defaultName = defaultFileName(suffix);
QDir projectDir = QDir(project()->projectDirectory().toString());
QList<Utils::FileName> result; QList<Utils::FileName> result;
if (QFileInfo(defaultName).exists())
result << Utils::FileName::fromString(defaultName);
QFileInfoList fiList = projectDir.entryInfoList( const Utils::FileName baseName = project()->projectFilePath();
QStringList(QFileInfo(defaultName).fileName() + QLatin1String("*")), QDir::Files); QFileInfo fi = baseName.toFileInfo();
QDir dir = QDir(fi.absolutePath());
QString filter = fi.fileName() + suffix + QLatin1String("*");
QFileInfoList list = dir.entryInfoList(QStringList() << filter, QDir::Files);
foreach (const QFileInfo &fi, fiList) { foreach (const QFileInfo &fi, list) {
const Utils::FileName path = Utils::FileName::fromString(fi.absoluteFilePath()); const Utils::FileName path = Utils::FileName::fromString(fi.absoluteFilePath());
if (!result.contains(path)) if (!result.contains(path)) {
if (path.endsWith(suffix))
result.append(path); result.append(path);
} }
return result; return result;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment