QuasarAppLib
QuasarAppUtils::ISettings Class Referenceabstract

The Settings class base interface for implementation settings backends. Available implementations: Setting (based on QSettings backend) More...

#include <isettings.h>

Inheritance diagram for QuasarAppUtils::ISettings:
Inheritance graph
Collaboration diagram for QuasarAppUtils::ISettings:
Collaboration graph

Public Slots

void setValue (const QString &key, const QVariant &value)
 setValue This slot sets new value for a key setting
 
void setStrValue (const QString &key, const QString &value)
 setStrValue This is some as setValue but working with the QString type.
 

Signals

void valueChanged (QString key, QVariant value)
 valueChanged This signal when value of the key settings changed
 
void valueStrChanged (QString key, QString value)
 valueStrChanged some as valueChanged(QString key, QVariant value) but value has ben converted to the QString type.
 

Public Member Functions

 ~ISettings () override
 
Q_INVOKABLE QVariant getValue (const QString &key, const QVariant &def={})
 getValue This method return the value of the settings.
 
Q_INVOKABLE QString getStrValue (const QString &key, const QString &def={})
 getStrValue some as getValue but convert result object to QString type.
 
Q_INVOKABLE void resetToDefault ()
 resetToDefault This method reset all settings to default values.
 
virtual bool ignoreToRest (const QString &key) const
 ignoreToRest This method should be returns true if the key setting is not be reset on the resetToDefault method.
 
void sync ()
 sync This method save all setings data on a hard disk;
 
void forceReloadCache ()
 forceReloadCache This method force reload settings data from disk.
 
SettingsSaveMode getMode () const
 getMode This method return the current mode of the settings.
 
void setMode (const SettingsSaveMode &mode)
 setMode This method sets a new value of the settings mode.
 
- Public Member Functions inherited from QuasarAppUtils::Service< ISettings >
 Service ()
 

Static Public Member Functions

static ISettingsinstance ()
 instance This method returns pointer to current settings object.
 
static bool initService (std::unique_ptr< ISettings > obj)
 initService This method initialize the global settings object.
 
- Static Public Member Functions inherited from QuasarAppUtils::Service< ISettings >
static std::unique_ptr< ISettings > & initService ()
 initService This method initialize the Base object as a service.
 
static bool initService (std::unique_ptr< ISettings > obj)
 initService This is overrided static method of initialization cross libraryes object.
 
static ISettingsinstance ()
 instance This method return pointerer to current service object.
 
static ISettingsautoInstance ()
 autoInstance This method return pointerer to current service object and if it is not inited try to initialize it use default constructor.
 
static void deinitService ()
 deinitService This is distructor method for the service.
 

Protected Member Functions

 ISettings (SettingsSaveMode mode=SettingsSaveMode::Auto)
 
virtual QHash< QString, QVariantdefaultSettings ()=0
 
virtual void syncImplementation ()=0
 syncImplementation This method should save all configuration data to the hard drive;
 
virtual QVariant getValueImplementation (const QString &key, const QVariant &def)=0
 getValueImplementation This method will return the value of the settings.
 
virtual void setValueImplementation (const QString key, const QVariant &value)=0
 setValueImplementation This slot will set a new value for the key parameter.
 
void clearCache ()
 clearCache This method clear all data from cache.
 
QHash< QString, QVariant > & settingsMap ()
 settingsMap This method returns initialized settings map. Settings map contains pairs with settings key and default value.
 

Friends

class Service< ISettings >
 

Detailed Description

The Settings class base interface for implementation settings backends. Available implementations: Setting (based on QSettings backend)

Note
This is singleton object.
The all child classes should be initialized before used.
auto settingsInstance = Setting::initService<Setting>();
void gen(int size, QByteArray &result)
See also
ISettings::init method.

Definition at line 45 of file isettings.h.

Constructor & Destructor Documentation

◆ ~ISettings()

QuasarAppUtils::ISettings::~ISettings ( )
override

Definition at line 19 of file isettings.cpp.

◆ ISettings()

QuasarAppUtils::ISettings::ISettings ( SettingsSaveMode  mode = SettingsSaveMode::Auto)
explicitprotected

Definition at line 15 of file isettings.cpp.

Member Function Documentation

◆ clearCache()

void QuasarAppUtils::ISettings::clearCache ( )
protected

clearCache This method clear all data from cache.

Definition at line 24 of file isettings.cpp.

◆ defaultSettings()

virtual QHash< QString, QVariant > QuasarAppUtils::ISettings::defaultSettings ( )
protectedpure virtual

Implemented in QuasarAppUtils::Settings.

Here is the caller graph for this function:

◆ forceReloadCache()

void QuasarAppUtils::ISettings::forceReloadCache ( )

forceReloadCache This method force reload settings data from disk.

Note
Cache will be refreshed

Definition at line 97 of file isettings.cpp.

Here is the call graph for this function:

◆ getMode()

SettingsSaveMode QuasarAppUtils::ISettings::getMode ( ) const

getMode This method return the current mode of the settings.

Returns
the current mode of the settings.

Definition at line 35 of file isettings.cpp.

◆ getStrValue()

QString QuasarAppUtils::ISettings::getStrValue ( const QString key,
const QString def = {} 
)

getStrValue some as getValue but convert result object to QString type.

