#include <uasettings.h>
Public Types | |
enum | Scope { UserScope = 0, SystemScope = 1 } |
Scope enumeration. More... | |
Public Member Functions | |
UaSettings (const UaUniString &sOrganization, const UaUniString &sApplication, Scope scope=UserScope) | |
~UaSettings () | |
UaUniString | organizationName () const |
UaUniString | applicationName () const |
Scope | scope () const |
void | beginGroup (const UaUniString &sGroup) |
void | removeKey (const UaUniString &sKey) |
void | setValue (const UaUniString &sKey, const UaVariant &value) |
UaUniString | endGroup () |
UaUniString | group () |
UaUniStringList | childGroups () const |
UaUniStringList | childKeys () const |
UaVariant | value (const UaUniString &sKey, const UaVariant &defaultValue) |
enum UaSettings::Scope |
UaSettings::UaSettings | ( | const UaUniString & | sOrganization, | |
const UaUniString & | sApplication, | |||
Scope | scope = UserScope | |||
) |
construction Get the needed variables to create the path to the ini file.
sOrganization | the name of the organisation. | |
sApplication | the name of the application. | |
scope | the scope of the user or of the system. |
UaSettings::~UaSettings | ( | ) |
destruction calls the private method writeIniFile() to write all values out of the map into the ini file.
UaUniString UaSettings::organizationName | ( | ) | const [inline] |
Get the name of the organisation.
UaUniString UaSettings::applicationName | ( | ) | const [inline] |
Get the name of the application.
Scope UaSettings::scope | ( | ) | const [inline] |
Get the actual used scope.
void UaSettings::beginGroup | ( | const UaUniString & | sGroup | ) |
Appends a prefix to the current group. The current group is automatically prepended to all keys specified to UaSettings. Groups are useful to avoid typing in the same setting paths over and over. For example:
settings.beginGroup("Test"); settings.setValue("size", 10); settings.setValue("size2", FullScreen()); settings.endGroup(); settings.beginGroup("Test2"); settings.setValue("visible", Visible()); settings.endGroup();
sGroup | the group you want to have. |
void UaSettings::removeKey | ( | const UaUniString & | sKey | ) |
Removes the setting sKey.
sKey | the key to remove from the ini file.. |
void UaSettings::setValue | ( | const UaUniString & | sKey, | |
const UaVariant & | value | |||
) |
Sets the value of setting sKey to value. If the key already exists, the previous value is overwritten. For example:
UaSettings settings; settings.setValue("interval", 30); settings.value("interval").toInt(); // returns 30 settings.setValue("interval", 6.55); settings.value("interval").toDouble(); // returns 6.55
sKey | the key you want to write into the ini file. | |
value | the value for the key to write into the íni file. |
UaUniString UaSettings::endGroup | ( | ) |
Resets the group to what it was before the corresponding beginGroup() call. For example:
settings.beginGroup("alpha"); settings.beginGroup("beta"); UaUniString ret = settings.endGroup(); // ret = beta ret = settings.endGroup(); // ret = alpha
UaUniString UaSettings::group | ( | ) |
UaUniStringList UaSettings::childGroups | ( | ) | const |
Returns a list of all key top-level groups that contain keys that can be read using the UaSettings object.
sPath | Path to the ini file. |
UaUniStringList UaSettings::childKeys | ( | ) | const |
Returns a list of all top-level keys that can be read using the UaSettings object.
sPath | Path to the ini file. | |
sGroup | the group to read out of the file. |
UaVariant UaSettings::value | ( | const UaUniString & | sKey, | |
const UaVariant & | defaultValue | |||
) |
Returns the value for setting sKey. If the setting doesn't exist, returns defaultValue. If no default value is specified, a default UaVariant is returned. For example:
UaSettings settings; settings.setValue("animal/snake", 58); settings.value("animal/snake", 1024).toInt(); // returns 58 settings.value("animal/zebra", 1024).toInt(); // returns 1024 settings.value("animal/zebra").toInt(); // returns 0
sKey | the key you want to read out of the ini file. | |
defaultValue | the value for the key to read out the íni file. |