• NymeaSettings
  • NymeaSettings Class

    The settings class for nymea. More...

    Header: #include <NymeaSettings>
    Inherits:

    Public Types

    enum SettingsRole { SettingsRoleNone, SettingsRoleDevices, SettingsRoleRules, SettingsRolePlugins, ..., SettingsRoleTags }

    Public Functions

    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

    Static Public Members

    bool isRoot()
    QString settingsPath()
    QString storagePath()
    QString translationsPath()

    Detailed Description

    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.

    Member Type Documentation

    enum NymeaSettings::SettingsRole

    Represents the role for the NymeaSettings. Each role creates its own settings file.

    ConstantValueDescription
    NymeaSettings::SettingsRoleNone0No role will be used. This sould not be used!
    NymeaSettings::SettingsRoleDevices1This role will create the devices.conf file and is used to store the configured Devices.
    NymeaSettings::SettingsRoleRules2This role will create the rules.conf file and is used to store the configured Rules.
    NymeaSettings::SettingsRolePlugins3This role will create the plugins.conf file and is used to store the Plugin configurations.
    NymeaSettings::SettingsRoleGlobal4This 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::SettingsRoleDeviceStates5This role will create the device-states.conf file and is used to store the configured Device States.
    NymeaSettings::SettingsRoleTags6This role will create the tags.conf file and is used to store the Tags.

    Member Function Documentation

    NymeaSettings::NymeaSettings(const SettingsRole & role = SettingsRoleNone, QObject * parent = nullptr)

    Constructs a NymeaSettings instance with the given role and parent.

    NymeaSettings::~NymeaSettings()

    Destructor of the NymeaSettings.

    QStringList NymeaSettings::allKeys() const

    Return a list of all settings keys.

    void NymeaSettings::beginGroup(const QString & prefix)

    Begins a new group with the given prefix.

    int NymeaSettings::beginReadArray(const QString & prefix)

    Adds prefix to the current group and starts reading from an array. Returns the size of the array.

    void NymeaSettings::beginWriteArray(const QString & prefix)

    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.

    QStringList NymeaSettings::childGroups() const

    Returns a list of all key top-level groups that contain keys that can be read using the NymeaSettings object.

    QStringList NymeaSettings::childKeys() const

    Returns a list of all top-level keys that can be read using the NymeaSettings object.

    void NymeaSettings::clear()

    Removes all entries in the primary location associated to this NymeaSettings object.

    bool NymeaSettings::contains(const QString & key) const

    Returns true if there exists a setting called key; returns false otherwise.

    void NymeaSettings::endArray()

    End an array.

    void NymeaSettings::endGroup()

    Resets the group to what it was before the corresponding beginGroup() call.

    QString NymeaSettings::fileName() const

    Returns the path where settings written using this NymeaSettings object are stored.

    QString NymeaSettings::group() const

    Returns the current group.

    [static] bool NymeaSettings::isRoot()

    Returns true if nymead is started as root.

    bool NymeaSettings::isWritable() const

    Returns true if settings can be written using this NymeaSettings object; returns false otherwise.

    void NymeaSettings::remove(const QString & key)

    Removes the setting key and any sub-settings of key.

    void NymeaSettings::setArrayIndex(int i)

    Sets the current array index to i.

    void NymeaSettings::setValue(const QString & key, const QVariant & value)

    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.

    SettingsRole NymeaSettings::settingsRole() const

    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.

    QVariant NymeaSettings::value(const QString & key, const QVariant & defaultValue = QVariant()) const

    Returns the value for setting key. If the setting doesn't exist, returns defaultValue.

    See also setValue().