#include <settinggroup.h>
Collaboration diagram for SettingGroup:

Definition at line 25 of file settinggroup.h.
Public Member Functions | |
| SettingGroup (QString name) | |
| Creates configuration variables using default avlues. | |
| ~SettingGroup () | |
| Destructor. | |
| QString | getName () |
| Returns group's name. | |
| QString | getValue (QString key) |
| Returns a setting value. | |
| void | setValue (QString key, QString value) |
| Sets a setting value, create new setting if setting not found. | |
| SettingGroup * | getNext () |
| returns the next groupsetting | |
| void | setNext (SettingGroup *next) |
| sets the next group setting | |
| void | loadSettings (QDomNode &node) |
| void | saveSettings (QTextStream &stream) |
| writes out this group to file | |
| void | resetSetting (QString key) |
| resets a setting to its default value | |
Private Attributes | |
| QString | name |
| groups identifying name | |
| Setting * | firstSetting |
| pointer to first setting in group | |
| Setting * | lastSetting |
| pointer to last setting in group | |
| SettingGroup * | next |
| pointer to next settingroup | |
|
|
Creates configuration variables using default avlues.
Definition at line 21 of file settinggroup.cpp. References firstSetting, lastSetting, and next. 00022 {
00023 this->name = name;
00024 firstSetting = NULL;
00025 lastSetting = NULL;
00026 next = NULL;
00027 }
|
|
|
Destructor.
Definition at line 29 of file settinggroup.cpp. References Setting::getNext(). 00030 {
00031 Setting* cur = firstSetting;
00032 while(cur != NULL)
00033 {
00034 Setting* t = cur->getNext();
00035 delete cur;
00036 cur = t;
00037 }
00038 }
|
|
|
Returns group's name.
Definition at line 40 of file settinggroup.cpp. Referenced by Configuration::getString(), Configuration::loadSettings(), Configuration::removeGroup(), Configuration::resetSetting(), saveSettings(), and Configuration::setString(). 00041 {
00042 return name;
00043 }
|
|
|
returns the next groupsetting
Definition at line 94 of file settinggroup.cpp. Referenced by Configuration::getString(), Configuration::loadSettings(), Configuration::removeGroup(), Configuration::resetSetting(), Configuration::saveSettings(), Configuration::setString(), and Configuration::~Configuration(). 00095 {
00096 return next;
00097 }
|
|
|
Returns a setting value.
Definition at line 45 of file settinggroup.cpp. References Setting::getKey(), Setting::getNext(), and Setting::getValue(). Referenced by Configuration::getString(). 00046 {
00047 Setting* cur = firstSetting;
00048 while(cur != NULL)
00049 {
00050 if(cur->getKey().compare(key) == 0)
00051 {
00052 return cur->getValue();
00053 }
00054 cur = cur->getNext();
00055 }
00056 return "-1";
00057 }
|
|
|
Definition at line 119 of file settinggroup.cpp. References setValue(). Referenced by Configuration::loadSettings(). 00120 {
00121 //iterate over all children (Settings)
00122 QDomNode node = root.firstChild();
00123 QDomText val;
00124 while( !node.isNull() )
00125 {
00126 if( node.isElement() && node.nodeName() == "setting" )
00127 {
00128 //find key and value, if either is missing move on to next setting
00129 QDomNamedNodeMap attributes = node.attributes();
00130 if(attributes.namedItem("key").isNull() || attributes.namedItem("value").isNull())
00131 {
00132 node = node.nextSibling();
00133 continue;
00134 }
00135
00136
00137 QString k = attributes.namedItem("key").nodeValue();
00138 QString v = attributes.namedItem("value").nodeValue();
00139
00140 //key and value found -> add new setting
00141 setValue( attributes.namedItem("key").nodeValue(),
00142 attributes.namedItem("value").nodeValue() );
00143 }
00144
00145 //move on to next setting
00146 node = node.nextSibling();
00147 }
00148 }
|
|
|
resets a setting to its default value
Definition at line 59 of file settinggroup.cpp. References Setting::getKey(), Setting::getNext(), and Setting::resetSetting(). Referenced by Configuration::resetSetting(). 00060 {
00061 Setting* cur = firstSetting;
00062 while(cur != NULL)
00063 {
00064 if(cur->getKey().compare(key) == 0)
00065 {
00066 cur->resetSetting();
00067 }
00068 cur = cur->getNext();
00069 }
00070 }
|
|
|
writes out this group to file
Definition at line 104 of file settinggroup.cpp. References Setting::getKey(), getName(), Setting::getNext(), and Setting::getValue(). Referenced by Configuration::saveSettings(). 00105 {
00106 stream << " <group name=\"" << getName() << "\">\n";
00107
00108 //iterate over every setting
00109 Setting* cur = firstSetting;
00110 while(cur != NULL)
00111 {
00112 stream << " <setting key=\"" << cur->getKey() << "\" value=\"" << cur->getValue() << "\"/>\n";
00113 cur = cur->getNext();
00114 }
00115
00116 stream << " </group>\n";
00117 }
|
|
|
sets the next group setting
Definition at line 99 of file settinggroup.cpp. Referenced by Configuration::loadSettings(), Configuration::removeGroup(), and Configuration::setString(). 00100 {
00101 this->next = next;
00102 }
|
|
||||||||||||
|
Sets a setting value, create new setting if setting not found.
Definition at line 72 of file settinggroup.cpp. References firstSetting, Setting::getKey(), Setting::getNext(), lastSetting, Setting::setNext(), and Setting::setValue(). Referenced by loadSettings(), and Configuration::setString(). 00073 {
00074 Setting* cur = firstSetting;
00075 while(cur != NULL)
00076 {
00077 if(cur->getKey().compare(key) == 0)
00078 {
00079 cur->setValue(value);
00080 return;
00081 }
00082 cur = cur->getNext();
00083 }
00084
00085 //setting not found, create new one and append to list
00086 cur = new Setting(key, value);
00087 if(firstSetting == NULL)
00088 firstSetting = cur;
00089 else
00090 lastSetting->setNext(cur);
00091 lastSetting = cur;
00092 }
|
|
|
pointer to first setting in group
Definition at line 64 of file settinggroup.h. Referenced by SettingGroup(), and setValue(). |
|
|
pointer to last setting in group
Definition at line 67 of file settinggroup.h. Referenced by SettingGroup(), and setValue(). |
|
|
groups identifying name
Definition at line 61 of file settinggroup.h. |
|
|
pointer to next settingroup
Definition at line 70 of file settinggroup.h. Referenced by SettingGroup(). |
1.3.9.1