10#include <QtCore/QUrlQuery>
11#include <QtCore/QXmlStreamReader>
12#include <QtCore/QRegularExpression>
13#include <QtNetwork/QNetworkAccessManager>
14#include <QtNetwork/QNetworkRequest>
15#include <QtNetwork/QNetworkReply>
16#include <QtPositioning/QGeoCircle>
17#include <QtLocation/QPlaceCategory>
18#include <QtLocation/QPlaceSearchRequest>
19#include <QtLocation/private/unsupportedreplies_p.h>
21#include <QtCore/QElapsedTimer>
81 return qobject_cast<QPlaceSearchReply *>(doSearch(
request, PlaceSearchType::CompleteSearch));
86 return qobject_cast<QPlaceSearchSuggestionReply *>(doSearch(
request, PlaceSearchType::SuggestionSearch));
96 bool invalidRequest =
false;
108 if (invalidRequest) {
110 if (searchType == PlaceSearchType::CompleteSearch)
116 this, &QPlaceManagerEngineMapbox::onReplyFinished);
118 this, &QPlaceManagerEngineMapbox::onReplyError);
129 queryString = searchTerm;
130 }
else if (!recommendationId.
isEmpty()) {
131 queryString = recommendationId;
135 similarIds.
append(placeCategory.categoryId());
141 QUrl requestUrl(m_urlPrefix + queryString);
149 for (
const QLocale& locale:
std::as_const(m_locales)) {
159 if (!languageCodes.contains(languageCode))
160 languageCodes.append(languageCode);
163 if (!languageCodes.isEmpty())
190 requestUrl.setQuery(queryItems);
197 if (searchType == PlaceSearchType::CompleteSearch)
203 this, &QPlaceManagerEngineMapbox::onReplyFinished);
205 this, &QPlaceManagerEngineMapbox::onReplyError);
218 m_categories[categoryId] =
category;
224 this, &QPlaceManagerEngineMapbox::onReplyFinished);
226 this, &QPlaceManagerEngineMapbox::onReplyError);
246 return m_categories.
keys();
253 return m_categories.
value(categoryId);
260 return m_categories.
values();
275void QPlaceManagerEngineMapbox::onReplyFinished()
double longitude
This property holds the longitude in decimal degrees.
double latitude
This property holds the latitude in decimal degrees.
QGeoCoordinate topLeft
This property holds the top left coordinate of this geo rectangle.
QGeoCoordinate bottomRight
This property holds the bottom right coordinate of this geo rectangle.
Error
Describes an error related to the loading and setup of a service provider plugin.
ShapeType type
This property holds the type of this geo shape.
Q_INVOKABLE QGeoRectangle boundingGeoRectangle() const
Returns a QGeoRectangle representing the geographical bounding rectangle of the geo shape,...
bool isEmpty
This property defines whether this geo shape is empty.
QList< T > values() const
Returns a list containing all the values in the hash, in an arbitrary order.
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
T value(const Key &key) const noexcept
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
bool isEmpty() const noexcept
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
static QString mapboxNameForCategory(const QString &category)
The QNetworkAccessManager class allows the application to send network requests and receive replies.
QNetworkReply * get(const QNetworkRequest &request)
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object o...
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
QPlaceReply * initializeCategories() override
Initializes the categories of the manager engine.
QStringList childCategoryIds(const QString &categoryId) const override
Returns the child category identifiers of the category corresponding to categoryId.
QList< QLocale > locales() const override
Returns a list of preferred locales.
QPlaceManagerEngineMapbox(const QVariantMap ¶meters, QGeoServiceProvider::Error *, QString *errorString)
~QPlaceManagerEngineMapbox()
QPlaceSearchReply * search(const QPlaceSearchRequest &) override
Searches for places according to the parameters specified in request.
QList< QPlaceCategory > childCategories(const QString &parentId) const override
Returns a list of categories that are children of the category corresponding to parentId.
QString parentCategoryId(const QString &categoryId) const override
Returns the parent category identifier of the category corresponding to categoryId.
void setLocales(const QList< QLocale > &locales) override
Set the list of preferred locales.
QPlaceCategory category(const QString &categoryId) const override
Returns the category corresponding to the given categoryId.
QPlaceSearchSuggestionReply * searchSuggestions(const QPlaceSearchRequest &) override
Requests a set of search term suggestions according to the parameters specified in request.
void finished(QPlaceReply *reply)
This signal is emitted when reply has finished processing.
void errorOccurred(QPlaceReply *, QPlaceReply::Error error, const QString &errorString=QString())
This signal is emitted when an error has been detected in the processing of reply.
void errorOccurred(QPlaceReply::Error error, const QString &errorString=QString())
This signal is emitted when an error has been detected in the processing of this reply.
void finished()
This signal is emitted when this reply has finished processing.
Error
Describes an error which occurred during an operation.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
void clear()
Clears the contents of the string and makes it null.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
void addQueryItem(const QString &key, const QString &value)
Appends the pair key = value to the end of the query string of the URL.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
const QLoggingCategory & category()
[1]
list append(new Employee("Blackpool", "Stephen"))
Q_QML_PRIVATE_EXPORT QV4::ReturnedValue locale(QV4::ExecutionEngine *engine, const QString &localeName)
Provides locale specific properties and formatted data.
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
DBusConnection const char DBusError * error
static const QByteArray mapboxDefaultUserAgent
static const QString mapboxGeocodingApiPath
static const QString mapboxGeocodingEnterpriseApiPath
#define Q_ARG(Type, data)
GLsizei GLenum * categories
#define QStringLiteral(str)
QNetworkRequest request(url)
\inmodule QtCore \reentrant