mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Unify value loading paths
The idea is to try load every intermediate value from the base case and then convert them to their respective type.
This commit is contained in:
parent
261f08b90e
commit
1c52fff1cc
1 changed files with 8 additions and 7 deletions
|
@ -60,17 +60,18 @@ public:
|
||||||
{
|
{
|
||||||
if constexpr (std::is_enum_v<T>)
|
if constexpr (std::is_enum_v<T>)
|
||||||
{
|
{
|
||||||
const auto value = loadValueImpl(key).toString();
|
const auto value = loadValue<QString>(key);
|
||||||
return Utils::String::toEnum(value, defaultValue);
|
return Utils::String::toEnum(value, defaultValue);
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same_v<T, QVariant>)
|
|
||||||
{
|
|
||||||
return loadValueImpl(key, defaultValue);
|
|
||||||
}
|
|
||||||
else if constexpr (IsQFlags<T>::value)
|
else if constexpr (IsQFlags<T>::value)
|
||||||
{
|
{
|
||||||
const QVariant value = loadValueImpl(key, static_cast<typename T::Int>(defaultValue));
|
const typename T::Int value = loadValue(key, static_cast<typename T::Int>(defaultValue));
|
||||||
return T {value.template value<typename T::Int>()};
|
return T {value};
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, QVariant>)
|
||||||
|
{
|
||||||
|
// fast path for loading QVariant
|
||||||
|
return loadValueImpl(key, defaultValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue