refs #694 Support human readable names for settings and data cache traits.

This commit is contained in:
Mathew Sutcliffe
2016-07-28 22:26:47 +01:00
parent 61f3655b2c
commit 87b2396edb
5 changed files with 47 additions and 8 deletions

View File

@@ -79,7 +79,7 @@ namespace BlackMisc
//! Must be a void, non-const member function of the owner.
template <typename T>
CSetting(T *owner, NotifySlot<T> slot = nullptr) :
CSetting::CCached(CSettingsCache::instance(), Trait::key(), Trait::isValid, Trait::defaultValue(), owner, slot)
CSetting::CCached(CSettingsCache::instance(), Trait::key(), Trait::humanReadable(), Trait::isValid, Trait::defaultValue(), owner, slot)
{}
//! Reset the setting to its default value.
@@ -123,6 +123,9 @@ namespace BlackMisc
//! Key string of the value. Reimplemented in derived class.
static const char *key() { qFatal("Not implemented"); return ""; }
//! Optional human readable name.
static const QString &humanReadable() { static const QString name; return name; }
//! Validator function. Return true if the argument is valid, false otherwise. Default
//! implementation just returns true. Reimplemented in derived class to support validation of the value.
static bool isValid(const T &) { return true; }