summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-01-31 17:19:38 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-01-31 19:24:55 +0200
commit691398e9bde410efa095bb648366779995b98e84 (patch)
tree9a92fac35834144e9b7d8c15aaad55b269e6b46e
parentf3bcf836cdf5f422a2a4c51f665f17d3b64ca3ae (diff)
downloadqtlocation-mapboxgl-691398e9bde410efa095bb648366779995b98e84.tar.gz
[Qt] Avoid using brace-list init ctor in QMapboxGL
-rw-r--r--include/mbgl/annotation/annotation.hpp20
-rw-r--r--platform/qt/app/mapwindow.cpp6
-rw-r--r--platform/qt/include/qmapbox.hpp21
-rw-r--r--platform/qt/src/qmapboxgl.cpp38
4 files changed, 56 insertions, 29 deletions
diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp
index a84bea1c18..1a107080de 100644
--- a/include/mbgl/annotation/annotation.hpp
+++ b/include/mbgl/annotation/annotation.hpp
@@ -16,6 +16,11 @@ using AnnotationIDs = std::vector<AnnotationID>;
class SymbolAnnotation {
public:
+ SymbolAnnotation() = default;
+
+ SymbolAnnotation(Point<double> geometry_, std::string icon_)
+ : geometry(std::move(geometry_)), icon(std::move(icon_)) {}
+
Point<double> geometry;
std::string icon;
};
@@ -28,9 +33,9 @@ using ShapeAnnotationGeometry = variant<
class LineAnnotation {
public:
- LineAnnotation(const ShapeAnnotationGeometry &geometry_, const style::PropertyValue<float> &opacity_,
- const style::PropertyValue<float> &width_, const style::PropertyValue<Color> &color_) :
- geometry(geometry_), opacity(opacity_), width(width_), color(color_) {}
+ LineAnnotation(ShapeAnnotationGeometry geometry_, style::PropertyValue<float> opacity_,
+ style::PropertyValue<float> width_, style::PropertyValue<Color> color_)
+ : geometry(std::move(geometry_)), opacity(std::move(opacity_)), width(std::move(width_)), color(std::move(color_)) {}
ShapeAnnotationGeometry geometry;
style::PropertyValue<float> opacity { 1.0f };
@@ -40,9 +45,9 @@ public:
class FillAnnotation {
public:
- FillAnnotation(const ShapeAnnotationGeometry &geometry_, const style::PropertyValue<float> &opacity_,
- const style::PropertyValue<Color> &color_, const style::PropertyValue<Color> &outlineColor_) :
- geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {}
+ FillAnnotation(ShapeAnnotationGeometry geometry_, style::PropertyValue<float> opacity_,
+ style::PropertyValue<Color> color_, style::PropertyValue<Color> outlineColor_)
+ : geometry(std::move(geometry_)), opacity(std::move(opacity_)), color(std::move(color_)), outlineColor(std::move(outlineColor_)) {}
ShapeAnnotationGeometry geometry;
style::PropertyValue<float> opacity { 1.0f };
@@ -53,6 +58,9 @@ public:
// An annotation whose type and properties are sourced from a style layer.
class StyleSourcedAnnotation {
public:
+ StyleSourcedAnnotation(ShapeAnnotationGeometry geometry_, std::string layerID_)
+ : geometry(std::move(geometry_)), layerID(std::move(layerID_)) {}
+
ShapeAnnotationGeometry geometry;
std::string layerID;
};
diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp
index 3e6a14736f..7c54dfa9bd 100644
--- a/platform/qt/app/mapwindow.cpp
+++ b/platform/qt/app/mapwindow.cpp
@@ -220,7 +220,7 @@ void MapWindow::keyPressEvent(QKeyEvent *ev)
QMapbox::Coordinate topLeft = m_map->coordinateForPixel({ 0, 0 });
QMapbox::Coordinate bottomRight = m_map->coordinateForPixel({ qreal(size().width()), qreal(size().height()) });
QMapbox::CoordinatesCollections geometry { { { topLeft, bottomRight } } };
- QMapbox::LineAnnotation line { { QMapbox::ShapeAnnotationGeometry::Type::LineStringType, geometry }, 0.5f, 1.0f, Qt::red };
+ QMapbox::LineAnnotation line({ QMapbox::ShapeAnnotationGeometry::Type::LineStringType, geometry }, 0.5f, 1.0f, Qt::red);
m_lineAnnotationId = m_map->addAnnotation(QVariant::fromValue<QMapbox::LineAnnotation>(line));
} else {
m_map->removeAnnotation(m_lineAnnotationId.toUInt());
@@ -235,7 +235,7 @@ void MapWindow::keyPressEvent(QKeyEvent *ev)
QMapbox::Coordinate bottomLeft = m_map->coordinateForPixel({ qreal(size().width()), 0 });
QMapbox::Coordinate bottomRight = m_map->coordinateForPixel({ qreal(size().width()), qreal(size().height()) });
QMapbox::CoordinatesCollections geometry { { { bottomLeft, bottomRight, topRight, topLeft, bottomLeft } } };
- QMapbox::FillAnnotation fill { { QMapbox::ShapeAnnotationGeometry::Type::PolygonType, geometry }, 0.5f, Qt::green, QVariant::fromValue<QColor>(QColor(Qt::black)) };
+ QMapbox::FillAnnotation fill({ QMapbox::ShapeAnnotationGeometry::Type::PolygonType, geometry }, 0.5f, Qt::green, QVariant::fromValue<QColor>(QColor(Qt::black)));
m_fillAnnotationId = m_map->addAnnotation(QVariant::fromValue<QMapbox::FillAnnotation>(fill));
} else {
m_map->removeAnnotation(m_fillAnnotationId.toUInt());
@@ -250,7 +250,7 @@ void MapWindow::keyPressEvent(QKeyEvent *ev)
QMapbox::Coordinate bottomLeft = m_map->coordinateForPixel({ qreal(size().width()), 0 });
QMapbox::Coordinate bottomRight = m_map->coordinateForPixel({ qreal(size().width()), qreal(size().height()) });
QMapbox::CoordinatesCollections geometry { { { bottomLeft, bottomRight, topRight, topLeft, bottomLeft } } };
- QMapbox::StyleSourcedAnnotation styleSourced { { QMapbox::ShapeAnnotationGeometry::Type::PolygonType, geometry }, "water" };
+ QMapbox::StyleSourcedAnnotation styleSourced({ QMapbox::ShapeAnnotationGeometry::Type::PolygonType, geometry }, "water");
m_styleSourcedAnnotationId = m_map->addAnnotation(QVariant::fromValue<QMapbox::StyleSourcedAnnotation>(styleSourced));
} else {
m_map->removeAnnotation(m_styleSourcedAnnotationId.toUInt());
diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp
index 1388c0f513..417609bd93 100644
--- a/platform/qt/include/qmapbox.hpp
+++ b/platform/qt/include/qmapbox.hpp
@@ -32,6 +32,12 @@ struct Q_DECL_EXPORT ShapeAnnotationGeometry {
MultiLineStringType,
MultiPolygonType
};
+
+ ShapeAnnotationGeometry() {}
+
+ ShapeAnnotationGeometry(Type type_, const CoordinatesCollections& geometry_)
+ : type(type_), geometry(geometry_) {}
+
Type type;
CoordinatesCollections geometry;
};
@@ -44,6 +50,11 @@ struct Q_DECL_EXPORT SymbolAnnotation {
// Reflects mbgl::LineAnnotation.
struct Q_DECL_EXPORT LineAnnotation {
+ LineAnnotation() {}
+
+ LineAnnotation(const ShapeAnnotationGeometry& geometry_, float opacity_, float width_, const QColor& color_)
+ : geometry(geometry_), opacity(opacity_), width(width_), color(color_) {}
+
ShapeAnnotationGeometry geometry;
float opacity = 1.0f;
float width = 1.0f;
@@ -52,6 +63,11 @@ struct Q_DECL_EXPORT LineAnnotation {
// Reflects mbgl::FillAnnotation.
struct Q_DECL_EXPORT FillAnnotation {
+ FillAnnotation() {}
+
+ FillAnnotation(const ShapeAnnotationGeometry& geometry_, float opacity_, const QColor& color_, const QVariant& outlineColor_ = QVariant())
+ : geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {}
+
ShapeAnnotationGeometry geometry;
float opacity = 1.0f;
QColor color = Qt::black;
@@ -60,6 +76,11 @@ struct Q_DECL_EXPORT FillAnnotation {
// Reflects mbgl::StyleSourcedAnnotation.
struct Q_DECL_EXPORT StyleSourcedAnnotation {
+ StyleSourcedAnnotation() {}
+
+ StyleSourcedAnnotation(const ShapeAnnotationGeometry geometry_, const QString& layerID_)
+ : geometry(geometry_), layerID(layerID_) {}
+
ShapeAnnotationGeometry geometry;
QString layerID;
};
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 5e3a0f2a7c..bdc99994b5 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -885,43 +885,41 @@ mbgl::ShapeAnnotationGeometry asMapboxGLGeometry(const QMapbox::ShapeAnnotationG
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;
}
mbgl::Annotation asMapboxGLAnnotation(const QMapbox::Annotation & annotation) {
if (annotation.canConvert<QMapbox::SymbolAnnotation>()) {
- QMapbox::SymbolAnnotation symbolAnnotation = annotation.value<QMapbox::SymbolAnnotation>();
- QMapbox::Coordinate& pair = symbolAnnotation.geometry;
- return mbgl::SymbolAnnotation { mbgl::Point<double> { pair.second, pair.first }, symbolAnnotation.icon.toStdString() };
+ QMapbox::SymbolAnnotation symbol = annotation.value<QMapbox::SymbolAnnotation>();
+ QMapbox::Coordinate& pair = symbol.geometry;
+ return mbgl::SymbolAnnotation(mbgl::Point<double>(pair.second, pair.first), symbol.icon.toStdString());
} else if (annotation.canConvert<QMapbox::LineAnnotation>()) {
- QMapbox::LineAnnotation lineAnnotation = annotation.value<QMapbox::LineAnnotation>();
- auto color = mbgl::Color::parse(lineAnnotation.color.name().toStdString());
- return mbgl::LineAnnotation { asMapboxGLGeometry(lineAnnotation.geometry), lineAnnotation.opacity, lineAnnotation.width, { *color } };
+ QMapbox::LineAnnotation line = annotation.value<QMapbox::LineAnnotation>();
+ mbgl::style::PropertyValue<mbgl::Color> color = *mbgl::Color::parse(line.color.name().toStdString());
+ return mbgl::LineAnnotation(asMapboxGLGeometry(line.geometry), line.opacity, line.width, color);
} else if (annotation.canConvert<QMapbox::FillAnnotation>()) {
- QMapbox::FillAnnotation fillAnnotation = annotation.value<QMapbox::FillAnnotation>();
- auto color = mbgl::Color::parse(fillAnnotation.color.name().toStdString());
- if (fillAnnotation.outlineColor.canConvert<QColor>()) {
- auto outlineColor = mbgl::Color::parse(fillAnnotation.outlineColor.value<QColor>().name().toStdString());
- return mbgl::FillAnnotation { asMapboxGLGeometry(fillAnnotation.geometry), fillAnnotation.opacity, { *color }, { *outlineColor } };
- } else {
- return mbgl::FillAnnotation { asMapboxGLGeometry(fillAnnotation.geometry), fillAnnotation.opacity, { *color }, {} };
+ QMapbox::FillAnnotation fill = annotation.value<QMapbox::FillAnnotation>();
+ mbgl::style::PropertyValue<mbgl::Color> color = *mbgl::Color::parse(fill.color.name().toStdString());
+ mbgl::style::PropertyValue<mbgl::Color> outlineColor;
+ if (fill.outlineColor.canConvert<QColor>()) {
+ outlineColor = *mbgl::Color::parse(fill.outlineColor.value<QColor>().name().toStdString());
}
+ return mbgl::FillAnnotation(asMapboxGLGeometry(fill.geometry), fill.opacity, color, outlineColor);
} else if (annotation.canConvert<QMapbox::StyleSourcedAnnotation>()) {
- QMapbox::StyleSourcedAnnotation styleSourcedAnnotation = annotation.value<QMapbox::StyleSourcedAnnotation>();
- return mbgl::StyleSourcedAnnotation { asMapboxGLGeometry(styleSourcedAnnotation.geometry), styleSourcedAnnotation.layerID.toStdString() };
+ QMapbox::StyleSourcedAnnotation styleSourced = annotation.value<QMapbox::StyleSourcedAnnotation>();
+ return mbgl::StyleSourcedAnnotation(asMapboxGLGeometry(styleSourced.geometry), styleSourced.layerID.toStdString());
}
qWarning() << "Unable to convert annotation:" << annotation;