forked from qt-creator/qt-creator
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: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -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("*");
|
||||||
|
|
||||||
foreach (const QFileInfo &fi, fiList) {
|
QFileInfoList list = dir.entryInfoList(QStringList() << filter, QDir::Files);
|
||||||
|
|
||||||
|
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)) {
|
||||||
result.append(path);
|
if (path.endsWith(suffix))
|
||||||
|
result.prepend(path);
|
||||||
|
else
|
||||||
|
result.append(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user