The settings class for nymea. More...
Header: | #include <NymeaSettings> |
Inherits: |
enum | SettingsRole { SettingsRoleNone, SettingsRoleDevices, SettingsRoleRules, SettingsRolePlugins, ..., SettingsRoleTags } |
NymeaSettings(const SettingsRole & role = SettingsRoleNone, QObject * parent = nullptr) | |
~NymeaSettings() | |
QStringList | allKeys() const |
void | beginGroup(const QString & prefix) |
int | beginReadArray(const QString & prefix) |
void | beginWriteArray(const QString & prefix) |
QStringList | childGroups() const |
QStringList | childKeys() const |
void | clear() |
bool | contains(const QString & key) const |
void | endArray() |
void | endGroup() |
QString | fileName() const |
QString | group() const |
bool | isWritable() const |
void | remove(const QString & key) |
void | setArrayIndex(int i) |
void | setValue(const QString & key, const QVariant & value) |
SettingsRole | settingsRole() const |
QVariant | value(const QString & key, const QVariant & defaultValue = QVariant()) const |
bool | isRoot() |
QString | settingsPath() |
QString | storagePath() |
QString | translationsPath() |
The settings class for nymea.
Depending on how the nymea server was started (which user started nymead), the setting have to be stored in different locations. This class represents a centralized mechanism to store settings of the system. The different settings are represented ba the SettingsRole and can be used everywhere in the project.
Represents the role for the NymeaSettings. Each role creates its own settings file.
Constant | Value | Description |
---|---|---|
NymeaSettings::SettingsRoleNone | 0 | No role will be used. This sould not be used! |
NymeaSettings::SettingsRoleDevices | 1 | This role will create the devices.conf file and is used to store the configured Devices. |
NymeaSettings::SettingsRoleRules | 2 | This role will create the rules.conf file and is used to store the configured Rules. |
NymeaSettings::SettingsRolePlugins | 3 | This role will create the plugins.conf file and is used to store the Plugin configurations. |
NymeaSettings::SettingsRoleGlobal | 4 | This role will create the nymead.conf file and is used to store the global settings of the nymea system. This settings file is read only. |
NymeaSettings::SettingsRoleDeviceStates | 5 | This role will create the device-states.conf file and is used to store the configured Device States. |
NymeaSettings::SettingsRoleTags | 6 | This role will create the tags.conf file and is used to store the Tags. |
Constructs a NymeaSettings instance with the given role and parent.
Destructor of the NymeaSettings.
Return a list of all settings keys.
Begins a new group with the given prefix.
Adds prefix to the current group and starts reading from an array. Returns the size of the array.
Adds prefix to the current group and starts writing an array of size size. If size is -1 (the default), it is automatically determined based on the indexes of the entries written.
Returns a list of all key top-level groups that contain keys that can be read using the NymeaSettings object.
Returns a list of all top-level keys that can be read using the NymeaSettings object.
Removes all entries in the primary location associated to this NymeaSettings object.
Returns true if there exists a setting called key; returns false otherwise.
End an array.
Resets the group to what it was before the corresponding beginGroup() call.
Returns the path where settings written using this NymeaSettings object are stored.
Returns the current group.
[static]
bool NymeaSettings::isRoot()Returns true if nymead is started as root.
Returns true if settings can be written using this NymeaSettings object; returns false otherwise.
Removes the setting key and any sub-settings of key.
Sets the current array index to i.
Sets the value of setting key to value. If the key already exists, the previous value is overwritten.
See also value().
[static]
QString NymeaSettings::settingsPath()Returns the path to the folder where the NymeaSettings will be saved i.e. /etc/nymea
.
Returns the SettingsRole of this NymeaSettings.
[static]
QString NymeaSettings::storagePath()Returns the default system sorage path i.e. /var/lib/nymea
.
[static]
QString NymeaSettings::translationsPath()Returns the default system translation path /usr/share/nymea/translations
.
Returns the value for setting key. If the setting doesn't exist, returns defaultValue.
See also setValue().