diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-08-25 14:22:16 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-08-28 12:46:07 +0000 |
commit | fd3ea87861b281a54c1888a0a044517cf86f9692 (patch) | |
tree | 41b79f1944943165f5fa3632e9850cf5d24f6645 /src/imports/location | |
parent | 7b9390bd139c8e6314bcf3167f3d0538b9f7708b (diff) | |
download | qtlocation-fd3ea87861b281a54c1888a0a044517cf86f9692.tar.gz |
Update Error enums for GeoCode & Route model types
1.) Remove not required/duplicated enums
2.) Add docs for new enum values
3.) Sorted the enums by alphabet (except for NoErrror)
4.) Other minor spelling corrections
5.) Update and expand tests
Change-Id: I83bf9e5e40f1237ead45320d020b315b39442946
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'src/imports/location')
-rw-r--r-- | src/imports/location/plugins.qmltypes | 12 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeocodemodel.cpp | 43 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeocodemodel_p.h | 17 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeomap.cpp | 3 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeoroutemodel.cpp | 41 | ||||
-rw-r--r-- | src/imports/location/qdeclarativegeoroutemodel_p.h | 11 |
6 files changed, 78 insertions, 49 deletions
diff --git a/src/imports/location/plugins.qmltypes b/src/imports/location/plugins.qmltypes index 3871feaa..105e8713 100644 --- a/src/imports/location/plugins.qmltypes +++ b/src/imports/location/plugins.qmltypes @@ -577,10 +577,8 @@ Module { "ParseError": 3, "UnsupportedOptionError": 4, "UnknownError": 5, - "NotSupportedError": 101, - "UnknownParameterError": 102, - "MissingRequiredParameterError": 103, - "ConnectionError": 104 + "UnknownParameterError": 100, + "MissingRequiredParameterError": 101 } } Property { name: "plugin"; type: "QDeclarativeGeoServiceProvider"; isPointer: true } @@ -984,10 +982,8 @@ Module { "UnsupportedOptionError": 4, "CombinationError": 5, "UnknownError": 6, - "NotSupportedError": 101, - "UnknownParameterError": 102, - "MissingRequiredParameterError": 103, - "ConnectionError": 104 + "UnknownParameterError": 100, + "MissingRequiredParameterError": 101 } } Property { name: "plugin"; type: "QDeclarativeGeoServiceProvider"; isPointer: true } diff --git a/src/imports/location/qdeclarativegeocodemodel.cpp b/src/imports/location/qdeclarativegeocodemodel.cpp index d2599747..d8ff4e85 100644 --- a/src/imports/location/qdeclarativegeocodemodel.cpp +++ b/src/imports/location/qdeclarativegeocodemodel.cpp @@ -150,7 +150,7 @@ void QDeclarativeGeocodeModel::update() return; if (!plugin_) { - setError(NotSupportedError, tr("Cannot geocode, plugin not set.")); + setError(EngineNotSetError, tr("Cannot geocode, plugin not set.")); return; } @@ -160,7 +160,7 @@ void QDeclarativeGeocodeModel::update() QGeoCodingManager *geocodingManager = serviceProvider->geocodingManager(); if (!geocodingManager) { - setError(NotSupportedError, tr("Cannot geocode, geocode manager not set.")); + setError(EngineNotSetError, tr("Cannot geocode, geocode manager not set.")); return; } if (!coordinate_.isValid() && (!address_ || address_->address().isEmpty()) && @@ -292,13 +292,26 @@ void QDeclarativeGeocodeModel::pluginReady() QGeoCodingManager *geocodingManager = serviceProvider->geocodingManager(); if (serviceProvider->error() != QGeoServiceProvider::NoError) { - setError(GeocodeError(serviceProvider->error() + NotSupportedError - 1), - serviceProvider->errorString()); + QDeclarativeGeocodeModel::GeocodeError newError = UnknownError; + switch (serviceProvider->error()) { + case QGeoServiceProvider::NotSupportedError: + newError = EngineNotSetError; break; + case QGeoServiceProvider::UnknownParameterError: + newError = UnknownParameterError; break; + case QGeoServiceProvider::MissingRequiredParameterError: + newError = MissingRequiredParameterError; break; + case QGeoServiceProvider::ConnectionError: + newError = CommunicationError; break; + default: + break; + } + + setError(newError, serviceProvider->errorString()); return; } if (!geocodingManager) { - setError(NotSupportedError,tr("Plugin does not support (reverse) geocoding.")); + setError(EngineNotSetError,tr("Plugin does not support (reverse) geocoding.")); return; } @@ -432,13 +445,17 @@ void QDeclarativeGeocodeModel::setStatus(QDeclarativeGeocodeModel::Status status This read-only property holds the latest error value of the geocoding request. \list - \li GeocodeModel.NoError - No error has occurred - \li GeocodeModel.EngineNotSetError - The plugin/service provider used does not support (reverse) geocoding - \li GeocodeModel.CommunicationError - An error occurred while communicating with the service provider - \li GeocodeModel.ParseError - The response from the service provider was in an unrecognizable format - \li GeocodeModel.UnsupportedOptionError - The requested operation or one of the options for the operation are not supported by the service provider. - \li GeocodeModel.CombinationError - An error occurred while results where being combined from multiple sources - \li GeocodeModel.UnknownError - An error occurred which does not fit into any of the other categories + \li GeocodeModel.NoError - No error has occurred. + \li GeocodeModel.CombinationError - An error occurred while results where being combined from multiple sources. + \li GeocodeModel.CommunicationError - An error occurred while communicating with the service provider. + \li GeocodeModel.EngineNotSetError - The model's plugin property was not set or there is no geocoding manager associated with the plugin. + \li GeocodeModel.MissingRequiredParameterError - A required parameter was not specified. + \li GeocodeModel.ParseError - The response from the service provider was in an unrecognizable format. + \li GeocodeModel.UnknownError - An error occurred which does not fit into any of the other categories. + \li GeocodeModel.UnknownParameterError - The plugin did not recognize one of the parameters it was given. + \li GeocodeModel.UnsupportedOptionError - The requested operation is not supported by the geocoding provider. + This may happen when the loaded engine does not support a particular geocoding request + such as reverse geocoding. \endlist */ @@ -512,7 +529,7 @@ int QDeclarativeGeocodeModel::count() const QDeclarativeGeoLocation *QDeclarativeGeocodeModel::get(int index) { if (index < 0 || index >= declarativeLocations_.count()) { - setError(UnsupportedOptionError, QCoreApplication::translate(CONTEXT_NAME, INDEX_OUT_OF_RANGE).arg(index)); + qmlInfo(this) << QStringLiteral("Index '%1' out of range").arg(index); return 0; } return declarativeLocations_.at(index); diff --git a/src/imports/location/qdeclarativegeocodemodel_p.h b/src/imports/location/qdeclarativegeocodemodel_p.h index 5d6b27a7..cb610bb0 100644 --- a/src/imports/location/qdeclarativegeocodemodel_p.h +++ b/src/imports/location/qdeclarativegeocodemodel_p.h @@ -82,18 +82,17 @@ public: enum GeocodeError { NoError = QGeoCodeReply::NoError, - EngineNotSetError = QGeoCodeReply::EngineNotSetError, - CommunicationError = QGeoCodeReply::CommunicationError, + EngineNotSetError = QGeoCodeReply::EngineNotSetError, //TODO Qt6 consider merge with NotSupportedError + CommunicationError = QGeoCodeReply::CommunicationError, //TODO Qt6 merge with Map's ConnectionError ParseError = QGeoCodeReply::ParseError, - UnsupportedOptionError = QGeoCodeReply::UnsupportedOptionError, + UnsupportedOptionError = QGeoCodeReply::UnsupportedOptionError, //TODO Qt6 consider rename UnsupportedOperationError CombinationError = QGeoCodeReply::CombinationError, UnknownError = QGeoCodeReply::UnknownError, - //here we leave gap for future model errors - //now geo service provider errors - NotSupportedError = 100 + QGeoServiceProvider::NotSupportedError, - UnknownParameterError = 100 + QGeoServiceProvider::UnknownParameterError, - MissingRequiredParameterError = 100 + QGeoServiceProvider::MissingRequiredParameterError, - ConnectionError = 100 + QGeoServiceProvider::ConnectionError + //we leave gap for future QGeoCodeReply errors + + //QGeoServiceProvider related errors start here + UnknownParameterError = 100, + MissingRequiredParameterError }; enum Roles { diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp index cf492977..87023708 100644 --- a/src/imports/location/qdeclarativegeomap.cpp +++ b/src/imports/location/qdeclarativegeomap.cpp @@ -283,6 +283,7 @@ void QDeclarativeGeoMap::pluginReady() } if (!m_mappingManager) { + //TODO Should really be EngineNotSetError (see QML GeoCodeModel) setError(QGeoServiceProvider::NotSupportedError, tr("Plugin does not support mapping.")); return; } @@ -917,7 +918,7 @@ QString QDeclarativeGeoMap::errorString() const \list \li Map.NoError - No error has occurred. - \li Map.NotSupportedError -The plugin does not support mapping functionality. + \li Map.NotSupportedError -The maps plugin property was not set or there is no mapping manager associated with the plugin. \li Map.UnknownParameterError -The plugin did not recognize one of the parameters it was given. \li Map.MissingRequiredParameterError - The plugin did not find one of the parameters it was expecting. \li Map.ConnectionError - The plugin could not connect to its backend service or database. diff --git a/src/imports/location/qdeclarativegeoroutemodel.cpp b/src/imports/location/qdeclarativegeoroutemodel.cpp index 87023c15..0c64c23a 100644 --- a/src/imports/location/qdeclarativegeoroutemodel.cpp +++ b/src/imports/location/qdeclarativegeoroutemodel.cpp @@ -212,7 +212,7 @@ void QDeclarativeGeoRouteModel::abortRequest() QDeclarativeGeoRoute *QDeclarativeGeoRouteModel::get(int index) { if (index < 0 || index >= routes_.count()) { - setError(UnsupportedOptionError, QCoreApplication::translate(CONTEXT_NAME, INDEX_OUT_OF_RANGE).arg(index)); + qmlInfo(this) << QStringLiteral("Index '%1' out of range").arg(index); return 0; } return routes_.at(index); @@ -307,13 +307,26 @@ void QDeclarativeGeoRouteModel::pluginReady() QGeoRoutingManager *routingManager = serviceProvider->routingManager(); if (serviceProvider->error() != QGeoServiceProvider::NoError) { - setError(RouteError(serviceProvider->error() + NotSupportedError -1), - serviceProvider->errorString()); + QDeclarativeGeoRouteModel::RouteError newError = UnknownError; + switch (serviceProvider->error()) { + case QGeoServiceProvider::NotSupportedError: + newError = EngineNotSetError; break; + case QGeoServiceProvider::UnknownParameterError: + newError = UnknownParameterError; break; + case QGeoServiceProvider::MissingRequiredParameterError: + newError = MissingRequiredParameterError; break; + case QGeoServiceProvider::ConnectionError: + newError = CommunicationError; break; + default: + break; + } + + setError(newError, serviceProvider->errorString()); return; } if (!routingManager) { - setError(NotSupportedError, tr("Plugin does not support routing.")); + setError(EngineNotSetError, tr("Plugin does not support routing.")); return; } @@ -519,12 +532,16 @@ QString QDeclarativeGeoRouteModel::errorString() const This read-only property holds the latest error value of the routing request. \list - \li RouteModel.NoError - No error has occurred - \li RouteModel.EngineNotSetError - The plugin/service provider used does not support routing - \li RouteModel.CommunicationError - An error occurred while communicating with the service provider - \li RouteModel.ParseError - The response from the service provider was in an unrecognizable format - \li RouteModel.UnsupportedOptionError - The requested operation or one of the options for the operation are not supported by the service provider. - \li RouteModel.UnknownError - An error occurred which does not fit into any of the other categories + \li RouteModel.NoError - No error has occurred. + \li RouteModel.CommunicationError - An error occurred while communicating with the service provider. + \li RouteModel.EngineNotSetError - The model's plugin property was not set or there is no routing manager associated with the plugin. + \li RouteModel.MissingRequiredParameterError - A required parameter was not specified. + \li RouteModel.ParseError - The response from the service provider was in an unrecognizable format. + \li RouteModel.UnknownError - An error occurred which does not fit into any of the other categories. + \li RouteModel.UnknownParameterError - The plugin did not recognize one of the parameters it was given. + \li RouteModel.UnsupportedOptionError - The requested operation is not supported by the routing provider. + This may happen when the loaded engine does not support a particular + type of routing request. \endlist */ @@ -555,7 +572,7 @@ void QDeclarativeGeoRouteModel::update() return; if (!plugin_) { - setError(NotSupportedError, tr("Cannot route, plugin not set.")); + setError(EngineNotSetError, tr("Cannot route, plugin not set.")); return; } @@ -565,7 +582,7 @@ void QDeclarativeGeoRouteModel::update() QGeoRoutingManager *routingManager = serviceProvider->routingManager(); if (!routingManager) { - setError(NotSupportedError, tr("Cannot route, route manager not set.")); + setError(EngineNotSetError, tr("Cannot route, route manager not set.")); return; } if (!routeQuery_) { diff --git a/src/imports/location/qdeclarativegeoroutemodel_p.h b/src/imports/location/qdeclarativegeoroutemodel_p.h index 363c3bc5..35cfe004 100644 --- a/src/imports/location/qdeclarativegeoroutemodel_p.h +++ b/src/imports/location/qdeclarativegeoroutemodel_p.h @@ -95,12 +95,11 @@ public: ParseError = QGeoRouteReply::ParseError, UnsupportedOptionError = QGeoRouteReply::UnsupportedOptionError, UnknownError = QGeoRouteReply::UnknownError, - //here we leave gap for future model errors - //now geo service provider errors - NotSupportedError = 100 + QGeoServiceProvider::NotSupportedError, - UnknownParameterError = 100 + QGeoServiceProvider::UnknownParameterError, - MissingRequiredParameterError = 100 + QGeoServiceProvider::MissingRequiredParameterError, - ConnectionError = 100 + QGeoServiceProvider::ConnectionError + //we leave gap for future QGeoRouteReply errors + + //QGeoServiceProvider related errors start here + UnknownParameterError = 100, + MissingRequiredParameterError }; explicit QDeclarativeGeoRouteModel(QObject *parent = 0); |