summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2018-03-05 13:47:31 -0500
committerBruno de Oliveira Abinader <bruno@mapbox.com>2018-03-05 14:41:58 -0500
commit803a4d46ed15a790876f5bda0e1d49d9ba0483a4 (patch)
tree8fae73f672783250279796f66ed19163860899e6 /platform/qt
parentfc140e265b559868a2a9f568583689ee4a6b9dfd (diff)
downloadqtlocation-mapboxgl-803a4d46ed15a790876f5bda0e1d49d9ba0483a4.tar.gz
[Qt] Added QMapboxGL::MapLoadingFailure enum
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/include/qmapboxgl.hpp10
-rw-r--r--platform/qt/src/qmapboxgl.cpp22
-rw-r--r--platform/qt/src/qmapboxgl_map_observer.cpp24
-rw-r--r--platform/qt/src/qmapboxgl_map_observer.hpp2
4 files changed, 53 insertions, 5 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp
index 7b07a0dff6..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,7 +258,7 @@ public slots:
signals:
void needsRendering();
void mapChanged(QMapboxGL::MapChange);
- void mapLoadingFailed(const QString &reason);
+ void mapLoadingFailed(QMapboxGL::MapLoadingFailure, const QString &reason);
void copyrightsChanged(const QString &copyrightsHtml);
void staticRenderFinished(const QString &error);
@@ -263,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 5430af30e2..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 &copyrightsHtml);
This signal is emitted when the copyrights of the current content of the map
@@ -1649,7 +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(QString)), q, SIGNAL(mapLoadingFailed(QString)));
+ 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 43b4162eb4..44cb8c41d5 100644
--- a/platform/qt/src/qmapboxgl_map_observer.cpp
+++ b/platform/qt/src/qmapboxgl_map_observer.cpp
@@ -2,7 +2,7 @@
#include "qmapboxgl_p.hpp"
-#include <mbgl/util/string.hpp>
+#include <mbgl/util/exception.hpp>
#include <exception>
@@ -51,7 +51,27 @@ void QMapboxGLMapObserver::onDidFinishLoadingMap()
void QMapboxGLMapObserver::onDidFailLoadingMap(std::exception_ptr exception)
{
emit mapChanged(QMapboxGL::MapChangeDidFailLoadingMap);
- emit mapLoadingFailed(QString::fromStdString(mbgl::util::toString(exception)));
+
+ 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 7c272c39ae..98da5b6add 100644
--- a/platform/qt/src/qmapboxgl_map_observer.hpp
+++ b/platform/qt/src/qmapboxgl_map_observer.hpp
@@ -36,7 +36,7 @@ public:
signals:
void mapChanged(QMapboxGL::MapChange);
- void mapLoadingFailed(const QString &reason);
+ void mapLoadingFailed(QMapboxGL::MapLoadingFailure, const QString &reason);
void copyrightsChanged(const QString &copyrightsHtml);
private: