From 7e8fe05af0dcf6d3d935c8b871b083ab98118e7b Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 31 Jan 2017 17:19:38 +0200 Subject: [Qt] Avoid using brace-list init ctor in QMapboxGL --- platform/qt/include/qmapbox.hpp | 29 +++++++++++++++++++++++------ platform/qt/src/qmapboxgl.cpp | 16 ++++++++-------- 2 files changed, 31 insertions(+), 14 deletions(-) (limited to 'platform') diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp index 1b61d3270f..d138f4057b 100644 --- a/platform/qt/include/qmapbox.hpp +++ b/platform/qt/include/qmapbox.hpp @@ -26,6 +26,11 @@ struct Q_DECL_EXPORT Feature { LineStringType, PolygonType }; + + Feature(Type type_ = PointType, const CoordinatesCollections& geometry_ = CoordinatesCollections(), + const QVariantMap& properties_ = QVariantMap(), const QVariant& id_ = QVariant()) + : type(type_), geometry(geometry_), properties(properties_), id(id_) {} + Type type; CoordinatesCollections geometry; QVariantMap properties; @@ -34,11 +39,15 @@ struct Q_DECL_EXPORT Feature { struct Q_DECL_EXPORT ShapeAnnotationGeometry { enum Type { - LineStringType, + LineStringType = 1, PolygonType, MultiLineStringType, MultiPolygonType }; + + ShapeAnnotationGeometry(Type type_ = LineStringType, const CoordinatesCollections& geometry_ = CoordinatesCollections()) + : type(type_), geometry(geometry_) {} + Type type; CoordinatesCollections geometry; }; @@ -49,16 +58,24 @@ struct Q_DECL_EXPORT SymbolAnnotation { }; struct Q_DECL_EXPORT LineAnnotation { + LineAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, + float width_ = 1.0f, const QColor& color_ = Qt::black) + : geometry(geometry_), opacity(opacity_), width(width_), color(color_) {} + ShapeAnnotationGeometry geometry; - float opacity = 1.0f; - float width = 1.0f; - QColor color = Qt::black; + float opacity; + float width; + QColor color; }; struct Q_DECL_EXPORT FillAnnotation { + FillAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, + const QColor& color_ = Qt::black, const QVariant& outlineColor_ = QVariant()) + : geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {} + ShapeAnnotationGeometry geometry; - float opacity = 1.0f; - QColor color = Qt::black; + float opacity; + QColor color; QVariant outlineColor; }; diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 06901b13ba..b79630b3df 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -780,16 +780,16 @@ mbgl::optional asMapboxGLAnnotation(const QMapbox::Annotation mbgl::ShapeAnnotationGeometry result; switch (geometry.type) { case QMapbox::ShapeAnnotationGeometry::LineStringType: - result = { asMapboxGLLineString(geometry.geometry.first().first()) }; + result = asMapboxGLLineString(geometry.geometry.first().first()); break; case QMapbox::ShapeAnnotationGeometry::PolygonType: - result = { asMapboxGLPolygon(geometry.geometry.first()) }; + result = asMapboxGLPolygon(geometry.geometry.first()); break; case QMapbox::ShapeAnnotationGeometry::MultiLineStringType: - result = { asMapboxGLMultiLineString(geometry.geometry.first()) }; + result = asMapboxGLMultiLineString(geometry.geometry.first()); break; case QMapbox::ShapeAnnotationGeometry::MultiPolygonType: - result = { asMapboxGLMultiPolygon(geometry.geometry) }; + result = asMapboxGLMultiPolygon(geometry.geometry); break; } return result; @@ -798,19 +798,19 @@ mbgl::optional asMapboxGLAnnotation(const QMapbox::Annotation if (annotation.canConvert()) { QMapbox::SymbolAnnotation symbolAnnotation = annotation.value(); QMapbox::Coordinate& pair = symbolAnnotation.geometry; - return { mbgl::SymbolAnnotation { mbgl::Point { pair.second, pair.first }, symbolAnnotation.icon.toStdString() } }; + return { mbgl::SymbolAnnotation(mbgl::Point { pair.second, pair.first }, symbolAnnotation.icon.toStdString()) }; } else if (annotation.canConvert()) { QMapbox::LineAnnotation lineAnnotation = annotation.value(); auto color = mbgl::Color::parse(lineAnnotation.color.name().toStdString()); - return { mbgl::LineAnnotation { asMapboxGLGeometry(lineAnnotation.geometry), lineAnnotation.opacity, lineAnnotation.width, { *color } } }; + return { mbgl::LineAnnotation(asMapboxGLGeometry(lineAnnotation.geometry), lineAnnotation.opacity, lineAnnotation.width, { *color }) }; } else if (annotation.canConvert()) { QMapbox::FillAnnotation fillAnnotation = annotation.value(); auto color = mbgl::Color::parse(fillAnnotation.color.name().toStdString()); if (fillAnnotation.outlineColor.canConvert()) { auto outlineColor = mbgl::Color::parse(fillAnnotation.outlineColor.value().name().toStdString()); - return { mbgl::FillAnnotation { asMapboxGLGeometry(fillAnnotation.geometry), fillAnnotation.opacity, { *color }, { *outlineColor } } }; + return { mbgl::FillAnnotation(asMapboxGLGeometry(fillAnnotation.geometry), fillAnnotation.opacity, { *color }, { *outlineColor }) }; } else { - return { mbgl::FillAnnotation { asMapboxGLGeometry(fillAnnotation.geometry), fillAnnotation.opacity, { *color }, {} } }; + return { mbgl::FillAnnotation(asMapboxGLGeometry(fillAnnotation.geometry), fillAnnotation.opacity, { *color }, {}) }; } } -- cgit v1.2.1