summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2018-07-31 22:17:07 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2018-08-01 13:36:11 +0300
commit58d8b771a1ea22b4880d03efab44ebe6aafd2693 (patch)
tree521f4746397e0e504ecbc7bbbdcbd30c8f3c1a54
parentf7dcfced34a2716b7e742bc30e753dd7e5d3919e (diff)
downloadqtlocation-mapboxgl-58d8b771a1ea22b4880d03efab44ebe6aafd2693.tar.gz
[Qt] QMapboxGL::set{Paint,Layout}Property should return bool
-rw-r--r--platform/qt/include/qmapboxgl.hpp4
-rw-r--r--platform/qt/src/qmapboxgl.cpp30
2 files changed, 20 insertions, 14 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp
index a699b77cec..1af62c7491 100644
--- a/platform/qt/include/qmapboxgl.hpp
+++ b/platform/qt/include/qmapboxgl.hpp
@@ -198,8 +198,8 @@ public:
void updateAnnotation(QMapbox::AnnotationID, const QMapbox::Annotation &);
void removeAnnotation(QMapbox::AnnotationID);
- void setLayoutProperty(const QString &layer, const QString &property, const QVariant &value);
- void setPaintProperty(const QString &layer, const QString &property, const QVariant &value);
+ bool setLayoutProperty(const QString &layer, const QString &property, const QVariant &value);
+ bool setPaintProperty(const QString &layer, const QString &property, const QVariant &value);
bool isFullyLoaded() const;
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 09479581bb..05cb5b7f93 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -975,7 +975,7 @@ void QMapboxGL::removeAnnotation(QMapbox::AnnotationID id)
/*!
Sets a layout \a property_ \a value to an existing \a layer. The \a property_ string can be any
as defined by the \l {https://www.mapbox.com/mapbox-gl-style-spec/} {Mapbox style specification}
- for layout properties.
+ for layout properties. Returns true if the operation succeeds, and false otherwise.
This example hides the layer \c route:
@@ -1007,26 +1007,29 @@ void QMapboxGL::removeAnnotation(QMapbox::AnnotationID id)
\li QVariantList
\endtable
*/
-void QMapboxGL::setLayoutProperty(const QString& layer, const QString& property_, const QVariant& value)
+bool QMapboxGL::setLayoutProperty(const QString& layer, const QString& property_, const QVariant& value)
{
using namespace mbgl::style;
Layer* layer_ = d_ptr->mapObj->getStyle().getLayer(layer.toStdString());
if (!layer_) {
qWarning() << "Layer not found:" << layer;
- return;
+ return false;
}
- if (conversion::setLayoutProperty(*layer_, property_.toStdString(), value)) {
- qWarning() << "Error setting layout property:" << layer << "-" << property_;
- return;
+ auto result = conversion::setLayoutProperty(*layer_, property_.toStdString(), value);
+ if (result) {
+ qWarning() << "Error setting layout property" << property_ << "on layer" << layer << ":" << QString::fromStdString(result->message);
+ return false;
}
+
+ return true;
}
/*!
Sets a paint \a property_ \a value to an existing \a layer. The \a property_ string can be any
as defined by the \l {https://www.mapbox.com/mapbox-gl-style-spec/} {Mapbox style specification}
- for paint properties.
+ for paint properties. Returns true if the operation succeeds, and false otherwise.
For paint properties that take a color as \a value, such as \c fill-color, a string such as
\c blue can be passed or a QColor.
@@ -1073,20 +1076,23 @@ void QMapboxGL::setLayoutProperty(const QString& layer, const QString& property_
map->setPaintProperty("route","line-dasharray", lineDashArray);
\endcode
*/
-void QMapboxGL::setPaintProperty(const QString& layer, const QString& property_, const QVariant& value)
+bool QMapboxGL::setPaintProperty(const QString& layer, const QString& property_, const QVariant& value)
{
using namespace mbgl::style;
Layer* layer_ = d_ptr->mapObj->getStyle().getLayer(layer.toStdString());
if (!layer_) {
qWarning() << "Layer not found:" << layer;
- return;
+ return false;
}
- if (conversion::setPaintProperty(*layer_, property_.toStdString(), value)) {
- qWarning() << "Error setting paint property:" << layer << "-" << property_;
- return;
+ auto result = conversion::setPaintProperty(*layer_, property_.toStdString(), value);
+ if (result) {
+ qWarning() << "Error setting paint property" << property_ << "on layer" << layer << ":" << QString::fromStdString(result->message);
+ return false;
}
+
+ return true;
}
/*!