Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdeclarativegeocodemodel_p.h
Go to the documentation of this file.
1// Copyright (C) 2015 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QDECLARATIVEGEOCODEMODEL_H
5#define QDECLARATIVEGEOCODEMODEL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtLocation/private/qlocationglobal_p.h>
19#include <QtLocation/private/qdeclarativegeoserviceprovider_p.h>
20
21#include <QtLocation/qgeocodereply.h>
22#include <QtPositioningQuick/private/qdeclarativegeoaddress_p.h>
23#include <QtPositioningQuick/private/qdeclarativegeolocation_p.h>
24
25#include <QtQml/qqml.h>
26#include <QtQml/QQmlParserStatus>
27#include <QAbstractListModel>
28#include <QPointer>
29
30
32
36
37class Q_LOCATION_EXPORT QDeclarativeGeocodeModel : public QAbstractListModel, public QQmlParserStatus
38{
40 QML_NAMED_ELEMENT(GeocodeModel)
43
44 Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
45 Q_PROPERTY(bool autoUpdate READ autoUpdate WRITE setAutoUpdate NOTIFY autoUpdateChanged)
46 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
47 Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
48 Q_PROPERTY(int count READ count NOTIFY countChanged)
49 Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
50 Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
51 Q_PROPERTY(QVariant query READ query WRITE setQuery NOTIFY queryChanged)
52 Q_PROPERTY(QVariant bounds READ bounds WRITE setBounds NOTIFY boundsChanged)
53 Q_PROPERTY(GeocodeError error READ error NOTIFY errorChanged)
55
56public:
63
66 EngineNotSetError = QGeoCodeReply::EngineNotSetError, //TODO Qt6 consider merge with NotSupportedError
67 CommunicationError = QGeoCodeReply::CommunicationError, //TODO Qt6 merge with Map's ConnectionError
69 UnsupportedOptionError = QGeoCodeReply::UnsupportedOptionError, //TODO Qt6 consider rename UnsupportedOperationError
72 //we leave gap for future QGeoCodeReply errors
73
74 //QGeoServiceProvider related errors start here
75 UnknownParameterError = 100,
76 MissingRequiredParameterError
77 };
78
79 enum Roles {
80 LocationRole = Qt::UserRole + 1
81 };
82
83 explicit QDeclarativeGeocodeModel(QObject *parent = nullptr);
85
86 // From QQmlParserStatus
87 void classBegin() override {}
88 void componentComplete() override;
89
90 // From QAbstractListModel
91 int rowCount(const QModelIndex &parent) const override;
92 QVariant data(const QModelIndex &index, int role) const override;
93 QHash<int,QByteArray> roleNames() const override;
94
95 void setPlugin(QDeclarativeGeoServiceProvider *plugin);
96 QDeclarativeGeoServiceProvider *plugin() const;
97
98 void setBounds(const QVariant &boundingArea);
99 QVariant bounds() const;
100
101 Status status() const;
102 QString errorString() const;
103 GeocodeError error() const;
104
105 bool autoUpdate() const;
106 void setAutoUpdate(bool update);
107
108 int count() const;
110
111 int limit() const;
112 void setLimit(int limit);
113 int offset() const;
114 void setOffset(int offset);
115
116 QVariant query() const;
117 void setQuery(const QVariant &query);
118 Q_INVOKABLE void reset();
119 Q_INVOKABLE void cancel();
120
125 void errorChanged(); //emitted also for errorString notification
132
133public Q_SLOTS:
134 void update();
135
136protected Q_SLOTS:
137 void queryContentChanged();
138 void geocodeFinished(QGeoCodeReply *reply);
139 void geocodeError(QGeoCodeReply *reply,
141 const QString &errorString);
142 void pluginReady();
143
144protected:
146 void setStatus(Status status);
147 void setError(GeocodeError error, const QString &errorString);
148 bool autoUpdate_ = false;
149 bool complete_ = false;
150
151private:
152 void setLocations(const QList<QGeoLocation> &locations);
153 void abortRequest();
154 QGeoCodeReply *reply_ = nullptr;
155
156 QDeclarativeGeoServiceProvider *plugin_ = nullptr;
157 QGeoShape boundingArea_;
158
159 QList<QDeclarativeGeoLocation *> declarativeLocations_;
160
162 QString errorString_;
164 QVariant queryVariant_;
165 QGeoCoordinate coordinate_;
166 QDeclarativeGeoAddress *address_ = nullptr;
167 QString searchString_;
168
169 int limit_ = -1;
170 int offset_ = 0;
171};
172
174
175#endif
void classBegin() override
Invoked after class creation, but before any properties have been set.
QGeoCodingManager * searchManager()
\inmodule QtLocation
Error
Describes an error which prevented the completion of the operation.
\inmodule QtLocation
\inmodule QtPositioning
\inmodule QtLocation
\inmodule QtPositioning
Definition qgeoshape.h:17
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
The QQmlParserStatus class provides updates on the QML parser state.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
void statusChanged(QQmlComponent::Status status)
[1]
Definition qlogging.cpp:11
Combined button and popup list for selecting options.
@ UserRole
DBusConnection const char DBusError * error
static QDBusError::ErrorType get(const char *name)
GLuint index
[2]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLboolean reset
GLenum query
GLint limit
GLuint const GLint * locations
#define QML_NAMED_ELEMENT(NAME)
static void setError(QJsonObject *response, const QString &msg)
@ NoError
Definition main.cpp:34
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_INTERFACES(x)
#define Q_SLOTS
#define Q_ENUMS(x)
#define Q_SIGNALS
future cancel()
qDebug()<< QUrl("file copy setQuery(copy.query(QUrl::FullyDecoded), QUrl::DecodedMode)
QNetworkReply * reply