Commit 74896187 authored by Tobias Hunger's avatar Tobias Hunger

SettingsAccessorPrivate::bestSettings: Use Utils::FileName

also remove the const from that method.

Change-Id: I5df052d39595eac885e1dbdafd50ccec3e850ca8
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent b9338df4
...@@ -456,7 +456,7 @@ public: ...@@ -456,7 +456,7 @@ public:
return m_upgraders.at(pos); return m_upgraders.at(pos);
return 0; return 0;
} }
Settings bestSettings(const SettingsAccessor *accessor, const QStringList &candidates) const; Settings bestSettings(const SettingsAccessor *accessor, const QList<Utils::FileName> &pathList);
QList<VersionUpgrader *> m_upgraders; QList<VersionUpgrader *> m_upgraders;
Utils::PersistentSettingsWriter *m_writer; Utils::PersistentSettingsWriter *m_writer;
...@@ -744,20 +744,20 @@ bool SettingsAccessor::addVersionUpgrader(VersionUpgrader *upgrader) ...@@ -744,20 +744,20 @@ bool SettingsAccessor::addVersionUpgrader(VersionUpgrader *upgrader)
} }
/* Will always return the default name first */ /* Will always return the default name first */
QStringList SettingsAccessor::findSettingsFiles(const QString &suffix) const QList<FileName> SettingsAccessor::findSettingsFiles(const QString &suffix) const
{ {
const QString defaultName = defaultFileName(suffix); const QString defaultName = defaultFileName(suffix);
QDir projectDir = QDir(project()->projectDirectory().toString()); QDir projectDir = QDir(project()->projectDirectory().toString());
QStringList result; QList<Utils::FileName> result;
if (QFileInfo(defaultName).exists()) if (QFileInfo(defaultName).exists())
result << defaultName; result << Utils::FileName::fromString(defaultName);
QFileInfoList fiList = projectDir.entryInfoList( QFileInfoList fiList = projectDir.entryInfoList(
QStringList(QFileInfo(defaultName).fileName() + QLatin1String("*")), QDir::Files); QStringList(QFileInfo(defaultName).fileName() + QLatin1String("*")), QDir::Files);
foreach (const QFileInfo &fi, fiList) { foreach (const QFileInfo &fi, fiList) {
const QString path = fi.absoluteFilePath(); const Utils::FileName path = Utils::FileName::fromString(fi.absoluteFilePath());
if (!result.contains(path)) if (!result.contains(path))
result.append(path); result.append(path);
} }
...@@ -813,7 +813,7 @@ void SettingsAccessor::backupUserFile() const ...@@ -813,7 +813,7 @@ void SettingsAccessor::backupUserFile() const
QVariantMap SettingsAccessor::readUserSettings(QWidget *parent) const QVariantMap SettingsAccessor::readUserSettings(QWidget *parent) const
{ {
SettingsAccessorPrivate::Settings result; SettingsAccessorPrivate::Settings result;
QStringList fileList = findSettingsFiles(m_userSuffix); QList<Utils::FileName> fileList = findSettingsFiles(m_userSuffix);
if (fileList.isEmpty()) // No settings found at all. if (fileList.isEmpty()) // No settings found at all.
return result.map; return result.map;
...@@ -908,14 +908,15 @@ QVariantMap SettingsAccessor::readSharedSettings(QWidget *parent) const ...@@ -908,14 +908,15 @@ QVariantMap SettingsAccessor::readSharedSettings(QWidget *parent) const
return sharedSettings.map; return sharedSettings.map;
} }
SettingsAccessorPrivate::Settings SettingsAccessorPrivate::bestSettings(const SettingsAccessor *accessor, const QStringList &candidates) const SettingsAccessorPrivate::Settings SettingsAccessorPrivate::bestSettings(const SettingsAccessor *accessor,
const QList<Utils::FileName> &pathList)
{ {
Settings newestNonMatching; Settings newestNonMatching;
Settings newestMatching; Settings newestMatching;
Settings tmp; Settings tmp;
foreach (const QString &file, candidates) { foreach (const Utils::FileName &file, pathList) {
tmp.path = FileName::fromString(file); tmp.path = file;
tmp.map = accessor->readFile(tmp.path); tmp.map = accessor->readFile(tmp.path);
if (tmp.map.isEmpty()) if (tmp.map.isEmpty())
continue; continue;
......
...@@ -71,7 +71,7 @@ protected: ...@@ -71,7 +71,7 @@ protected:
virtual QVariantMap prepareSettings(const QVariantMap &data) const; virtual QVariantMap prepareSettings(const QVariantMap &data) const;
private: private:
QStringList findSettingsFiles(const QString &suffix) const; QList<Utils::FileName> findSettingsFiles(const QString &suffix) const;
static QByteArray creatorId(); static QByteArray creatorId();
QString defaultFileName(const QString &suffix) const; QString defaultFileName(const QString &suffix) const;
void backupUserFile() const; void backupUserFile() const;
......
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