summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-12-23 01:54:40 -0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-01-03 16:52:24 -0200
commit003eec633e93ddea3638e4f77f01079640bed492 (patch)
tree74c649a3c65b1acec783587c9b047cba432b7d3b /platform
parentb8564299e5e76918ba0ec01eb4fb99bd9756638b (diff)
downloadqtlocation-mapboxgl-003eec633e93ddea3638e4f77f01079640bed492.tar.gz
[Qt] Move QMapboxGL stuff from QMapbox namespace
Diffstat (limited to 'platform')
-rw-r--r--platform/qt/app/mapwindow.cpp2
-rw-r--r--platform/qt/include/qmapbox.hpp29
-rw-r--r--platform/qt/include/qmapboxgl.hpp34
-rw-r--r--platform/qt/src/qmapbox.cpp18
-rw-r--r--platform/qt/src/qmapboxgl.cpp30
-rw-r--r--platform/qt/src/qmapboxgl_p.hpp2
-rw-r--r--platform/qt/src/qquickmapboxgl.cpp5
-rw-r--r--platform/qt/src/qquickmapboxgl.hpp3
-rw-r--r--platform/qt/src/qquickmapboxglrenderer.cpp2
-rw-r--r--platform/qt/test/qmapboxgl.cpp26
10 files changed, 76 insertions, 75 deletions
diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp
index 4c2c0ed2ad..e8fb6314c6 100644
--- a/platform/qt/app/mapwindow.cpp
+++ b/platform/qt/app/mapwindow.cpp
@@ -92,7 +92,7 @@ void MapWindow::keyPressEvent(QKeyEvent *ev)
m_sourceAdded = true;
- QFile geojson(":source.geojson");
+ QFile geojson(":source1.geojson");
geojson.open(QIODevice::ReadOnly);
// The data source for the route line and markers
diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp
index b8a4399fa5..b2e3b521d0 100644
--- a/platform/qt/include/qmapbox.hpp
+++ b/platform/qt/include/qmapbox.hpp
@@ -29,34 +29,6 @@ enum NetworkMode {
Offline,
};
-// Reflects mbgl::MapChange.
-enum MapChange {
- MapChangeRegionWillChange = 0,
- MapChangeRegionWillChangeAnimated,
- MapChangeRegionIsChanging,
- MapChangeRegionDidChange,
- MapChangeRegionDidChangeAnimated,
- MapChangeWillStartLoadingMap,
- MapChangeDidFinishLoadingMap,
- MapChangeDidFailLoadingMap,
- MapChangeWillStartRenderingFrame,
- MapChangeDidFinishRenderingFrame,
- MapChangeDidFinishRenderingFrameFullyRendered,
- MapChangeWillStartRenderingMap,
- MapChangeDidFinishRenderingMap,
- MapChangeDidFinishRenderingMapFullyRendered,
- MapChangeDidFinishLoadingStyle,
- MapChangeSourceDidChange
-};
-
-struct Q_DECL_EXPORT CameraOptions {
- QVariant center; // Coordinate
- QVariant anchor; // QPointF
- QVariant zoom; // double
- QVariant angle; // double
- QVariant pitch; // double
-};
-
Q_DECL_EXPORT QList<QPair<QString, QString> >& defaultStyles();
Q_DECL_EXPORT NetworkMode networkMode();
@@ -84,6 +56,5 @@ Q_DECL_EXPORT void registerTypes();
} // namespace QMapbox
Q_DECLARE_METATYPE(QMapbox::Coordinate);
-Q_DECLARE_METATYPE(QMapbox::MapChange);
#endif // QMAPBOX_H
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp
index d832bc821d..c3a83610be 100644
--- a/platform/qt/include/qmapboxgl.hpp
+++ b/platform/qt/include/qmapboxgl.hpp
@@ -71,6 +71,14 @@ private:
QString m_accessToken;
};
+struct Q_DECL_EXPORT QMapboxGLCameraOptions {
+ QVariant center; // Coordinate
+ QVariant anchor; // QPointF
+ QVariant zoom; // double
+ QVariant angle; // double
+ QVariant pitch; // double
+};
+
class Q_DECL_EXPORT QMapboxGL : public QObject
{
Q_OBJECT
@@ -86,6 +94,26 @@ class Q_DECL_EXPORT QMapboxGL : public QObject
Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
public:
+ // Reflects mbgl::MapChange.
+ enum MapChange {
+ MapChangeRegionWillChange = 0,
+ MapChangeRegionWillChangeAnimated,
+ MapChangeRegionIsChanging,
+ MapChangeRegionDidChange,
+ MapChangeRegionDidChangeAnimated,
+ MapChangeWillStartLoadingMap,
+ MapChangeDidFinishLoadingMap,
+ MapChangeDidFailLoadingMap,
+ MapChangeWillStartRenderingFrame,
+ MapChangeDidFinishRenderingFrame,
+ MapChangeDidFinishRenderingFrameFullyRendered,
+ MapChangeWillStartRenderingMap,
+ MapChangeDidFinishRenderingMap,
+ MapChangeDidFinishRenderingMapFullyRendered,
+ MapChangeDidFinishLoadingStyle,
+ MapChangeSourceDidChange
+ };
+
// Determines the orientation of the map.
enum NorthOrientation {
NorthUpwards, // Default
@@ -137,7 +165,7 @@ public:
void setCoordinate(const QMapbox::Coordinate &);
void setCoordinateZoom(const QMapbox::Coordinate &, double zoom);
- void jumpTo(const QMapbox::CameraOptions&);
+ void jumpTo(const QMapboxGLCameraOptions&);
void setGestureInProgress(bool inProgress);
@@ -209,7 +237,7 @@ public slots:
signals:
void needsRendering();
- void mapChanged(QMapbox::MapChange);
+ void mapChanged(QMapboxGL::MapChange);
void copyrightsChanged(const QString &copyrightsHtml);
private:
@@ -218,4 +246,6 @@ private:
QMapboxGLPrivate *d_ptr;
};
+Q_DECLARE_METATYPE(QMapboxGL::MapChange);
+
#endif // QMAPBOXGL_H
diff --git a/platform/qt/src/qmapbox.cpp b/platform/qt/src/qmapbox.cpp
index 118b1355e2..379b0cdd57 100644
--- a/platform/qt/src/qmapbox.cpp
+++ b/platform/qt/src/qmapbox.cpp
@@ -18,24 +18,6 @@
static_assert(mbgl::underlying_type(QMapbox::Online) == mbgl::underlying_type(mbgl::NetworkStatus::Status::Online), "error");
static_assert(mbgl::underlying_type(QMapbox::Offline) == mbgl::underlying_type(mbgl::NetworkStatus::Status::Offline), "error");
-// mbgl::MapChange
-static_assert(mbgl::underlying_type(QMapbox::MapChangeRegionWillChange) == mbgl::underlying_type(mbgl::MapChangeRegionWillChange), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeRegionWillChangeAnimated) == mbgl::underlying_type(mbgl::MapChangeRegionWillChangeAnimated), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeRegionIsChanging) == mbgl::underlying_type(mbgl::MapChangeRegionIsChanging), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeRegionDidChange) == mbgl::underlying_type(mbgl::MapChangeRegionDidChange), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeRegionDidChangeAnimated) == mbgl::underlying_type(mbgl::MapChangeRegionDidChangeAnimated), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeWillStartLoadingMap) == mbgl::underlying_type(mbgl::MapChangeWillStartLoadingMap), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeDidFinishLoadingMap) == mbgl::underlying_type(mbgl::MapChangeDidFinishLoadingMap), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeDidFailLoadingMap) == mbgl::underlying_type(mbgl::MapChangeDidFailLoadingMap), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeWillStartRenderingFrame) == mbgl::underlying_type(mbgl::MapChangeWillStartRenderingFrame), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeDidFinishRenderingFrame) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingFrame), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeDidFinishRenderingFrameFullyRendered) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingFrameFullyRendered), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeWillStartRenderingMap) == mbgl::underlying_type(mbgl::MapChangeWillStartRenderingMap), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeDidFinishRenderingMap) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingMap), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeDidFinishRenderingMapFullyRendered) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingMapFullyRendered), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeDidFinishLoadingStyle) == mbgl::underlying_type(mbgl::MapChangeDidFinishLoadingStyle), "error");
-static_assert(mbgl::underlying_type(QMapbox::MapChangeSourceDidChange) == mbgl::underlying_type(mbgl::MapChangeSourceDidChange), "error");
-
namespace QMapbox {
Q_DECL_EXPORT NetworkMode networkMode()
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index d6111839f3..cf6b930d4a 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -55,6 +55,24 @@ static_assert(mbgl::underlying_type(QMapboxGLSettings::ConstrainWidthAndHeight)
static_assert(mbgl::underlying_type(QMapboxGLSettings::DefaultViewport) == mbgl::underlying_type(mbgl::ViewportMode::Default), "error");
static_assert(mbgl::underlying_type(QMapboxGLSettings::FlippedYViewport) == mbgl::underlying_type(mbgl::ViewportMode::FlippedY), "error");
+// mbgl::MapChange
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeRegionWillChange) == mbgl::underlying_type(mbgl::MapChangeRegionWillChange), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeRegionWillChangeAnimated) == mbgl::underlying_type(mbgl::MapChangeRegionWillChangeAnimated), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeRegionIsChanging) == mbgl::underlying_type(mbgl::MapChangeRegionIsChanging), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeRegionDidChange) == mbgl::underlying_type(mbgl::MapChangeRegionDidChange), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeRegionDidChangeAnimated) == mbgl::underlying_type(mbgl::MapChangeRegionDidChangeAnimated), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeWillStartLoadingMap) == mbgl::underlying_type(mbgl::MapChangeWillStartLoadingMap), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeDidFinishLoadingMap) == mbgl::underlying_type(mbgl::MapChangeDidFinishLoadingMap), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeDidFailLoadingMap) == mbgl::underlying_type(mbgl::MapChangeDidFailLoadingMap), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeWillStartRenderingFrame) == mbgl::underlying_type(mbgl::MapChangeWillStartRenderingFrame), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeDidFinishRenderingFrame) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingFrame), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeDidFinishRenderingFrameFullyRendered) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingFrameFullyRendered), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeWillStartRenderingMap) == mbgl::underlying_type(mbgl::MapChangeWillStartRenderingMap), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeDidFinishRenderingMap) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingMap), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeDidFinishRenderingMapFullyRendered) == mbgl::underlying_type(mbgl::MapChangeDidFinishRenderingMapFullyRendered), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeDidFinishLoadingStyle) == mbgl::underlying_type(mbgl::MapChangeDidFinishLoadingStyle), "error");
+static_assert(mbgl::underlying_type(QMapboxGL::MapChangeSourceDidChange) == mbgl::underlying_type(mbgl::MapChangeSourceDidChange), "error");
+
// mbgl::NorthOrientation
static_assert(mbgl::underlying_type(QMapboxGL::NorthUpwards) == mbgl::underlying_type(mbgl::NorthOrientation::Upwards), "error");
static_assert(mbgl::underlying_type(QMapboxGL::NorthRightwards) == mbgl::underlying_type(mbgl::NorthOrientation::Rightwards), "error");
@@ -279,7 +297,7 @@ QString QMapboxGL::styleUrl() const
{Mapbox Style Specification}.
\note In case of a invalid style it will trigger a mapChanged
- signal with QMapbox::MapChangeDidFailLoadingMap as argument.
+ signal with QMapboxGL::MapChangeDidFailLoadingMap as argument.
*/
void QMapboxGL::setStyleJson(const QString &style)
{
@@ -296,7 +314,7 @@ void QMapboxGL::setStyleJson(const QString &style)
be fetched from anything that QNetworkAccessManager can handle.
\note In case of a invalid style it will trigger a mapChanged
- signal with QMapbox::MapChangeDidFailLoadingMap as argument.
+ signal with QMapboxGL::MapChangeDidFailLoadingMap as argument.
*/
void QMapboxGL::setStyleUrl(const QString &url)
{
@@ -370,7 +388,7 @@ void QMapboxGL::setCoordinateZoom(const Coordinate &coordinate_, double zoom_)
mbgl::LatLng { coordinate_.first, coordinate_.second }, zoom_, d_ptr->margins);
}
-void QMapboxGL::jumpTo(const CameraOptions& camera)
+void QMapboxGL::jumpTo(const QMapboxGLCameraOptions& camera)
{
mbgl::CameraOptions mbglCamera;
if (camera.center.isValid()) {
@@ -837,11 +855,11 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
static_cast<mbgl::ConstrainMode>(settings.constrainMode()),
static_cast<mbgl::ViewportMode>(settings.viewportMode())))
{
- qRegisterMetaType<QMapbox::MapChange>("QMapbox::MapChange");
+ qRegisterMetaType<QMapboxGL::MapChange>("QMapboxGL::MapChange");
fileSourceObj->setAccessToken(settings.accessToken().toStdString());
connect(this, SIGNAL(needsRendering()), q_ptr, SIGNAL(needsRendering()), Qt::QueuedConnection);
- connect(this, SIGNAL(mapChanged(QMapbox::MapChange)), q_ptr, SIGNAL(mapChanged(QMapbox::MapChange)), Qt::QueuedConnection);
+ connect(this, SIGNAL(mapChanged(QMapboxGL::MapChange)), q_ptr, SIGNAL(mapChanged(QMapboxGL::MapChange)), Qt::QueuedConnection);
connect(this, SIGNAL(copyrightsChanged(QString)), q_ptr, SIGNAL(copyrightsChanged(QString)), Qt::QueuedConnection);
}
@@ -888,7 +906,7 @@ void QMapboxGLPrivate::notifyMapChange(mbgl::MapChange change)
emit copyrightsChanged(QString::fromStdString(attribution));
}
- emit mapChanged(static_cast<QMapbox::MapChange>(change));
+ emit mapChanged(static_cast<QMapboxGL::MapChange>(change));
}
void QMapboxGLPrivate::connectionEstablished()
diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp
index bfa5b8c326..3d2be90273 100644
--- a/platform/qt/src/qmapboxgl_p.hpp
+++ b/platform/qt/src/qmapboxgl_p.hpp
@@ -50,6 +50,6 @@ public slots:
signals:
void needsRendering();
- void mapChanged(QMapbox::MapChange);
+ void mapChanged(QMapboxGL::MapChange);
void copyrightsChanged(const QString &copyrightsHtml);
};
diff --git a/platform/qt/src/qquickmapboxgl.cpp b/platform/qt/src/qquickmapboxgl.cpp
index 579bea72f2..7325bfe3c2 100644
--- a/platform/qt/src/qquickmapboxgl.cpp
+++ b/platform/qt/src/qquickmapboxgl.cpp
@@ -1,6 +1,5 @@
#include "qquickmapboxgl.hpp"
-#include "qmapbox.hpp"
#include "qquickmapboxglmapparameter.hpp"
#include "qquickmapboxglrenderer.hpp"
@@ -202,9 +201,9 @@ void QQuickMapboxGL::pan(int dx, int dy)
update();
}
-void QQuickMapboxGL::onMapChanged(QMapbox::MapChange change)
+void QQuickMapboxGL::onMapChanged(QMapboxGL::MapChange change)
{
- if (change == QMapbox::MapChangeDidFinishLoadingStyle) {
+ if (change == QMapboxGL::MapChangeDidFinishLoadingStyle) {
m_styleLoaded = true;
update();
}
diff --git a/platform/qt/src/qquickmapboxgl.hpp b/platform/qt/src/qquickmapboxgl.hpp
index 64cc41bf78..a6561d4bb4 100644
--- a/platform/qt/src/qquickmapboxgl.hpp
+++ b/platform/qt/src/qquickmapboxgl.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "qmapbox.hpp"
+#include "qmapboxgl.hpp"
#include "qquickmapboxglmapparameter.hpp"
#include <QColor>
@@ -98,7 +99,7 @@ public slots:
void setCenter(const QGeoCoordinate &center);
private slots:
- void onMapChanged(QMapbox::MapChange);
+ void onMapChanged(QMapboxGL::MapChange);
void onParameterPropertyUpdated(const QString &name);
private:
diff --git a/platform/qt/src/qquickmapboxglrenderer.cpp b/platform/qt/src/qquickmapboxglrenderer.cpp
index 880d7b2e40..69c22d35d7 100644
--- a/platform/qt/src/qquickmapboxglrenderer.cpp
+++ b/platform/qt/src/qquickmapboxglrenderer.cpp
@@ -46,7 +46,7 @@ void QQuickMapboxGLRenderer::synchronize(QQuickFramebufferObject *item)
auto quickMap = qobject_cast<QQuickMapboxGL*>(item);
if (!m_initialized) {
QObject::connect(m_map.data(), &QMapboxGL::needsRendering, quickMap, &QQuickMapboxGL::update);
- QObject::connect(m_map.data(), SIGNAL(mapChanged(QMapbox::MapChange)), quickMap, SLOT(onMapChanged(QMapbox::MapChange)));
+ QObject::connect(m_map.data(), SIGNAL(mapChanged(QMapboxGL::MapChange)), quickMap, SLOT(onMapChanged(QMapboxGL::MapChange)));
QObject::connect(this, &QQuickMapboxGLRenderer::centerChanged, quickMap, &QQuickMapboxGL::setCenter);
m_initialized = true;
}
diff --git a/platform/qt/test/qmapboxgl.cpp b/platform/qt/test/qmapboxgl.cpp
index 597aef5df3..9406fa2420 100644
--- a/platform/qt/test/qmapboxgl.cpp
+++ b/platform/qt/test/qmapboxgl.cpp
@@ -11,8 +11,8 @@ class QMapboxGLTest : public QObject, public ::testing::Test {
public:
QMapboxGLTest() : app(argc, const_cast<char**>(&argv)), map(nullptr, settings) {
- connect(&map, SIGNAL(mapChanged(QMapbox::MapChange)),
- this, SLOT(onMapChanged(QMapbox::MapChange)));
+ connect(&map, SIGNAL(mapChanged(QMapboxGL::MapChange)),
+ this, SLOT(onMapChanged(QMapboxGL::MapChange)));
connect(&map, SIGNAL(needsRendering()),
this, SLOT(onNeedsRendering()));
@@ -23,8 +23,8 @@ public:
map.setCoordinateZoom(QMapbox::Coordinate(60.170448, 24.942046), 14);
}
- void runUntil(QMapbox::MapChange status) {
- changeCallback = [&](QMapbox::MapChange change) {
+ void runUntil(QMapboxGL::MapChange status) {
+ changeCallback = [&](QMapboxGL::MapChange change) {
if (change == status) {
app.exit();
changeCallback = nullptr;
@@ -45,10 +45,10 @@ protected:
QMapboxGLSettings settings;
QMapboxGL map;
- std::function<void(QMapbox::MapChange)> changeCallback;
+ std::function<void(QMapboxGL::MapChange)> changeCallback;
private slots:
- void onMapChanged(QMapbox::MapChange change) {
+ void onMapChanged(QMapboxGL::MapChange change) {
if (changeCallback) {
changeCallback(change);
}
@@ -65,16 +65,16 @@ TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleJson)) {
map.setStyleJson(json);
ASSERT_EQ(map.styleJson(), json);
- runUntil(QMapbox::MapChangeDidFinishLoadingMap);
+ runUntil(QMapboxGL::MapChangeDidFinishLoadingMap);
map.setStyleJson("invalid json");
- runUntil(QMapbox::MapChangeDidFailLoadingMap);
+ runUntil(QMapboxGL::MapChangeDidFailLoadingMap);
map.setStyleJson("\"\"");
- runUntil(QMapbox::MapChangeDidFailLoadingMap);
+ runUntil(QMapboxGL::MapChangeDidFailLoadingMap);
map.setStyleJson(QString());
- runUntil(QMapbox::MapChangeDidFailLoadingMap);
+ runUntil(QMapboxGL::MapChangeDidFailLoadingMap);
}
TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleUrl)) {
@@ -82,13 +82,13 @@ TEST_F(QMapboxGLTest, TEST_DISABLED_ON_CI(styleUrl)) {
map.setStyleUrl(url);
ASSERT_EQ(map.styleUrl(), url);
- runUntil(QMapbox::MapChangeDidFinishLoadingMap);
+ runUntil(QMapboxGL::MapChangeDidFinishLoadingMap);
map.setStyleUrl("invalid://url");
- runUntil(QMapbox::MapChangeDidFailLoadingMap);
+ runUntil(QMapboxGL::MapChangeDidFailLoadingMap);
map.setStyleUrl(QString());
- runUntil(QMapbox::MapChangeDidFailLoadingMap);
+ runUntil(QMapboxGL::MapChangeDidFailLoadingMap);
}
#include "qmapboxgl.moc"