forked from mirror/openmw-tes3mp
Implmented QSettings for loading / saving file definitions. Also
renamed opencs.cfg to opencs.ini to follow Ini format standards
This commit is contained in:
parent
3f737bbb44
commit
475214ab62
11 changed files with 63 additions and 259 deletions
|
@ -368,7 +368,7 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
||||||
"${OpenMW_BINARY_DIR}/openmw.cfg.install")
|
"${OpenMW_BINARY_DIR}/openmw.cfg.install")
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/opencs.cfg
|
configure_file(${OpenMW_SOURCE_DIR}/files/opencs.conf
|
||||||
"${OpenMW_BINARY_DIR}/opencs.cfg")
|
"${OpenMW_BINARY_DIR}/opencs.cfg")
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters
|
configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters
|
||||||
|
|
|
@ -27,7 +27,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
|
||||||
|
|
||||||
setupDataFiles (config.first);
|
setupDataFiles (config.first);
|
||||||
|
|
||||||
CSMSettings::UserSettings::instance().loadSettings ("opencs.cfg");
|
CSMSettings::UserSettings::instance().loadSettings ("opencs.ini");
|
||||||
mSettings.setModel (CSMSettings::UserSettings::instance());
|
mSettings.setModel (CSMSettings::UserSettings::instance());
|
||||||
|
|
||||||
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());
|
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());
|
||||||
|
|
|
@ -45,7 +45,7 @@ void CSMSettings::Setting::addProxy (const Setting *setting,
|
||||||
foreach (const QString &val, vals)
|
foreach (const QString &val, vals)
|
||||||
list << (QStringList() << val);
|
list << (QStringList() << val);
|
||||||
|
|
||||||
mProxies [setting->page() + '.' + setting->name()] = list;
|
mProxies [setting->page() + '/' + setting->name()] = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::addProxy (const Setting *setting,
|
void CSMSettings::Setting::addProxy (const Setting *setting,
|
||||||
|
@ -54,7 +54,7 @@ void CSMSettings::Setting::addProxy (const Setting *setting,
|
||||||
if (serializable())
|
if (serializable())
|
||||||
setProperty (Property_Serializable, false);
|
setProperty (Property_Serializable, false);
|
||||||
|
|
||||||
mProxies [setting->page() + '.' + setting->name()] = list;
|
mProxies [setting->page() + '/' + setting->name()] = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setColumnSpan (int value)
|
void CSMSettings::Setting::setColumnSpan (int value)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
#include "settingmanager.hpp"
|
#include "settingmanager.hpp"
|
||||||
|
@ -20,15 +21,6 @@ CSMSettings::SettingManager::SettingManager(QObject *parent) :
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::SettingManager::dumpModel()
|
|
||||||
{
|
|
||||||
foreach (Setting *setting, mSettings)
|
|
||||||
{
|
|
||||||
if (setting->proxyLists().isEmpty())
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
||||||
(CSMSettings::SettingType typ, const QString &page, const QString &name)
|
(CSMSettings::SettingType typ, const QString &page, const QString &name)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +28,7 @@ CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
||||||
if (findSetting (page, name))
|
if (findSetting (page, name))
|
||||||
{
|
{
|
||||||
qWarning() << "Duplicate declaration encountered: "
|
qWarning() << "Duplicate declaration encountered: "
|
||||||
<< (name + '.' + page);
|
<< (name + '/' + page);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,182 +41,6 @@ CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
||||||
return setting;
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::DefinitionPageMap
|
|
||||||
CSMSettings::SettingManager::readFilestream (QTextStream *stream)
|
|
||||||
{
|
|
||||||
//regEx's for page names and keys / values
|
|
||||||
QRegExp pageRegEx ("^\\[([^]]+)\\]");
|
|
||||||
QRegExp keyRegEx ("^([^=]+)\\s*=\\s*(.+)$");
|
|
||||||
|
|
||||||
QString currPage = "Unassigned";
|
|
||||||
|
|
||||||
DefinitionPageMap pageMap;
|
|
||||||
|
|
||||||
if (!stream)
|
|
||||||
{
|
|
||||||
displayFileErrorMessage(mReadWriteMessage, false);
|
|
||||||
return pageMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream->atEnd())
|
|
||||||
return pageMap;
|
|
||||||
|
|
||||||
DefinitionMap *settingMap = new DefinitionMap();
|
|
||||||
pageMap[currPage] = settingMap;
|
|
||||||
|
|
||||||
while (!stream->atEnd())
|
|
||||||
{
|
|
||||||
QString line = stream->readLine().simplified();
|
|
||||||
|
|
||||||
if (line.isEmpty() || line.startsWith("#"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//page name found
|
|
||||||
if (pageRegEx.exactMatch(line))
|
|
||||||
{
|
|
||||||
currPage = pageRegEx.cap(1).simplified().trimmed();
|
|
||||||
settingMap = new DefinitionMap();
|
|
||||||
pageMap[currPage] = settingMap;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//setting definition found
|
|
||||||
if ( (keyRegEx.indexIn(line) != -1))
|
|
||||||
{
|
|
||||||
QString settingName = keyRegEx.cap(1).simplified();
|
|
||||||
QString settingValue = keyRegEx.cap(2).simplified();
|
|
||||||
|
|
||||||
if (!settingMap->contains (settingName))
|
|
||||||
settingMap->insert (settingName, new QStringList());
|
|
||||||
|
|
||||||
settingMap->value(settingName)->append(settingValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//return empty map if no settings were ever added to
|
|
||||||
if (pageMap.size() == 1)
|
|
||||||
{
|
|
||||||
QString pageKey = pageMap.keys().at(0);
|
|
||||||
if (pageMap[pageKey]->size() == 0)
|
|
||||||
pageMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return pageMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSMSettings::SettingManager::writeFilestream(QTextStream *stream,
|
|
||||||
const QMap <QString, QStringList > &settingListMap)
|
|
||||||
{
|
|
||||||
if (!stream)
|
|
||||||
{
|
|
||||||
displayFileErrorMessage(mReadWriteMessage, false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//disabled after rolling selector class into view. Need to
|
|
||||||
//iterate views to get setting definitions before writing to file
|
|
||||||
|
|
||||||
QStringList sectionKeys;
|
|
||||||
|
|
||||||
foreach (const QString &key, settingListMap.keys())
|
|
||||||
{
|
|
||||||
QStringList names = key.split('.');
|
|
||||||
QString section = names.at(0);
|
|
||||||
|
|
||||||
if (!sectionKeys.contains(section))
|
|
||||||
if (!settingListMap.value(key).isEmpty())
|
|
||||||
sectionKeys.append (section);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (const QString §ion, sectionKeys)
|
|
||||||
{
|
|
||||||
*stream << '[' << section << "]\n";
|
|
||||||
foreach (const QString &key, settingListMap.keys())
|
|
||||||
{
|
|
||||||
QStringList names = key.split('.');
|
|
||||||
|
|
||||||
if (names.at(0) != section)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QStringList list = settingListMap.value(key);
|
|
||||||
|
|
||||||
if (list.isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QString name = names.at(1);
|
|
||||||
|
|
||||||
foreach (const QString value, list)
|
|
||||||
{
|
|
||||||
if (value.isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
*stream << name << " = " << value << '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destroyStream (stream);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSMSettings::SettingManager::mergeSettings(DefinitionPageMap &destMap, DefinitionPageMap &srcMap)
|
|
||||||
{
|
|
||||||
if (srcMap.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (const QString &pageKey, srcMap.keys())
|
|
||||||
{
|
|
||||||
DefinitionMap *srcSetting = srcMap.value(pageKey);
|
|
||||||
//Unique Page:
|
|
||||||
//insertfrom the source map
|
|
||||||
if (!destMap.keys().contains (pageKey))
|
|
||||||
{
|
|
||||||
destMap.insert (pageKey, srcSetting);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DefinitionMap *destSetting = destMap.value(pageKey);
|
|
||||||
|
|
||||||
//Duplicate Page:
|
|
||||||
//iterate the settings in the source and check for duplicates in the
|
|
||||||
//destination
|
|
||||||
foreach (const QString &srcKey, srcSetting->keys())
|
|
||||||
{
|
|
||||||
//insert into destination if unique
|
|
||||||
if (!destSetting->keys().contains (srcKey))
|
|
||||||
destSetting->insert(srcKey, srcSetting->value (srcKey));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream *CSMSettings::SettingManager::openFilestream (const QString &filePath,
|
|
||||||
bool isReadOnly) const
|
|
||||||
{
|
|
||||||
QIODevice::OpenMode openFlags = QIODevice::Text;
|
|
||||||
|
|
||||||
if (isReadOnly)
|
|
||||||
openFlags = QIODevice::ReadOnly | openFlags;
|
|
||||||
else
|
|
||||||
openFlags = QIODevice::ReadWrite | QIODevice::Truncate | openFlags;
|
|
||||||
|
|
||||||
QFile *file = new QFile(filePath);
|
|
||||||
QTextStream *stream = 0;
|
|
||||||
|
|
||||||
if (file->open(openFlags))
|
|
||||||
stream = new QTextStream(file);
|
|
||||||
|
|
||||||
if (stream)
|
|
||||||
stream->setCodec(QTextCodec::codecForName("UTF-8"));
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSMSettings::SettingManager::destroyStream(QTextStream *stream) const
|
|
||||||
{
|
|
||||||
stream->device()->close();
|
|
||||||
|
|
||||||
delete stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSMSettings::SettingManager::displayFileErrorMessage(const QString &message,
|
void CSMSettings::SettingManager::displayFileErrorMessage(const QString &message,
|
||||||
bool isReadOnly) const
|
bool isReadOnly) const
|
||||||
{
|
{
|
||||||
|
@ -242,29 +58,29 @@ void CSMSettings::SettingManager::displayFileErrorMessage(const QString &message
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::SettingManager::addDefinitions (DefinitionPageMap &pageMap)
|
void CSMSettings::SettingManager::addDefinitions (const QSettings *settings)
|
||||||
{
|
{
|
||||||
foreach (QString pageName, pageMap.keys())
|
foreach (const QString &key, settings->allKeys())
|
||||||
{
|
{
|
||||||
DefinitionMap *settingMap = pageMap.value (pageName);
|
QStringList names = key.split('/');
|
||||||
|
|
||||||
foreach (QString settingName, (*settingMap).keys())
|
Setting *setting = findSetting (names.at(0), names.at(1));
|
||||||
|
|
||||||
|
if (!setting)
|
||||||
{
|
{
|
||||||
QStringList *values = settingMap->value (settingName);
|
qWarning() << "Found definitions for undeclared setting "
|
||||||
Setting *setting = findSetting (pageName, settingName);
|
<< names.at(0) << "." << names.at(1);
|
||||||
|
continue;
|
||||||
if (!setting)
|
|
||||||
{
|
|
||||||
qWarning() << "Found definitions for undeclared setting "
|
|
||||||
<< pageName << "." << settingName;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (values->size() == 0)
|
|
||||||
values->append (setting->defaultValues());
|
|
||||||
|
|
||||||
setting->setDefinedValues (*values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList values = settings->value (key).toStringList();
|
||||||
|
|
||||||
|
if (values.isEmpty())
|
||||||
|
values.append (setting->defaultValues());
|
||||||
|
|
||||||
|
setting->setDefinedValues (values);
|
||||||
|
|
||||||
|
qDebug() << "added definitons " << values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +113,7 @@ CSMSettings::Setting *CSMSettings::SettingManager::findSetting
|
||||||
{
|
{
|
||||||
foreach (Setting *setting, mSettings)
|
foreach (Setting *setting, mSettings)
|
||||||
{
|
{
|
||||||
if (setting->name() == settingName)
|
if (settingName.isEmpty() || (setting->name() == settingName))
|
||||||
{
|
{
|
||||||
if (setting->page() == pageName)
|
if (setting->page() == pageName)
|
||||||
return setting;
|
return setting;
|
||||||
|
@ -305,7 +121,7 @@ CSMSettings::Setting *CSMSettings::SettingManager::findSetting
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
QList <CSMSettings::Setting *> CSMSettings::SettingManager::findSettings
|
QList <CSMSettings::Setting *> CSMSettings::SettingManager::findSettings
|
||||||
(const QString &pageName)
|
(const QString &pageName)
|
||||||
{
|
{
|
||||||
|
@ -318,7 +134,7 @@ QList <CSMSettings::Setting *> CSMSettings::SettingManager::findSettings
|
||||||
}
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
CSMSettings::SettingPageMap CSMSettings::SettingManager::settingPageMap() const
|
CSMSettings::SettingPageMap CSMSettings::SettingManager::settingPageMap() const
|
||||||
{
|
{
|
||||||
SettingPageMap pageMap;
|
SettingPageMap pageMap;
|
||||||
|
@ -332,7 +148,7 @@ CSMSettings::SettingPageMap CSMSettings::SettingManager::settingPageMap() const
|
||||||
void CSMSettings::SettingManager::updateUserSetting(const QString &settingKey,
|
void CSMSettings::SettingManager::updateUserSetting(const QString &settingKey,
|
||||||
const QStringList &list)
|
const QStringList &list)
|
||||||
{
|
{
|
||||||
QStringList names = settingKey.split('.');
|
QStringList names = settingKey.split('/');
|
||||||
|
|
||||||
Setting *setting = findSetting (names.at(0), names.at(1));
|
Setting *setting = findSetting (names.at(0), names.at(1));
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "support.hpp"
|
#include "support.hpp"
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
|
@ -30,7 +31,7 @@ namespace CSMSettings
|
||||||
|
|
||||||
///retrieve a setting object from a given page and setting name
|
///retrieve a setting object from a given page and setting name
|
||||||
Setting *findSetting
|
Setting *findSetting
|
||||||
(const QString &pageName, const QString &settingName);
|
(const QString &pageName, const QString &settingName = QString());
|
||||||
|
|
||||||
///retrieve all settings for a specified page
|
///retrieve all settings for a specified page
|
||||||
QList <Setting *> findSettings (const QString &pageName);
|
QList <Setting *> findSettings (const QString &pageName);
|
||||||
|
@ -49,28 +50,12 @@ namespace CSMSettings
|
||||||
const QString &page, const QString &name);
|
const QString &page, const QString &name);
|
||||||
|
|
||||||
///add definitions to the settings specified in the page map
|
///add definitions to the settings specified in the page map
|
||||||
void addDefinitions (DefinitionPageMap &pageMap);
|
void addDefinitions (const QSettings *settings);
|
||||||
|
|
||||||
///read setting definitions from file
|
|
||||||
DefinitionPageMap readFilestream(QTextStream *stream);
|
|
||||||
|
|
||||||
///write setting definitions to file
|
|
||||||
bool writeFilestream (QTextStream *stream,
|
|
||||||
const QMap <QString, QStringList > &settingMap);
|
|
||||||
|
|
||||||
///merge PageMaps of settings when loading from multiple files
|
|
||||||
void mergeSettings (DefinitionPageMap &destMap, DefinitionPageMap &srcMap);
|
|
||||||
|
|
||||||
QTextStream *openFilestream (const QString &filePath,
|
|
||||||
bool isReadOnly) const;
|
|
||||||
|
|
||||||
void destroyStream(QTextStream *stream) const;
|
|
||||||
|
|
||||||
void displayFileErrorMessage(const QString &message,
|
void displayFileErrorMessage(const QString &message,
|
||||||
bool isReadOnly) const;
|
bool isReadOnly) const;
|
||||||
|
|
||||||
QList <Setting *> settings() const { return mSettings; }
|
QList <Setting *> settings() const { return mSettings; }
|
||||||
void dumpModel();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
|
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
#include "support.hpp"
|
#include "support.hpp"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
||||||
|
@ -40,6 +42,8 @@ CSMSettings::UserSettings::UserSettings()
|
||||||
assert(!mUserSettingsInstance);
|
assert(!mUserSettingsInstance);
|
||||||
mUserSettingsInstance = this;
|
mUserSettingsInstance = this;
|
||||||
|
|
||||||
|
mSettings = 0;
|
||||||
|
|
||||||
buildSettingModelDefaults();
|
buildSettingModelDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,16 +297,16 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
||||||
(mCfgMgr.getLocalPath().string().c_str()) + fileName.toUtf8();
|
(mCfgMgr.getLocalPath().string().c_str()) + fileName.toUtf8();
|
||||||
|
|
||||||
//open user and global streams
|
//open user and global streams
|
||||||
QTextStream *userStream = openFilestream (mUserFilePath, true);
|
//QTextStream *userStream = openFilestream (mUserFilePath, true);
|
||||||
QTextStream *otherStream = openFilestream (global, true);
|
// QTextStream *otherStream = openFilestream (global, true);
|
||||||
|
|
||||||
//failed stream, try for local
|
//failed stream, try for local
|
||||||
if (!otherStream)
|
// if (!otherStream)
|
||||||
otherStream = openFilestream (local, true);
|
// otherStream = openFilestream (local, true);
|
||||||
|
|
||||||
//error condition - notify and return
|
//error condition - notify and return
|
||||||
if (!otherStream || !userStream)
|
// if (!otherStream || !userStream)
|
||||||
{
|
/* {
|
||||||
QString message = QObject::tr("<br><b>An error was encountered loading \
|
QString message = QObject::tr("<br><b>An error was encountered loading \
|
||||||
user settings files.</b><br><br> One or several files could not \
|
user settings files.</b><br><br> One or several files could not \
|
||||||
be read. This may be caused by a missing configuration file, \
|
be read. This may be caused by a missing configuration file, \
|
||||||
|
@ -316,40 +320,34 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
||||||
displayFileErrorMessage ( message, true);
|
displayFileErrorMessage ( message, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
//QSETTINGS TEST
|
||||||
|
qDebug() << mCfgMgr.getUserConfigPath().string().c_str() << ',' << mCfgMgr.getGlobalPath().string().c_str();
|
||||||
|
|
||||||
//success condition - merge the two streams into a single map and save
|
QSettings::setPath (QSettings::IniFormat, QSettings::UserScope, mCfgMgr.getUserConfigPath().string().c_str());
|
||||||
DefinitionPageMap totalMap = readFilestream (userStream);
|
QSettings::setPath (QSettings::IniFormat, QSettings::SystemScope, mCfgMgr.getGlobalPath().string().c_str());
|
||||||
DefinitionPageMap otherMap = readFilestream(otherStream);
|
|
||||||
|
|
||||||
//merging other settings file in and ignore duplicate settings to
|
if (mSettings)
|
||||||
//avoid overwriting user-level settings
|
delete mSettings;
|
||||||
mergeSettings (totalMap, otherMap);
|
|
||||||
|
|
||||||
if (!totalMap.isEmpty())
|
mSettings = new QSettings
|
||||||
addDefinitions (totalMap);
|
(QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this);
|
||||||
|
|
||||||
|
addDefinitions (mSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::saveSettings
|
void CSMSettings::UserSettings::saveSettings
|
||||||
(const QMap <QString, QStringList> &settingMap)
|
(const QMap <QString, QStringList> &settingMap)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < settings().size(); i++)
|
foreach (const QString &key, settingMap.keys())
|
||||||
{
|
mSettings->setValue (key, settingMap.value (key));
|
||||||
Setting* setting = settings().at(i);
|
|
||||||
|
|
||||||
QString key = setting->page() + '.' + setting->name();
|
delete mSettings;
|
||||||
|
|
||||||
if (!settingMap.keys().contains(key))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
setting->setDefinedValues (settingMap.value(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFilestream (openFilestream (mUserFilePath, false), settingMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
||||||
{
|
{
|
||||||
QStringList names = settingKey.split('.');
|
QStringList names = settingKey.split('/');
|
||||||
|
|
||||||
Setting *setting = findSetting(names.at(0), names.at(1));
|
Setting *setting = findSetting(names.at(0), names.at(1));
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
||||||
struct ConfigurationManager;}
|
struct ConfigurationManager;}
|
||||||
|
|
||||||
class QFile;
|
class QFile;
|
||||||
|
class QSettings;
|
||||||
|
|
||||||
namespace CSMSettings {
|
namespace CSMSettings {
|
||||||
|
|
||||||
|
@ -32,6 +33,8 @@ namespace CSMSettings {
|
||||||
|
|
||||||
QString mReadOnlyMessage;
|
QString mReadOnlyMessage;
|
||||||
QString mReadWriteMessage;
|
QString mReadWriteMessage;
|
||||||
|
QSettings *mSettings;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ void CSVSettings::SettingWindow::createConnections
|
||||||
|
|
||||||
foreach (const QString &key, proxyMap.keys())
|
foreach (const QString &key, proxyMap.keys())
|
||||||
{
|
{
|
||||||
QStringList keyPair = key.split('.');
|
QStringList keyPair = key.split('/');
|
||||||
|
|
||||||
if (keyPair.size() != 2)
|
if (keyPair.size() != 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -14,7 +14,7 @@ CSVSettings::View::View(CSMSettings::Setting *setting,
|
||||||
: mDataModel(0), mParentPage (parent),
|
: mDataModel(0), mParentPage (parent),
|
||||||
mHasFixedValues (!setting->declaredValues().isEmpty()),
|
mHasFixedValues (!setting->declaredValues().isEmpty()),
|
||||||
mIsMultiValue (setting->isMultiValue()),
|
mIsMultiValue (setting->isMultiValue()),
|
||||||
mViewKey (setting->page() + '.' + setting->name()),
|
mViewKey (setting->page() + '/' + setting->name()),
|
||||||
mSerializable (setting->serializable()),
|
mSerializable (setting->serializable()),
|
||||||
Frame(true, setting->name(), parent)
|
Frame(true, setting->name(), parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,8 +42,10 @@ namespace CSVSettings
|
||||||
///State indicating whether the view will allow multiple values
|
///State indicating whether the view will allow multiple values
|
||||||
bool mIsMultiValue;
|
bool mIsMultiValue;
|
||||||
|
|
||||||
|
///'pagename.settingname' form of the view's id
|
||||||
QString mViewKey;
|
QString mViewKey;
|
||||||
|
|
||||||
|
///indicates whether or not the setting is written to file
|
||||||
bool mSerializable;
|
bool mSerializable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue