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,
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)
190 if (m_localDataPath.
isEmpty()) {
193 if (!dataLocations.isEmpty() && !dataLocations.first().isEmpty()) {
194 m_localDataPath = dataLocations.first()
203 errorString->
clear();
224 reply->setPlaceId(placeId);
226 this, &QPlaceManagerEngineNokiaV2::replyFinished);
228 this, &QPlaceManagerEngineNokiaV2::replyError);
237 if (
request.contentContext().userType() == qMetaTypeId<QUrl>()) {
240 networkReply = sendRequest(u);
248 switch (
request.contentType()) {
261 networkReply = sendRequest(requestUrl);
273 networkReply = sendRequest(requestUrl);
285 networkReply = sendRequest(requestUrl);
295 this, &QPlaceManagerEngineNokiaV2::replyFinished);
297 this, &QPlaceManagerEngineNokiaV2::replyError);
312 if (!center.isValid())
324 bool unsupported =
false;
330 unsupported |= !
query.searchTerm().isEmpty() && !
query.categories().isEmpty();
333 unsupported |= !
query.recommendationId().isEmpty()
334 && (!
query.searchTerm().isEmpty() || !
query.categories().isEmpty()
340 this, &QPlaceManagerEngineNokiaV2::replyFinished);
342 this, &QPlaceManagerEngineNokiaV2::replyError);
345 Q_ARG(
QString,
"Unsupported search request options specified."));
353 if (
query.recommendationId().isEmpty() && !
query.searchContext().isValid()) {
357 this, &QPlaceManagerEngineNokiaV2::replyFinished);
359 this, &QPlaceManagerEngineNokiaV2::replyError);
369 if (
query.searchContext().userType() == qMetaTypeId<QUrl>()) {
376 for (
const QueryItem &
item : queryItemList)
379 if (
query.limit() > 0)
384 networkReply = sendRequest(u);
385 }
else if (!
query.searchTerm().isEmpty()) {
393 if (
query.limit() > 0) {
404 this, &QPlaceManagerEngineNokiaV2::replyFinished);
406 this, &QPlaceManagerEngineNokiaV2::replyError);
409 }
else if (!
query.recommendationId().isEmpty()) {
418 networkReply = sendRequest(requestUrl);
437 if (
query.limit() > 0) {
444 networkReply = sendRequest(requestUrl);
449 this, &QPlaceManagerEngineNokiaV2::replyFinished);
451 this, &QPlaceManagerEngineNokiaV2::replyError);
458 bool unsupported =
false;
463 unsupported |= !
query.categories().isEmpty();
464 unsupported |= !
query.recommendationId().isEmpty();
469 this, &QPlaceManagerEngineNokiaV2::replyFinished);
471 this, &QPlaceManagerEngineNokiaV2::replyError);
474 Q_ARG(
QString,
"Unsupported search request options specified."));
488 this, &QPlaceManagerEngineNokiaV2::replyFinished);
490 this, &QPlaceManagerEngineNokiaV2::replyError);
503 this, &QPlaceManagerEngineNokiaV2::replyFinished);
505 this, &QPlaceManagerEngineNokiaV2::replyError);
513 return m_categoryReply.
data();
519 m_tempTree = parser.
tree();
527 int subCatDivider =
id.indexOf(
QChar(
'|'));
528 if (subCatDivider >= 0) {
530 const QString subCategoryId =
id.
mid(subCatDivider+1);
540 parent.childIds.append(subCategoryId);
541 m_tempTree.
insert(subCategoryId, node);
548 m_tempTree.
insert(
id, node);
565 this, &QPlaceManagerEngineNokiaV2::categoryReplyFinished);
567 this, &QPlaceManagerEngineNokiaV2::categoryReplyError);
569 m_categoryRequests.
insert(*
it, networkReply);
574 this, &QPlaceManagerEngineNokiaV2::replyFinished);
576 this, &QPlaceManagerEngineNokiaV2::replyError);
578 m_categoryReply =
reply;
626 if (
match.hasMatch() && !
match.capturedView(1).isEmpty() && !
match.capturedView(2).isEmpty()) {
627 iconPrefix =
match.captured(1);
628 nokiaIcon =
match.captured(2);
685void QPlaceManagerEngineNokiaV2::replyFinished()
699void QPlaceManagerEngineNokiaV2::categoryReplyFinished()
710 if (m_categoryReply) {
721 if (m_tempTree.
contains(categoryId)) {
727 m_tempTree.
insert(categoryId, node);
730 categoryId = m_categoryRequests.
key(
reply);
732 rootNode.
childIds.removeAll(categoryId);
734 m_tempTree.
remove(categoryId);
737 m_categoryRequests.
remove(categoryId);
740 if (m_categoryRequests.
isEmpty()) {
741 m_categoryTree = m_tempTree;
749void QPlaceManagerEngineNokiaV2::categoryReplyError()
751 if (m_categoryReply) {
776QByteArray QPlaceManagerEngineNokiaV2::createLanguageString()
const
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 open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
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...
QJsonArray toArray() 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.
\inmodule QtCore \reentrant
\inmodule QtCore \reentrant
static QStringList standardLocations(StandardLocation type)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clear()
Clears the contents of the string and makes it null.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
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)
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
void addQueryItem(const QString &key, const QString &value)
Appends the pair key = value to the end of the query string of the URL.
QList< QPair< 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()
std::pair< T1, T2 > QPair
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