Workspace 6.21.5
Public Member Functions | List of all members
SettingContainer Class Reference

#include <Authentication/Common/settingshelper.h>

Inheritance diagram for SettingContainer:
[legend]

Public Member Functions

 SettingContainer (const QString &organisation, const QString &application, QSettings::Scope scope)
 
 SettingContainer (const SettingContainer &)=delete
 
virtual ~SettingContainer ()
 
void add (const bool &defaultValue, const QString &key, const SettingItem< bool > &tag)
 
void add (const int &defaultValue, const QString &key, const SettingItem< int > &tag)
 
void add (const QString &defaultValue, const QString &key, const SettingItem< QString > &tag)
 
void addNested (const QString &key)
 
SettingContainergetNested (const QString &key)
 
QSettings::Scope getScope () const
 
bool getValue (const SettingItem< bool > &tag, QPair< bool, bool > defaultValue=qMakePair(false, false)) const
 
int getValue (const SettingItem< int > &tag, QPair< bool, int > defaultValue=qMakePair(false, 0)) const
 
QString getValue (const SettingItem< QString > &tag, QPair< bool, QString > defaultValue=qMakePair(false, QString())) const
 
void inherit (const SettingItem< bool > &tag)
 
void inherit (const SettingItem< int > &tag)
 
void inherit (const SettingItem< QString > &tag)
 
bool isInherited (const SettingItem< bool > &tag) const
 
bool isInherited (const SettingItem< int > &tag) const
 
bool isInherited (const SettingItem< QString > &tag) const
 
bool isMissing (const SettingItem< bool > &tag) const
 
bool isMissing (const SettingItem< int > &tag) const
 
bool isMissing (const SettingItem< QString > &tag) const
 
bool isWritable ()
 
bool load ()
 
bool load (QSettings &settings)
 
SettingContaineroperator= (const SettingContainer &)=delete
 
bool save () const
 
bool save (QSettings &settings) const
 
void setValue (const SettingItem< bool > &tag, bool value)
 
void setValue (const SettingItem< int > &tag, int value)
 
void setValue (const SettingItem< QString > &tag, QString value)
 

Detailed Description

Manages settings.

Constructor & Destructor Documentation

◆ SettingContainer() [1/2]

SettingContainer ( const QString &  organisation,
const QString &  application,
QSettings::Scope  scope 
)

◆ SettingContainer() [2/2]

SettingContainer ( const SettingContainer )
delete

◆ ~SettingContainer()

~SettingContainer ( )
virtualdefault

Destructor.

Member Function Documentation

◆ add() [1/3]

void add ( const bool &  defaultValue,
const QString &  key,
const SettingItem< bool > &  tag 
)

Add an item of bool type.

◆ add() [2/3]

void add ( const int &  defaultValue,
const QString &  key,
const SettingItem< int > &  tag 
)

Add an item of int type.

◆ add() [3/3]

void add ( const QString &  defaultValue,
const QString &  key,
const SettingItem< QString > &  tag 
)

Add an item of QString type.

◆ addNested()

void addNested ( const QString &  key)

Add an item of nested SettingContainer.

◆ getNested()

SettingContainer & getNested ( const QString &  key)
Parameters
keyName of the nested settings.
Returns
the nested SettingContainer.

Get (or create if not already exist) a nested SettingContainer named by key.

◆ getScope()

QSettings::Scope getScope ( ) const

Saves the settings to the settings store.

Returns
Returns true if the settings were saved successfully.

◆ getValue() [1/3]

bool getValue ( const SettingItem< bool > &  tag,
QPair< bool, bool >  defaultValue = qMakePair(false, false) 
) const
Parameters
tagTag for the SettingsItem added earlier.
defaultValueA pair with its first true will return the default value by its second if the required settings is missing at the current scope. Otherwise, it uses the default values set by the add().
Returns
the value of the settings.

Get bool value by given tag. When missing, use the defaultValue specified.

◆ getValue() [2/3]

int getValue ( const SettingItem< int > &  tag,
QPair< bool, int >  defaultValue = qMakePair(false, 0) 
) const
Parameters
tagTag for the SettingsItem added earlier.
defaultValueA pair with its first true will return the default value by its second if the required settings is missing at the current scope. Otherwise, it uses the default values set by the add().
Returns
the value of the settings.

Get int value by given tag. When missing, use the defaultValue specified.

