diff options
| author | Sebastien Braun | 2010-10-06 00:04:49 +0200 |
|---|---|---|
| committer | Sebastien Braun | 2010-10-06 00:04:49 +0200 |
| commit | f07fc3b426815e28fde23313242fbbb998a08d45 (patch) | |
| tree | ba9eda1a83135a1727d2d35661d6facabee53b95 /src/util/pvsSettingsManager.cpp | |
| parent | Fix recognition of letters in keyboard handler (diff) | |
| parent | Merge remote branch 'openslx/master' into mcastft (diff) | |
| download | pvs-f07fc3b426815e28fde23313242fbbb998a08d45.tar.gz pvs-f07fc3b426815e28fde23313242fbbb998a08d45.tar.xz pvs-f07fc3b426815e28fde23313242fbbb998a08d45.zip | |
Merge remote branch 'openslx/mcastft' into input
Conflicts:
CMakeLists.txt
i18n/pvs_ar_JO.ts
i18n/pvs_de_DE.ts
i18n/pvs_es_MX.ts
i18n/pvs_fr_FR.ts
i18n/pvs_pl_PL.ts
i18n/pvsmgr_ar_JO.ts
i18n/pvsmgr_de_DE.ts
i18n/pvsmgr_es_MX.ts
i18n/pvsmgr_fr_FR.ts
i18n/pvsmgr_pl_PL.ts
icons/README
pvsmgr.qrc
src/gui/mainWindow.cpp
src/pvs.cpp
src/pvs.h
src/pvsDaemon.cpp
src/util/clientGUIUtils.h
Diffstat (limited to 'src/util/pvsSettingsManager.cpp')
| -rw-r--r-- | src/util/pvsSettingsManager.cpp | 185 |
1 files changed, 0 insertions, 185 deletions
diff --git a/src/util/pvsSettingsManager.cpp b/src/util/pvsSettingsManager.cpp deleted file mode 100644 index a6a742b..0000000 --- a/src/util/pvsSettingsManager.cpp +++ /dev/null @@ -1,185 +0,0 @@ -#include "pvsSettingsManager.h" -#include "TextFile.h" - -PVSSettingsManager* PVSSettingsManager::getManager() -{ - if (myself) - return myself; - else - return myself = new PVSSettingsManager; -} - -void PVSSettingsManager::setConfigFile(QString path) -{ - if (path.size() && fileExists(path)) - { - _path = path; - _parseFile(_path); - - } - else - ConsoleLog writeError(QString("Can't open config file \"").append(QString(path).append("\""))); -} - -bool PVSSettingsManager::hasEntry(QString name) -{ - for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) - { - if ((*it).first.compare(name) == 0) - { - return true; - } - } - return false; -} - -QString PVSSettingsManager::getEntryString(QString name) -{ - for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) - { - if ((*it).first.compare(name) == 0) - { - return (*it).second; - } - } - return QString(); -} - -void PVSSettingsManager::writeEntry(QString name, QString value) -{ - if (name.size() && value.size()) - return; - bool unique = true; - for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) - { - if ((*it).first.compare(name) == 0) - { - unique = false; - (*it).second = value; - break; - } - } - if (unique) - { - SettingsEntry tmp(name, value); - settingsList.push_back(tmp); - } -} - - -PVSSettingsManager* PVSSettingsManager::myself = NULL; - -PVSSettingsManager::PVSSettingsManager() -{ - -} - -void PVSSettingsManager::setConfigs() -{ - //default settings - _configs.setValue("Chat/chatstate", "on"); - _configs.setValue("Chat/chatmode", "bossmode"); - _configs.setValue("Room/roomId", "0"); - _configs.setValue("VNC/permit", "off"); - _configs.setValue("VNC/quality", "high"); - _configs.sync(); -} -void PVSSettingsManager::reWriteConfigs(QString set, QString val) -{ - _configs.setValue(set, val); - _configs.sync(); -} - -void PVSSettingsManager::readConfigs(QString sett, QString vall) -{ - //TODO: read the config file.. - _configs.value("Chat/chatstate").toBool(); - _configs.value("Chat/chatmode").toString(); - _configs.value("Room/room").toInt(); - _configs.value("VNC/permit").toBool(); - _configs.value("VNC/quality").toString(); -} - -void PVSSettingsManager::_parseFile(QString path) -{ - QString line; - TextFile file(path); - - SettingsList tmpList; - - if (file.good()) - { - while (!file.eof()) - { - line = file.readLine(); - if (!(line.length() <=1)) // ignore blank - { - if (!(line[0] == '#' || line[0] == '/' || line[0] == '[')) // ignore comments and section headers - { - SettingsEntry tmp = _parseLine(line); - if (tmp.first.size() && tmp.second.size()) - { - bool unique = true; - for (SettingsIter it = tmpList.begin(); it != tmpList.end(); it++) - { - if ((*it).first.compare(tmp.first) == 0) - { - unique = false; - break; - } - } - if (unique) - tmpList.push_back(tmp); - } - } - } - } - } - else - { - ConsoleLog writeError(QString("No configfile \"").append(QString(path).append("\" found or file corrupt."))); - } - - if (tmpList.size()) - settingsList = tmpList; -} -#ifdef verbose -ConsoleLog writeLine(QString("Dumping Config Content of ").append(QString(path).append(" : "))); -for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) -{ - ConsoleLog writeLine(QString("Option: ").append(QString((*it).first).append(QString(" | Value: ").append((*it).second)))); -} -ConsoleLog writeLine(QString("End of ").append(QString(path).append("."))); -#endif - -SettingsEntry PVSSettingsManager::_parseLine(QString line) -{ - QString name; - QString value; - - name = lineSplitter(line, "=\n\t", true); - value = lineSplitter(line, "=\n\t", false); - - if (!(name.size() && value.size())) - return SettingsEntry("",""); - - - // remove whitespaces in front of option name - for (int i = 0; i < name.size(); i++) - { - if (name[i] == '\t' || name[i] == ' ') - { - name.remove(i, 1); - i--; - } - else - break; - } - // whitespaces after the value are trimmed by the lineSplitter - - SettingsEntry tmp(name, value); - return tmp; -} - - - |
