diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-03-08 14:12:47 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-03-08 14:12:47 +0200 |
commit | 8f49bcdcf4a254f89e1cd95c23e43ecb31efe722 (patch) | |
tree | d97c29537b1fac781edf489012b4632b2ed94942 /platform | |
parent | b2286c6c8f9076de4143061a778fc676cc15eb84 (diff) | |
download | qtlocation-mapboxgl-8f49bcdcf4a254f89e1cd95c23e43ecb31efe722.tar.gz |
Bump Mapbox GL Native
mapbox-gl-native @ eeadec3e061c0041257bc792eabb1db5fc05ef27
Diffstat (limited to 'platform')
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 9 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 21 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl_map_observer.cpp | 27 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl_map_observer.hpp | 1 |
4 files changed, 57 insertions, 1 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index bc18eaba59..b5676fbedd 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -128,6 +128,13 @@ public: MapChangeSourceDidChange }; + enum MapLoadingFailure { + StyleParseFailure, + StyleLoadFailure, + NotFoundFailure, + UnknownFailure + }; + // Determines the orientation of the map. enum NorthOrientation { NorthUpwards, // Default @@ -251,6 +258,7 @@ public slots: signals: void needsRendering(); void mapChanged(QMapboxGL::MapChange); + void mapLoadingFailed(QMapboxGL::MapLoadingFailure, const QString &reason); void copyrightsChanged(const QString ©rightsHtml); void staticRenderFinished(const QString &error); @@ -262,5 +270,6 @@ private: }; Q_DECLARE_METATYPE(QMapboxGL::MapChange); +Q_DECLARE_METATYPE(QMapboxGL::MapLoadingFailure); #endif // QMAPBOXGL_H diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 982f4b3b35..34fd5509fa 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -518,6 +518,19 @@ void QMapboxGLSettings::setResourceTransform(const std::function<std::string(con */ /*! + \enum QMapboxGL::MapLoadingFailure + + This enum represents map loading failure type. + + \value StyleParseFailure Failure to parse the style. + \value StyleLoadFailure Failure to load the style data. + \value NotFoundFailure Failure to obtain style resource file. + \value UnknownFailure Unknown map loading failure. + + \sa mapLoadingFailed() +*/ + +/*! \enum QMapboxGL::NorthOrientation This enum sets the orientation of the north bearing. It will directly affect bearing when @@ -1613,6 +1626,13 @@ void QMapboxGL::connectionEstablished() */ /*! + \fn void QMapboxGL::mapLoadingFailed(QMapboxGL::MapLoadingFailure type, const QString &description) + + This signal is emitted when a map loading failure happens. Details of the + failures are provided, including its \a type and textual \a description. +*/ + +/*! \fn void QMapboxGL::copyrightsChanged(const QString ©rightsHtml); This signal is emitted when the copyrights of the current content of the map @@ -1649,6 +1669,7 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin qRegisterMetaType<QMapboxGL::MapChange>("QMapboxGL::MapChange"); connect(m_mapObserver.get(), SIGNAL(mapChanged(QMapboxGL::MapChange)), q, SIGNAL(mapChanged(QMapboxGL::MapChange))); + connect(m_mapObserver.get(), SIGNAL(mapLoadingFailed(QMapboxGL::MapLoadingFailure,QString)), q, SIGNAL(mapLoadingFailed(QMapboxGL::MapLoadingFailure,QString))); connect(m_mapObserver.get(), SIGNAL(copyrightsChanged(QString)), q, SIGNAL(copyrightsChanged(QString))); // Setup the Map object diff --git a/platform/qt/src/qmapboxgl_map_observer.cpp b/platform/qt/src/qmapboxgl_map_observer.cpp index 60c6b81841..44cb8c41d5 100644 --- a/platform/qt/src/qmapboxgl_map_observer.cpp +++ b/platform/qt/src/qmapboxgl_map_observer.cpp @@ -2,6 +2,10 @@ #include "qmapboxgl_p.hpp" +#include <mbgl/util/exception.hpp> + +#include <exception> + QMapboxGLMapObserver::QMapboxGLMapObserver(QMapboxGLPrivate *d) : d_ptr(d) { @@ -44,9 +48,30 @@ void QMapboxGLMapObserver::onDidFinishLoadingMap() emit mapChanged(QMapboxGL::MapChangeDidFinishLoadingMap); } -void QMapboxGLMapObserver::onDidFailLoadingMap(std::exception_ptr) +void QMapboxGLMapObserver::onDidFailLoadingMap(std::exception_ptr exception) { emit mapChanged(QMapboxGL::MapChangeDidFailLoadingMap); + + QMapboxGL::MapLoadingFailure type; + QString description; + + try { + std::rethrow_exception(exception); + } catch (const mbgl::util::StyleParseException& e) { + type = QMapboxGL::MapLoadingFailure::StyleParseFailure; + description = e.what(); + } catch (const mbgl::util::StyleLoadException& e) { + type = QMapboxGL::MapLoadingFailure::StyleLoadFailure; + description = e.what(); + } catch (const mbgl::util::NotFoundException& e) { + type = QMapboxGL::MapLoadingFailure::NotFoundFailure; + description = e.what(); + } catch (const std::exception& e) { + type = QMapboxGL::MapLoadingFailure::UnknownFailure; + description = e.what(); + } + + emit mapLoadingFailed(type, description); } void QMapboxGLMapObserver::onWillStartRenderingFrame() diff --git a/platform/qt/src/qmapboxgl_map_observer.hpp b/platform/qt/src/qmapboxgl_map_observer.hpp index c9d0581a90..98da5b6add 100644 --- a/platform/qt/src/qmapboxgl_map_observer.hpp +++ b/platform/qt/src/qmapboxgl_map_observer.hpp @@ -36,6 +36,7 @@ public: signals: void mapChanged(QMapboxGL::MapChange); + void mapLoadingFailed(QMapboxGL::MapLoadingFailure, const QString &reason); void copyrightsChanged(const QString ©rightsHtml); private: |