◆ getValue() [3/3]

QString getValue ( const SettingItem< QString > &  tag,
QPair< bool, QString >  defaultValue = qMakePair(false, QString()) 
) const
Parameters
tagTag for the SettingsItem added earlier.
defaultValueA pair with its first true will return the default value by its second if the required settings is missing at the current scope. Otherwise, it uses the default values set by the add().

Default value when required setting doesn't exist. Used when useDefaultOnParameter is true.

Returns
the value of the settings.

Get QString value by given tag. When missing, use the defaultValue specified.

◆ inherit() [1/3]

void inherit ( const SettingItem< bool > &  tag)
Parameters
tagTag of the settings of interest.

Mark the setting as inherit will remove it from the current user scope. When load it uses Qt's fallback mechanism to get the system scope value.

◆ inherit() [2/3]

void inherit ( const SettingItem< int > &  tag)
Parameters
tagTag of the settings of interest.

Mark the setting as inherit will remove it from the current user scope. When load it uses Qt's fallback mechanism to get the system scope value.

◆ inherit() [3/3]

void inherit ( const SettingItem< QString > &  tag)
Parameters
tagTag of the settings of interest.

Mark the setting as inherit will remove it from the current user scope. When load it uses Qt's fallback mechanism to get the system scope value.

◆ isInherited() [1/3]

bool isInherited ( const SettingItem< bool > &  tag) const
Parameters
tagTag of the settings of interest.
Returns
True if the settings' value is inherited from system scope.

Query if the loaded setting inherited from different scope using Qt's fallback mechanism.

◆ isInherited() [2/3]

bool isInherited ( const SettingItem< int > &  tag) const
Parameters
tagTag of the settings of interest.
Returns
True if the settings' value is inherited from system scope.

Query if the loaded setting inherited from different scope using Qt's fallback mechanism.

◆ isInherited() [3/3]

bool isInherited ( const SettingItem< QString > &  tag) const
Parameters
tagTag of the settings of interest.
Returns
True if the settings' value is inherited from system scope.

Query if the loaded setting inherited from different scope using Qt's fallback mechanism.

◆ isMissing() [1/3]

bool isMissing ( const SettingItem< bool > &  tag) const
Parameters
tagTag of the settings of interest.
Returns
True if the settings' value is missing from the current scope.

Query if the setting is missing from current scope.

◆ isMissing() [2/3]

bool isMissing ( const SettingItem< int > &  tag) const
Parameters
tagTag of the settings of interest.
Returns
True if the settings' value is missing from the current scope.

Query if the setting is missing from current scope.

◆ isMissing() [3/3]

bool isMissing ( const SettingItem< QString > &  tag) const
Parameters
tagTag of the settings of interest.
Returns
True if the settings' value is missing from the current scope.

Query if the setting is missing from current scope.

◆ isWritable()

bool isWritable ( )

Indicates if the authenticated entity can be written or not.

Returns
True if the authenticated entity is writable.

◆ load() [1/2]

bool load ( )

Loads the server settings from the settings area.

Returns
Returns true if the settings were successfully loaded.

◆ load() [2/2]

bool load ( QSettings &  settings)

Loads the server settings from the settings area.

Returns
Returns true if the settings were successfully loaded.

◆ operator=()

SettingContainer & operator= ( const SettingContainer )
delete

◆ save() [1/2]

bool save ( ) const

Saves the settings to the settings store.

Returns
Returns true if the settings were saved successfully.

◆ save() [2/2]

bool save ( QSettings &  settings) const

Saves the settings to the settings store.

Returns
Returns true if the settings were saved successfully.

◆ setValue() [1/3]

void setValue ( const SettingItem< bool > &  tag,
bool  value 
)
Parameters
tagTag for the SettingsItem added earlier.
valueValue to set to the setting specified by tag.

Set bool value on the setting specified by tag.

◆ setValue() [2/3]

void setValue ( const SettingItem< int > &  tag,
int  value 
)
Parameters
tagTag for the SettingsItem added earlier.
valueValue to set to the setting specified by tag.

Set int value on the setting specified by tag.

◆ setValue() [3/3]

void setValue ( const SettingItem< QString > &  tag,
QString  value 
)
Parameters
tagTag for the SettingsItem added earlier.
valueValue to set to the setting specified by tag.

Set QString value on the setting specified by tag.