aboutsummaryrefslogtreecommitdiff
path: root/lib/converters.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/converters.h')
-rw-r--r--lib/converters.h33
1 files changed, 15 insertions, 18 deletions
diff --git a/lib/converters.h b/lib/converters.h
index af6c0192..cc6378e4 100644
--- a/lib/converters.h
+++ b/lib/converters.h
@@ -151,10 +151,17 @@ struct JsonConverter<QDate> {
};
template <>
-struct JsonConverter<QUrl> : JsonConverter<QString> {
- static auto dump(const QUrl& url) // Override on top of that for QString
+struct JsonConverter<QUrl> {
+ static auto load(const QJsonValue& jv)
+ {
+ // QT_NO_URL_CAST_FROM_STRING makes this a bit more verbose
+ QUrl url;
+ url.setUrl(jv.toString());
+ return url;
+ }
+ static auto dump(const QUrl& url)
{
- return JsonConverter<QString>::dump(url.toString(QUrl::FullyEncoded));
+ return url.toString(QUrl::FullyEncoded);
}
};
@@ -164,15 +171,6 @@ struct JsonConverter<QJsonArray> : public TrivialJsonDumper<QJsonArray> {
};
template <>
-struct JsonConverter<QByteArray> {
- static QString dump(const QByteArray& ba) { return ba.constData(); }
- static auto load(const QJsonValue& jv)
- {
- return fromJson<QString>(jv).toLatin1();
- }
-};
-
-template <>
struct JsonConverter<QVariant> {
static QJsonValue dump(const QVariant& v);
static QVariant load(const QJsonValue& jv);
@@ -304,16 +302,15 @@ namespace _impl {
q.addQueryItem(k, v ? QStringLiteral("true") : QStringLiteral("false"));
}
- inline void addTo(QUrlQuery& q, const QString& k, const QStringList& vals)
+ inline void addTo(QUrlQuery& q, const QString& k, const QUrl& v)
{
- for (const auto& v : vals)
- q.addQueryItem(k, v);
+ q.addQueryItem(k, v.toEncoded());
}
- inline void addTo(QUrlQuery& q, const QString&, const QJsonObject& vals)
+ inline void addTo(QUrlQuery& q, const QString& k, const QStringList& vals)
{
- for (auto it = vals.begin(); it != vals.end(); ++it)
- q.addQueryItem(it.key(), it.value().toString());
+ for (const auto& v : vals)
+ q.addQueryItem(k, v);
}
// This one is for types that don't have isEmpty() and for all types