|
AlbumShaper
1.0a3
|
SettingGroup contains settings which are releated. More...
#include <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 | |
SettingGroup contains settings which are releated.
Definition at line 25 of file settinggroup.h.
| SettingGroup::SettingGroup | ( | QString | name | ) |
Creates configuration variables using default avlues.
Definition at line 21 of file settinggroup.cpp.
References firstSetting, lastSetting, name, and next.
{
this->name = name;
firstSetting = NULL;
lastSetting = NULL;
next = NULL;
}
| SettingGroup::~SettingGroup | ( | ) |
Destructor.
Definition at line 29 of file settinggroup.cpp.
References firstSetting, and Setting::getNext().
{
Setting* cur = firstSetting;
while(cur != NULL)
{
Setting* t = cur->getNext();
delete cur;
cur = t;
}
}
| QString SettingGroup::getName | ( | ) |
Returns group's name.
Definition at line 40 of file settinggroup.cpp.
References name.
Referenced by Configuration::getString(), Configuration::loadSettings(), Configuration::removeGroup(), Configuration::resetSetting(), saveSettings(), and Configuration::setString().
{
return name;
}
| SettingGroup * SettingGroup::getNext | ( | ) |
returns the next groupsetting
Definition at line 94 of file settinggroup.cpp.
References next.
Referenced by Configuration::getString(), Configuration::loadSettings(), Configuration::removeGroup(), Configuration::resetSetting(), Configuration::saveSettings(), Configuration::setString(), and Configuration::~Configuration().
{
return next;
}
| QString SettingGroup::getValue | ( | QString | key | ) |
Returns a setting value.
Definition at line 45 of file settinggroup.cpp.
References firstSetting, Setting::getKey(), Setting::getNext(), and Setting::getValue().
Referenced by Configuration::getString().
{
Setting* cur = firstSetting;
while(cur != NULL)
{
if(cur->getKey().compare(key) == 0)
{
return cur->getValue();
}
cur = cur->getNext();
}
return "-1";
}
| void SettingGroup::loadSettings | ( | QDomNode & | node | ) |
Definition at line 119 of file settinggroup.cpp.
References setValue().
Referenced by Configuration::loadSettings().
{
//iterate over all children (Settings)
QDomNode node = root.firstChild();
QDomText val;
while( !node.isNull() )
{
if( node.isElement() && node.nodeName() == "setting" )
{
//find key and value, if either is missing move on to next setting
QDomNamedNodeMap attributes = node.attributes();
if(attributes.namedItem("key").isNull() || attributes.namedItem("value").isNull())
{
node = node.nextSibling();
continue;
}
QString k = attributes.namedItem("key").nodeValue();
QString v = attributes.namedItem("value").nodeValue();
//key and value found -> add new setting
setValue( attributes.namedItem("key").nodeValue(),
attributes.namedItem("value").nodeValue() );
}
//move on to next setting
node = node.nextSibling();
}
}
| void SettingGroup::resetSetting | ( | QString | key | ) |
resets a setting to its default value
Definition at line 59 of file settinggroup.cpp.
References firstSetting, Setting::getKey(), Setting::getNext(), and Setting::resetSetting().
Referenced by Configuration::resetSetting().
{
Setting* cur = firstSetting;
while(cur != NULL)
{
if(cur->getKey().compare(key) == 0)
{
cur->resetSetting();
}
cur = cur->getNext();
}
}
| void SettingGroup::saveSettings | ( | QTextStream & | stream | ) |
writes out this group to file
Definition at line 104 of file settinggroup.cpp.
References firstSetting, Setting::getKey(), getName(), Setting::getNext(), and Setting::getValue().
Referenced by Configuration::saveSettings().
| void SettingGroup::setNext | ( | SettingGroup * | next | ) |
sets the next group setting
Definition at line 99 of file settinggroup.cpp.
References next.
Referenced by Configuration::loadSettings(), Configuration::removeGroup(), and Configuration::setString().
{
this->next = next;
}
| void SettingGroup::setValue | ( | QString | key, |
| QString | value | ||
| ) |
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().
{
Setting* cur = firstSetting;
while(cur != NULL)
{
if(cur->getKey().compare(key) == 0)
{
cur->setValue(value);
return;
}
cur = cur->getNext();
}
//setting not found, create new one and append to list
cur = new Setting(key, value);
if(firstSetting == NULL)
firstSetting = cur;
else
lastSetting->setNext(cur);
lastSetting = cur;
}
Setting* SettingGroup::firstSetting [private] |
pointer to first setting in group
Definition at line 64 of file settinggroup.h.
Referenced by getValue(), resetSetting(), saveSettings(), SettingGroup(), setValue(), and ~SettingGroup().
Setting* SettingGroup::lastSetting [private] |
pointer to last setting in group
Definition at line 67 of file settinggroup.h.
Referenced by SettingGroup(), and setValue().
QString SettingGroup::name [private] |
groups identifying name
Definition at line 61 of file settinggroup.h.
Referenced by getName(), and SettingGroup().
SettingGroup* SettingGroup::next [private] |
pointer to next settingroup
Definition at line 70 of file settinggroup.h.
Referenced by getNext(), setNext(), and SettingGroup().
1.7.5.1