summaryrefslogtreecommitdiffstats
path: root/src/imports/location/qdeclarativegeocodemodel.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-08-25 14:22:16 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-08-28 12:46:07 +0000
commitfd3ea87861b281a54c1888a0a044517cf86f9692 (patch)
tree41b79f1944943165f5fa3632e9850cf5d24f6645 /src/imports/location/qdeclarativegeocodemodel.cpp
parent7b9390bd139c8e6314bcf3167f3d0538b9f7708b (diff)
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/qdeclarativegeocodemodel.cpp')
-rw-r--r--src/imports/location/qdeclarativegeocodemodel.cpp43
1 files changed, 30 insertions, 13 deletions
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);