16#include <QCoreApplication>
17#include <QtCore/QFile>
18#include <QtCore/QJsonArray>
19#include <QtCore/QJsonDocument>
20#include <QtCore/QJsonObject>
21#include <QtCore/QRegularExpression>
22#include <QtCore/QStandardPaths>
23#include <QtCore/QUrlQuery>
24#include <QtNetwork/QNetworkProxy>
25#include <QtNetwork/QNetworkProxyFactory>
27#include <QtLocation/QPlace>
28#include <QtLocation/QPlaceContentRequest>
29#include <QtLocation/QPlaceDetailsReply>
30#include <QtLocation/QPlaceIcon>
31#include <QtLocation/QPlaceSearchRequest>
32#include <QtPositioning/QGeoCircle>
44 "administrative-areas-buildings\0"
45 "natural-geographical\0"
49 "hospital-health-care-facility\0"
50 "eat-drink|restaurant\0"
51 "eat-drink|coffee-tea\0"
52 "eat-drink|snacks-fast-food\0"
57 0, 10, 20, 35, 45, 59, 68, 84,
58 115, 136, 151, 169, 186, 216, 237, 258,
88 QHash<QString, QUrl> m_restIdToIconHash;
99 m_errorString.
clear();
105 if (document.isObject()) {
116 +
QStringLiteral(
"does not contain the offline_explore property");
141 const int maxLevel = 2;
155 for (
int i = 0;
i < children.
count(); ++
i) {
159 processCategory(
level + 1, childId,
id);
173 , m_manager(networkManager)
189 if (m_localDataPath.
isEmpty()) {
192 if (!dataLocations.isEmpty() && !dataLocations.first().isEmpty()) {
193 m_localDataPath = dataLocations.
first()
202 errorString->clear();
223 reply->setPlaceId(placeId);
225 this, &QPlaceManagerEngineNokiaV2::replyFinished);
227 this, &QPlaceManagerEngineNokiaV2::replyError);
236 if (
request.contentContext().userType() == qMetaTypeId<QUrl>()) {
239 networkReply = sendRequest(u);
247 switch (
request.contentType()) {
260 networkReply = sendRequest(requestUrl);
272 networkReply = sendRequest(requestUrl);
284 networkReply = sendRequest(requestUrl);
294 this, &QPlaceManagerEngineNokiaV2::replyFinished);
296 this, &QPlaceManagerEngineNokiaV2::replyError);
311 if (!center.isValid())
323 bool unsupported =
false;
329 unsupported |= !
query.searchTerm().isEmpty() && !
query.categories().isEmpty();
332 unsupported |= !
query.recommendationId().isEmpty()
333 && (!
query.searchTerm().isEmpty() || !
query.categories().isEmpty()
339 this, &QPlaceManagerEngineNokiaV2::replyFinished);
341 this, &QPlaceManagerEngineNokiaV2::replyError);
344 Q_ARG(
QString,
"Unsupported search request options specified."));
352 if (
query.recommendationId().isEmpty() && !
query.searchContext().isValid()) {
356 this, &QPlaceManagerEngineNokiaV2::replyFinished);
358 this, &QPlaceManagerEngineNokiaV2::replyError);
368 if (
query.searchContext().userType() == qMetaTypeId<QUrl>()) {
372 typedef QPair<QString, QString> QueryItem;
375 for (
const QueryItem &
item : queryItemList)
378 if (
query.limit() > 0)
383 networkReply = sendRequest(u);
384 }
else if (!
query.searchTerm().isEmpty()) {
392 if (
query.limit() > 0) {
403 this, &QPlaceManagerEngineNokiaV2::replyFinished);
405 this, &QPlaceManagerEngineNokiaV2::replyError);
408 }
else if (!
query.recommendationId().isEmpty()) {
417 networkReply = sendRequest(requestUrl);
436 if (
query.limit() > 0) {
443 networkReply = sendRequest(requestUrl);
448 this, &QPlaceManagerEngineNokiaV2::replyFinished);
450 this, &QPlaceManagerEngineNokiaV2::replyError);
457 bool unsupported =
false;
462 unsupported |= !
query.categories().isEmpty();
463 unsupported |= !
query.recommendationId().isEmpty();
468 this, &QPlaceManagerEngineNokiaV2::replyFinished);
470 this, &QPlaceManagerEngineNokiaV2::replyError);
473 Q_ARG(
QString,
"Unsupported search request options specified."));
487 this, &QPlaceManagerEngineNokiaV2::replyFinished);
489 this, &QPlaceManagerEngineNokiaV2::replyError);
502 this, &QPlaceManagerEngineNokiaV2::replyFinished);
504 this, &QPlaceManagerEngineNokiaV2::replyError);
512 return m_categoryReply.
data();
518 m_tempTree = parser.
tree();
526 int subCatDivider =
id.indexOf(
QChar(
'|'));
527 if (subCatDivider >= 0) {
529 const QString subCategoryId =
id.
mid(subCatDivider+1);
539 parent.childIds.append(subCategoryId);
540 m_tempTree.
insert(subCategoryId, node);
547 m_tempTree.
insert(
id, node);
564 this, &QPlaceManagerEngineNokiaV2::categoryReplyFinished);
566 this, &QPlaceManagerEngineNokiaV2::categoryReplyError);
568 m_categoryRequests.
insert(*
it, networkReply);
573 this, &QPlaceManagerEngineNokiaV2::replyFinished);
575 this, &QPlaceManagerEngineNokiaV2::replyError);
577 m_categoryReply =
reply;
615 const QList<QPlaceCategory> &
categories)
const
625 if (
match.hasMatch() && !
match.capturedView(1).isEmpty() && !
match.capturedView(2).isEmpty()) {
626 iconPrefix =
match.captured(1);
627 nokiaIcon =
match.captured(2);
646 if (!nokiaIcon.isEmpty()) {
668 if (!nokiaIcon.isEmpty()) {
684void QPlaceManagerEngineNokiaV2::replyFinished()
698void QPlaceManagerEngineNokiaV2::categoryReplyFinished()
709 if (m_categoryReply) {
720 if (m_tempTree.
contains(categoryId)) {
726 m_tempTree.
insert(categoryId, node);
729 categoryId = m_categoryRequests.
key(
reply);
731 rootNode.
childIds.removeAll(categoryId);
733 m_tempTree.
remove(categoryId);
736 m_categoryRequests.
remove(categoryId);
739 if (m_categoryRequests.
isEmpty()) {
740 m_categoryTree = m_tempTree;
748void QPlaceManagerEngineNokiaV2::categoryReplyError()
750 if (m_categoryReply) {
774QByteArray QPlaceManagerEngineNokiaV2::createLanguageString()
const
778 QList<QLocale>
locales = m_locales;
bool parse(const QString &fileName)
QHash< QString, QUrl > restIdToIconHash() const
QString errorString() const
QPlaceCategoryTree tree() const
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual QNetworkReply * get(const QNetworkRequest &request)=0
Error
Describes an error related to the loading and setup of a service provider plugin.
QString getCurrentHost() const
bool remove(const Key &key)
Removes the item that has the key from the hash.
Key key(const T &value) const noexcept
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
\inmodule QtCore\reentrant
qsizetype count() const
Same as size().
QJsonValue at(qsizetype i) const
Returns a QJsonValue representing the value for index i.
\inmodule QtCore\reentrant
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
QJsonValue value(const QString &key) const
Returns a QJsonValue representing the value for the key key.
bool contains(const QString &key) const
Returns true if the object contains key key.
QJsonObject toObject() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString toString() const
Converts the value to a QString and returns it.
bool isEmpty() const noexcept
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
size_type remove(const Key &key)
key_iterator keyBegin() const
key_iterator keyEnd() const
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
void errorOccurred(QNetworkReply::NetworkError)
NetworkError error() const
Returns the error that was found during the processing of this request.
void finished()
This signal is emitted when the reply has finished processing.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
void setRawHeader(const QByteArray &headerName, const QByteArray &value)
Sets the header headerName to be of value headerValue.
void setUrl(const QUrl &url)
Sets the URL this network request is referring to be url.
QObject * parent() const
Returns a pointer to the parent object.
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...
void setParent(QObject *parent)
Makes the object a child of parent.
void deleteLater()
\threadsafe
void setCategoryId(const QString &identifier)
Sets the identifier of the category.
QString categoryId() const
Returns the identifier of the category.
void setIcon(const QPlaceIcon &icon)
Sets the icon of the category.
void setName(const QString &name)
Sets the name of the category.
static const QString SingleUrl
\qmlvaluetype icon \inqmlmodule QtLocation
QPlaceContentReply * getPlaceContent(const QPlaceContentRequest &request) override
Retrieves content for a place according to the parameters specified in request.
QStringList childCategoryIds(const QString &categoryId) const override
Returns the child category identifiers of the category corresponding to categoryId.
QString parentCategoryId(const QString &categoryId) const override
Returns the parent category identifier of the category corresponding to categoryId.
QPlaceSearchSuggestionReply * searchSuggestions(const QPlaceSearchRequest &query) override
Requests a set of search term suggestions according to the parameters specified in request.
QPlaceReply * initializeCategories() override
Initializes the categories of the manager engine.
QPlaceManagerEngineNokiaV2(QGeoNetworkAccessManager *networkManager, const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString)
QPlaceDetailsReply * getPlaceDetails(const QString &placeId) override
Retrieves details of place corresponding to the given placeId.
QList< QPlaceCategory > childCategories(const QString &parentId) const override
Returns a list of categories that are children of the category corresponding to parentId.
QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size) const override
QUrl QPlaceManagerEngine::constructIconUrl(const QPlaceIcon &icon, const QSize &size)
QPlaceSearchReply * search(const QPlaceSearchRequest &query) override
Searches for places according to the parameters specified in request.
void setLocales(const QList< QLocale > &locales) override
Set the list of preferred locales.
QList< QLocale > locales() const override
Returns a list of preferred locales.
QPlaceCategory category(const QString &categoryId) const override
Returns the category corresponding to the given categoryId.
QPlaceIcon icon(const QString &remotePath, const QList< QPlaceCategory > &categories=QList< QPlaceCategory >()) const
~QPlaceManagerEngineNokiaV2()
void finished(QPlaceReply *reply)
This signal is emitted when reply has finished processing.
QPlaceManager * manager() const
Returns the manager instance used to create this engine.
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.
T * data() const noexcept
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
static QStringList standardLocations(StandardLocation type)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
QString first(qsizetype n) const &
QString & insert(qsizetype i, QChar c)
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.
QList< std::pair< QString, QString > > queryItems(QUrl::ComponentFormattingOptions encoding=QUrl::PrettyDecoded) const
Returns the query string of the URL, as a map of keys and values, using the options specified in enco...
void setQuery(const QString &query, ParsingMode mode=TolerantMode)
Sets the query string of the URL to query.
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
const QLoggingCategory & category()
[1]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
emscripten::val document()
DBusConnection const char DBusError * error
QT_BEGIN_NAMESPACE const char NOKIA_PLUGIN_CONTEXT_NAME[]
const char NETWORK_ERROR[]
static int area(const QSize &s)
#define Q_ARG(Type, data)
GLenum GLuint GLint level
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint * ids
GLsizei GLenum * categories
GLsizei const GLchar *const * path
static QT_BEGIN_NAMESPACE const char FIXED_CATEGORIES_string[]
static bool addAtForBoundingArea(const QGeoShape &area, QUrlQuery *queryItems)
static const int FIXED_CATEGORIES_indices[]
static const char *const NokiaIconGenerated
static const char *const IconThemeKey
static const char *const NokiaIcon
static const char *const LocalDataPathKey
static const char *const IconPrefix
#define QStringLiteral(str)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
QUrl url("example.com")
[constructor-url-reference]
QNetworkRequest request(url)
char * toString(const MyType &t)
[31]
\inmodule QtCore \reentrant
const QString PLACES_HOST