mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-04-29 03:04:40 +00:00
added cahce tot settings class
This commit is contained in:
parent
165e61a86d
commit
d7e11e644c
@ -30,7 +30,12 @@ ISettings *ISettings::instance(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariant ISettings::getValue(const QString &key, const QVariant &def) {
|
QVariant ISettings::getValue(const QString &key, const QVariant &def) {
|
||||||
return getValueImplementation(key, def);
|
|
||||||
|
if (!_cache.contains(key)) {
|
||||||
|
_cache[key] = getValueImplementation(key, def);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _cache.value(key, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ISettings::getStrValue(const QString &key, const QString &def) {
|
QString ISettings::getStrValue(const QString &key, const QString &def) {
|
||||||
@ -38,11 +43,16 @@ QString ISettings::getStrValue(const QString &key, const QString &def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ISettings::sync() {
|
void ISettings::sync() {
|
||||||
|
for (auto it = _cache.begin(); it != _cache.end(); ++it) {
|
||||||
|
setValueImplementation(it.key(), it.value());
|
||||||
|
}
|
||||||
|
|
||||||
return syncImplementation();
|
return syncImplementation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISettings::setValue(const QString key, const QVariant &value) {
|
void ISettings::setValue(const QString key, const QVariant &value) {
|
||||||
return setValueImplementation(key, value);
|
|
||||||
|
_cache[key] = value;
|
||||||
|
|
||||||
emit valueChanged(key, value);
|
emit valueChanged(key, value);
|
||||||
emit valueStrChanged(key, value.toString());
|
emit valueStrChanged(key, value.toString());
|
||||||
|
@ -153,6 +153,9 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsSaveMode _mode = SettingsSaveMode::Auto;
|
SettingsSaveMode _mode = SettingsSaveMode::Auto;
|
||||||
|
|
||||||
|
QHash<QString, QVariant> _cache;
|
||||||
|
|
||||||
static ISettings* _settings;
|
static ISettings* _settings;
|
||||||
};
|
};
|
||||||
} ;
|
} ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user