summaryrefslogtreecommitdiff
path: root/platform/qt/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/qt/src')
-rw-r--r--platform/qt/src/qt_conversion.hpp8
-rw-r--r--platform/qt/src/qt_geojson.hpp15
2 files changed, 20 insertions, 3 deletions
diff --git a/platform/qt/src/qt_conversion.hpp b/platform/qt/src/qt_conversion.hpp
index ae05200d66..4b93ca7423 100644
--- a/platform/qt/src/qt_conversion.hpp
+++ b/platform/qt/src/qt_conversion.hpp
@@ -30,7 +30,13 @@ inline QVariant arrayMember(const QVariant& value, std::size_t i) {
}
inline bool isObject(const QVariant& value) {
- return value.canConvert(QVariant::Map) || value.type() == QVariant::ByteArray;
+ return value.canConvert(QVariant::Map)
+ || value.type() == QVariant::ByteArray
+#if QT_VERSION >= 0x050000
+ || QString(value.typeName()) == QStringLiteral("QMapbox::Feature");
+#else
+ || QString(value.typeName()) == QString("QMapbox::Feature");
+#endif
}
inline optional<QVariant> objectMember(const QVariant& value, const char* key) {
diff --git a/platform/qt/src/qt_geojson.hpp b/platform/qt/src/qt_geojson.hpp
index caec790842..038b051941 100644
--- a/platform/qt/src/qt_geojson.hpp
+++ b/platform/qt/src/qt_geojson.hpp
@@ -180,8 +180,19 @@ namespace style {
namespace conversion {
template <>
+Result<GeoJSON> convertGeoJSON(const QMapbox::Feature& feature) {
+ return Result<GeoJSON> { GeoJSON { asMapboxGLFeature(feature) } };
+}
+
+template <>
Result<GeoJSON> convertGeoJSON(const QVariant& value) {
- if (value.type() != QVariant::ByteArray) {
+#if QT_VERSION >= 0x050000
+ if (value.typeName() == QStringLiteral("QMapbox::Feature")) {
+#else
+ if (value.typeName() == QString("QMapbox::Feature")) {
+#endif
+ return convertGeoJSON(value.value<QMapbox::Feature>());
+ } else if (value.type() != QVariant::ByteArray) {
return Error { "JSON data must be in QByteArray" };
}
@@ -201,7 +212,7 @@ Result<GeoJSON> convertGeoJSON(const QVariant& value) {
return Error { message.str() };
}
- conversion::Result<GeoJSON> geoJSON = conversion::convertGeoJSON<JSValue>(d);
+ Result<GeoJSON> geoJSON = convertGeoJSON<JSValue>(d);
if (!geoJSON) {
return Error { geoJSON.error().message };
}