Parameters
keyThis is name of the required settings value.
defThis is default value if a value is not finded. If this params will be skipped, then The Settngs model try find default value in the defaultSettings map.
Returns
value of a key
See also
ISettings::defaultSettings
Warning
If you set a def arguments to empty string then this method will return default value from the defaultSettings map.

Definition at line 67 of file isettings.cpp.

Here is the call graph for this function:

◆ getValue()

QVariant QuasarAppUtils::ISettings::getValue ( const QString key,
const QVariant def = {} 
)

getValue This method return the value of the settings.

Parameters
keyThis is name of the required settings value.
defThis is default value if a value is not finded. If this params will be skipped, then The Settngs model try find default value in the defaultSettings map.
Returns
value of a key
See also
ISettings::defaultSettings

Definition at line 51 of file isettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getValueImplementation()

virtual QVariant QuasarAppUtils::ISettings::getValueImplementation ( const QString key,
const QVariant def 
)
protectedpure virtual

getValueImplementation This method will return the value of the settings.

Parameters
keyThis is name of the required settings value.
defThis is default value if a value is not finded.
Returns
value of a key

Implemented in QuasarAppUtils::Settings.

Here is the caller graph for this function:

◆ ignoreToRest()

bool QuasarAppUtils::ISettings::ignoreToRest ( const QString key) const
virtual

ignoreToRest This method should be returns true if the key setting is not be reset on the resetToDefault method.

Parameters
keyThis is keuy value.
Returns
true if the key option can't be reset to default. The default implementaion alwayes return false.

Reimplemented in QuasarAppUtils::Settings.

Definition at line 85 of file isettings.cpp.

Here is the caller graph for this function:

◆ initService()

bool QuasarAppUtils::ISettings::initService ( std::unique_ptr< ISettings obj)
static

initService This method initialize the global settings object.

Parameters
objThis is prepared settings object. You should create a your object monyaly, and add to initialization
bool result = initService(std::make_unique<MySettings>());
static std::unique_ptr< ISettings > & initService()
initService This method initialize the Base object as a service.
Definition qaservice.h:81
Returns
true if initialization finished successful else false.
See also
Service::initService

Definition at line 47 of file isettings.cpp.

Here is the call graph for this function:

◆ instance()

ISettings * QuasarAppUtils::ISettings::instance ( )
static

instance This method returns pointer to current settings object.

Returns
pointer to current settings object.
See also
Service::instance

Definition at line 43 of file isettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetToDefault()

void QuasarAppUtils::ISettings::resetToDefault ( )

resetToDefault This method reset all settings to default values.

Definition at line 76 of file isettings.cpp.

Here is the call graph for this function:

◆ setMode()

void QuasarAppUtils::ISettings::setMode ( const SettingsSaveMode mode)

setMode This method sets a new value of the settings mode.

Parameters
modeThis is a new value of the settings mode.

Definition at line 39 of file isettings.cpp.

◆ setStrValue

void QuasarAppUtils::ISettings::setStrValue ( const QString key,
const QString value 
)
slot

setStrValue This is some as setValue but working with the QString type.

Parameters
keyThis is name of the changed setting.
valueThis is a new value of the setting

Definition at line 124 of file isettings.cpp.

Here is the call graph for this function:

◆ settingsMap()

QHash< QString, QVariant > & QuasarAppUtils::ISettings::settingsMap ( )
protected

settingsMap This method returns initialized settings map. Settings map contains pairs with settings key and default value.

Returns
initialized settings map.
See also
ISettings::defaultSettings method

Definition at line 28 of file isettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setValue

void QuasarAppUtils::ISettings::setValue ( const QString key,
const QVariant value 
)
slot

setValue This slot sets new value for a key setting

Parameters
keyThis is name of the changed setting.
valueThis is a new value of the setting

Definition at line 105 of file isettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setValueImplementation()

virtual void QuasarAppUtils::ISettings::setValueImplementation ( const QString  key,
const QVariant value 
)
protectedpure virtual

setValueImplementation This slot will set a new value for the key parameter.

Parameters
keyThis is name of the changed setting.
valueThis is a new value of the setting

Implemented in QuasarAppUtils::Settings.

Here is the caller graph for this function:

◆ sync()

void QuasarAppUtils::ISettings::sync ( )

sync This method save all setings data on a hard disk;

Definition at line 89 of file isettings.cpp.

Here is the call graph for this function:

◆ syncImplementation()

virtual void QuasarAppUtils::ISettings::syncImplementation ( )
protectedpure virtual

syncImplementation This method should save all configuration data to the hard drive;

Implemented in QuasarAppUtils::Settings.

Here is the caller graph for this function:

◆ valueChanged

void QuasarAppUtils::ISettings::valueChanged ( QString  key,
QVariant  value 
)
signal

valueChanged This signal when value of the key settings changed

Parameters
keyThis is name of change setting.
valueThis is a new value of key.
Here is the caller graph for this function:

◆ valueStrChanged

void QuasarAppUtils::ISettings::valueStrChanged ( QString  key,
QString  value 
)
signal

valueStrChanged some as valueChanged(QString key, QVariant value) but value has ben converted to the QString type.

Parameters
keyThis is name of change setting.
valueThis is a new value of key.
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ Service< ISettings >

Definition at line 221 of file isettings.h.


The documentation for this class was generated from the following files: