1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-01 08:52:45 +00:00

WIP: Slowly bringing back viewmodels

This commit is contained in:
Chris Josten 2021-03-29 23:48:16 +02:00
parent 9abee12658
commit 228f81984b
17 changed files with 292 additions and 96 deletions

View file

@ -152,9 +152,24 @@ QJsonValue toJsonValue(const QSharedPointer<T> &source, convertType<QSharedPoint
/**
* Templates for string conversion.
*/
template <typename T>
QString toString(const T &source, convertType<T>) {
return toJsonValue(source).toString();
}
template <typename T>
QString toString(const std::optional<T> &source, convertType<std::optional<T>>) {
if (source.has_value()) {
return toString<T>(source.value(), convertType<T>{});
} else {
return QString();
}
}
template <typename T>
QString toString(const T &source) {
return toJsonValue(source).toString();
return toString(source, convertType<T>{});
}