10#include <QCoreApplication>
21 delete _defaultConfig;
32 return *_defaultConfig;
52 debug_assert(key.size(),
"You can't use the empty key value!");
54 if (!_cache.contains(key)) {
56 QVariant defVal = def;
57 if (defVal.isNull()) {
73 return getValue(key, QVariant(def)).toString();
79 for (
auto it = defaultConfig.begin(); it != defaultConfig.end(); ++it) {
81 setValue(it.key(), defaultConfig.value(it.key()));
90 for (
auto it = _cache.begin(); it != _cache.end(); ++it) {
100 for (
auto it = defaultConfig.begin(); it != defaultConfig.end(); ++it) {
107 debug_assert(key.size(),
"You can't use the empty key value!");
109 if (_cache.contains(key) && _cache.value(key) == value) {
The Settings class base interface for implementation settings backends. Available implementations: Se...
virtual bool ignoreToRest(const QString &key) const
ignoreToRest This method should be returns true if the key setting is not be reset on the resetToDefa...
void sync()
sync This method save all setings data on a hard disk;
void valueStrChanged(QString key, QString value)
valueStrChanged some as valueChanged(QString key, QVariant value) but value has ben converted to the ...
QHash< QString, QVariant > & settingsMap()
settingsMap This method returns initialized settings map. Settings map contains pairs with settings k...
static ISettings * instance()
instance This method returns pointer to current settings object.
virtual void syncImplementation()=0
syncImplementation This method should save all configuration data to the hard drive;
void setValue(const QString &key, const QVariant &value)
setValue This slot sets new value for a key setting
void valueChanged(QString key, QVariant value)
valueChanged This signal when value of the key settings changed
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.
Q_INVOKABLE QString getStrValue(const QString &key, const QString &def={})
getStrValue some as getValue but convert result object to QString type.
void clearCache()
clearCache This method clear all data from cache.
ISettings(SettingsSaveMode mode=SettingsSaveMode::Auto)
Q_INVOKABLE void resetToDefault()
resetToDefault This method reset all settings to default values.
void forceReloadCache()
forceReloadCache This method force reload settings data from disk.
void setMode(const SettingsSaveMode &mode)
setMode This method sets a new value of the settings mode.
Q_INVOKABLE QVariant getValue(const QString &key, const QVariant &def={})
getValue This method return the value of the settings.
SettingsSaveMode getMode() const
getMode This method return the current mode of the settings.
virtual QHash< QString, QVariant > defaultSettings()=0
void setStrValue(const QString &key, const QString &value)
setStrValue This is some as setValue but working with the QString type.
static Base * instance()
instance This method return pointerer to current service object.
static std::unique_ptr< ISettings > & initService()
initService This method initialize the Base object as a service.
The QuasaraAppUtils class This lib include base functions for the all applications of QuasarApp group...
SettingsSaveMode
The SettingsSaveMode enum.
@ Auto
a settings will be saved on hard disk when called the Settings::setValue method.
#define debug_assert(C, M)