summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-09-26 11:37:26 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-09-26 11:47:34 +0200
commit9eb33d6669dd2d1c5d3b2590108796df85317fd0 (patch)
tree2ddf30cc14a129ac756f6d67a7e5c4081a79840f /platform/qt
parent5a12539d34976dd68186c70c3b69fcad8156d0a6 (diff)
downloadqtlocation-mapboxgl-9eb33d6669dd2d1c5d3b2590108796df85317fd0.tar.gz
[Qt] Implement QQuickMapboxGL::error{,String} properties
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/include/qquickmapboxgl.hpp5
-rw-r--r--platform/qt/src/qquickmapboxgl.cpp32
2 files changed, 25 insertions, 12 deletions
diff --git a/platform/qt/include/qquickmapboxgl.hpp b/platform/qt/include/qquickmapboxgl.hpp
index 419d5328b5..44878c246e 100644
--- a/platform/qt/include/qquickmapboxgl.hpp
+++ b/platform/qt/include/qquickmapboxgl.hpp
@@ -88,10 +88,10 @@ signals:
void zoomLevelChanged(qreal zoomLevel);
void centerChanged(const QGeoCoordinate &coordinate);
void colorChanged(const QColor &color);
+ void errorChanged();
// Compatibility with Map QML Type, but no-op.
void pluginChanged(QDeclarativeGeoServiceProvider *plugin);
- void errorChanged();
void copyrightLinkActivated(const QString &link);
void copyrightsVisibleChanged(bool visible);
@@ -163,6 +163,9 @@ private:
QList<QVariantMap> m_filterChanges;
QList<QQuickMapboxGLMapParameter*> m_parameters;
+ QGeoServiceProvider::Error m_error = QGeoServiceProvider::NoError;
+ QString m_errorString;
+
qreal m_bearing = 0;
qreal m_pitch = 0;
diff --git a/platform/qt/src/qquickmapboxgl.cpp b/platform/qt/src/qquickmapboxgl.cpp
index 8d91085f46..f71f869c9c 100644
--- a/platform/qt/src/qquickmapboxgl.cpp
+++ b/platform/qt/src/qquickmapboxgl.cpp
@@ -40,8 +40,9 @@ QQuickFramebufferObject::Renderer *QQuickMapboxGL::createRenderer() const
void QQuickMapboxGL::setPlugin(QDeclarativeGeoServiceProvider *)
{
- qWarning() << __PRETTY_FUNCTION__
- << "Not implemented.";
+ m_error = QGeoServiceProvider::NotSupportedError;
+ m_errorString = "QQuickMapboxGL does not support plugins.";
+ emit errorChanged();
}
QDeclarativeGeoServiceProvider *QQuickMapboxGL::plugin() const
@@ -141,12 +142,12 @@ QGeoCoordinate QQuickMapboxGL::center() const
QGeoServiceProvider::Error QQuickMapboxGL::error() const
{
- return QGeoServiceProvider::NoError;
+ return m_error;
}
QString QQuickMapboxGL::errorString() const
{
- return QString();
+ return m_errorString;
}
void QQuickMapboxGL::setVisibleRegion(const QGeoShape &shape)
@@ -161,8 +162,7 @@ QGeoShape QQuickMapboxGL::visibleRegion() const
void QQuickMapboxGL::setCopyrightsVisible(bool)
{
- qWarning() << __PRETTY_FUNCTION__
- << "Not implemented.";
+ qWarning() << Q_FUNC_INFO << "Not implemented.";
}
bool QQuickMapboxGL::copyrightsVisible() const
@@ -296,7 +296,9 @@ bool QQuickMapboxGL::parseStyleSource(QQuickMapboxGLMapParameter *param)
source["data"] = geojson.readAll();
m_sourceChanges << source;
} else {
- qWarning() << "Error: Unsupported source type '" << sourceType << "'.";
+ m_error = QGeoServiceProvider::UnknownParameterError;
+ m_errorString = "Invalid source type: " + sourceType;
+ emit errorChanged();
return false;
}
return true;
@@ -337,7 +339,9 @@ void QQuickMapboxGL::processMapParameter(QQuickMapboxGLMapParameter *param)
bool needsUpdate = false;
switch (s_parameterTypes.indexOf(param->property("type").toString())) {
case -1:
- qWarning() << "Error: Invalid value for property 'type'.";
+ m_error = QGeoServiceProvider::UnknownParameterError;
+ m_errorString = "Invalid value for property 'type': " + param->property("type").toString();
+ emit errorChanged();
break;
case 0: // style
needsUpdate |= parseStyle(param);
@@ -374,19 +378,25 @@ void QQuickMapboxGL::onParameterPropertyUpdated(const QString &propertyName)
{
QQuickMapboxGLMapParameter *param = qobject_cast<QQuickMapboxGLMapParameter *>(sender());
if (!param) {
- qWarning() << "Warning: Sender for QQuickMapboxGL::onParameterPropertyUpdated is not a QQuickMapboxGLMapParameter.";
+ m_error = QGeoServiceProvider::NotSupportedError;
+ m_errorString = "QQuickMapboxGL::onParameterPropertyUpdated should be called from a QQuickMapboxGLMapParameter.";
+ emit errorChanged();
return;
}
if (propertyName == "type") {
- qWarning() << "Error: Cannot modify property 'type'.";
+ m_error = QGeoServiceProvider::NotSupportedError;
+ m_errorString = "Property 'type' is a write-once.";
+ emit errorChanged();
return;
}
bool needsUpdate = false;
switch (s_parameterTypes.indexOf(param->property("type").toString())) {
case -1:
- qWarning() << "Error: Invalid value for property 'type'.";
+ m_error = QGeoServiceProvider::UnknownParameterError;
+ m_errorString = "Invalid value for property 'type': " + param->property("type").toString();
+ emit errorChanged();
break;
case 0: // style
needsUpdate |= parseStyle(param);