|
|
@ -29,7 +29,6 @@ |
|
|
|
#ifndef SETTINGVALUE_H |
|
|
|
#ifndef SETTINGVALUE_H |
|
|
|
#define SETTINGVALUE_H |
|
|
|
#define SETTINGVALUE_H |
|
|
|
|
|
|
|
|
|
|
|
#include <functional> |
|
|
|
|
|
|
|
#include <type_traits> |
|
|
|
#include <type_traits> |
|
|
|
|
|
|
|
|
|
|
|
#include <QMetaEnum> |
|
|
|
#include <QMetaEnum> |
|
|
@ -41,8 +40,6 @@ |
|
|
|
template <typename T> |
|
|
|
template <typename T> |
|
|
|
class CachedSettingValue |
|
|
|
class CachedSettingValue |
|
|
|
{ |
|
|
|
{ |
|
|
|
using ProxyFunc = std::function<T (const T&)>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue = T()) |
|
|
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue = T()) |
|
|
|
: m_keyName(QLatin1String(keyName)) |
|
|
|
: m_keyName(QLatin1String(keyName)) |
|
|
@ -50,8 +47,11 @@ public: |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The signature of the ProxyFunc should be equivalent to the following:
|
|
|
|
|
|
|
|
// T proxyFunc(const T &a);
|
|
|
|
|
|
|
|
template <typename ProxyFunc> |
|
|
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue |
|
|
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue |
|
|
|
, const ProxyFunc &proxyFunc) |
|
|
|
, ProxyFunc proxyFunc) |
|
|
|
: m_keyName(QLatin1String(keyName)) |
|
|
|
: m_keyName(QLatin1String(keyName)) |
|
|
|
, m_value(proxyFunc(loadValue(defaultValue))) |
|
|
|
, m_value(proxyFunc(loadValue(defaultValue))) |
|
|
|
{ |
|
|
|
{ |
|
|
|