Improve function interface

`SettingsStorage` methods require `QString` so make `SettingValue` follow it.
`Path::operator+` can use `QStringView` to accept wider audience.
This commit is contained in:
Chocobo1
2022-03-23 23:56:47 +08:00
parent 11cfe38d1c
commit c6b772da11
33 changed files with 222 additions and 239 deletions

View File

@@ -38,8 +38,8 @@ template <typename T>
class SettingValue
{
public:
explicit SettingValue(const char *keyName)
: m_keyName {QString::fromLatin1(keyName)}
explicit SettingValue(const QString &keyName)
: m_keyName {keyName}
{
}
@@ -67,7 +67,7 @@ template <typename T>
class CachedSettingValue
{
public:
explicit CachedSettingValue(const char *keyName, const T &defaultValue = {})
explicit CachedSettingValue(const QString &keyName, const T &defaultValue = {})
: m_setting {keyName}
, m_cache {m_setting.get(defaultValue)}
{
@@ -76,7 +76,7 @@ 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, ProxyFunc &&proxyFunc)
explicit CachedSettingValue(const QString &keyName, const T &defaultValue, ProxyFunc &&proxyFunc)
: m_setting {keyName}
, m_cache {proxyFunc(m_setting.get(defaultValue))}
{