mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 22:45:34 +00:00
Use QMultiMap instead of QMap
This commit is contained in:
parent
19e95afc42
commit
487bfed672
5 changed files with 20 additions and 20 deletions
|
@ -2,11 +2,8 @@
|
||||||
#include "launchersettings.hpp"
|
#include "launchersettings.hpp"
|
||||||
|
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QTextStream>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QString>
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
|
@ -105,9 +102,9 @@ bool Config::GameSettings::readUserFile(QTextStream &stream)
|
||||||
return readFile(stream, mUserSettings);
|
return readFile(stream, mUserSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::GameSettings::readFile(QTextStream &stream, QMap<QString, QString> &settings)
|
bool Config::GameSettings::readFile(QTextStream &stream, QMultiMap<QString, QString> &settings)
|
||||||
{
|
{
|
||||||
QMap<QString, QString> cache;
|
QMultiMap<QString, QString> cache;
|
||||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||||
|
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
|
@ -151,7 +148,7 @@ bool Config::GameSettings::readFile(QTextStream &stream, QMap<QString, QString>
|
||||||
values.append(settings.values(key));
|
values.append(settings.values(key));
|
||||||
|
|
||||||
if (!values.contains(value)) {
|
if (!values.contains(value)) {
|
||||||
cache.insertMulti(key, value);
|
cache.insert(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,7 +365,7 @@ bool Config::GameSettings::writeFileWithComments(QFile &file)
|
||||||
*iter = QString(); // assume no match
|
*iter = QString(); // assume no match
|
||||||
QString key = settingRegex.cap(1);
|
QString key = settingRegex.cap(1);
|
||||||
QString keyVal = settingRegex.cap(1)+"="+settingRegex.cap(2);
|
QString keyVal = settingRegex.cap(1)+"="+settingRegex.cap(2);
|
||||||
QMap<QString, QString>::const_iterator i = mUserSettings.find(key);
|
QMultiMap<QString, QString>::const_iterator i = mUserSettings.find(key);
|
||||||
while (i != mUserSettings.end() && i.key() == key)
|
while (i != mUserSettings.end() && i.key() == key)
|
||||||
{
|
{
|
||||||
QString settingLine = i.key() + "=" + i.value();
|
QString settingLine = i.key() + "=" + i.value();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QMap>
|
#include <QMultiMap>
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
@ -31,7 +31,9 @@ namespace Config
|
||||||
|
|
||||||
inline void setValue(const QString &key, const QString &value)
|
inline void setValue(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
|
mSettings.remove(key);
|
||||||
mSettings.insert(key, value);
|
mSettings.insert(key, value);
|
||||||
|
mUserSettings.remove(key);
|
||||||
mUserSettings.insert(key, value);
|
mUserSettings.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +41,11 @@ namespace Config
|
||||||
{
|
{
|
||||||
QStringList values = mSettings.values(key);
|
QStringList values = mSettings.values(key);
|
||||||
if (!values.contains(value))
|
if (!values.contains(value))
|
||||||
mSettings.insertMulti(key, value);
|
mSettings.insert(key, value);
|
||||||
|
|
||||||
values = mUserSettings.values(key);
|
values = mUserSettings.values(key);
|
||||||
if (!values.contains(value))
|
if (!values.contains(value))
|
||||||
mUserSettings.insertMulti(key, value);
|
mUserSettings.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void remove(const QString &key)
|
inline void remove(const QString &key)
|
||||||
|
@ -63,7 +65,7 @@ namespace Config
|
||||||
QStringList values(const QString &key, const QStringList &defaultValues = QStringList()) const;
|
QStringList values(const QString &key, const QStringList &defaultValues = QStringList()) const;
|
||||||
|
|
||||||
bool readFile(QTextStream &stream);
|
bool readFile(QTextStream &stream);
|
||||||
bool readFile(QTextStream &stream, QMap<QString, QString> &settings);
|
bool readFile(QTextStream &stream, QMultiMap<QString, QString> &settings);
|
||||||
bool readUserFile(QTextStream &stream);
|
bool readUserFile(QTextStream &stream);
|
||||||
|
|
||||||
bool writeFile(QTextStream &stream);
|
bool writeFile(QTextStream &stream);
|
||||||
|
@ -78,8 +80,8 @@ namespace Config
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
|
|
||||||
void validatePaths();
|
void validatePaths();
|
||||||
QMap<QString, QString> mSettings;
|
QMultiMap<QString, QString> mSettings;
|
||||||
QMap<QString, QString> mUserSettings;
|
QMultiMap<QString, QString> mUserSettings;
|
||||||
|
|
||||||
QStringList mDataDirs;
|
QStringList mDataDirs;
|
||||||
QString mDataLocal;
|
QString mDataLocal;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QMap>
|
#include <QMultiMap>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ Config::LauncherSettings::~LauncherSettings()
|
||||||
|
|
||||||
QStringList Config::LauncherSettings::subKeys(const QString &key)
|
QStringList Config::LauncherSettings::subKeys(const QString &key)
|
||||||
{
|
{
|
||||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
QMultiMap<QString, QString> settings = SettingsBase::getSettings();
|
||||||
QStringList keys = settings.uniqueKeys();
|
QStringList keys = settings.uniqueKeys();
|
||||||
|
|
||||||
QRegExp keyRe("(.+)/");
|
QRegExp keyRe("(.+)/");
|
||||||
|
@ -54,7 +54,7 @@ bool Config::LauncherSettings::writeFile(QTextStream &stream)
|
||||||
{
|
{
|
||||||
QString sectionPrefix;
|
QString sectionPrefix;
|
||||||
QRegExp sectionRe("([^/]+)/(.+)$");
|
QRegExp sectionRe("([^/]+)/(.+)$");
|
||||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
QMultiMap<QString, QString> settings = SettingsBase::getSettings();
|
||||||
|
|
||||||
QMapIterator<QString, QString> i(settings);
|
QMapIterator<QString, QString> i(settings);
|
||||||
i.toBack();
|
i.toBack();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
class LauncherSettings : public SettingsBase<QMultiMap<QString, QString> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LauncherSettings();
|
LauncherSettings();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QMap>
|
#include <QMultiMap>
|
||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ namespace Config
|
||||||
{
|
{
|
||||||
QStringList values = mSettings.values(key);
|
QStringList values = mSettings.values(key);
|
||||||
if (!values.contains(value))
|
if (!values.contains(value))
|
||||||
mSettings.insertMulti(key, value);
|
mSettings.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setMultiValueEnabled(bool enable)
|
inline void setMultiValueEnabled(bool enable)
|
||||||
|
@ -83,8 +83,9 @@ namespace Config
|
||||||
|
|
||||||
if (!values.contains(value)) {
|
if (!values.contains(value)) {
|
||||||
if (mMultiValue) {
|
if (mMultiValue) {
|
||||||
cache.insertMulti(key, value);
|
cache.insert(key, value);
|
||||||
} else {
|
} else {
|
||||||
|
cache.remove(key);
|
||||||
cache.insert(key, value);
|
cache.insert(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue