1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
#include "qdeclarativelocation_p.h"
QTM_USE_NAMESPACE
/*!
\qmlclass Location
\brief The Location element holds location data.
\inherits QObject
Location cointains many properties holding data of the location like geo coordinates,
address, etc.
\ingroup qml-places
*/
QDeclarativeLocation::QDeclarativeLocation(QObject* parent)
: QObject(parent)
{
}
QDeclarativeLocation::QDeclarativeLocation(const QPlaceLocation &src,
QObject *parent)
: QObject(parent),
m_src(src)
{
}
QDeclarativeLocation::~QDeclarativeLocation()
{
}
void QDeclarativeLocation::setLocation(const QPlaceLocation &src)
{
QPlaceLocation previous = m_src;
m_src = src;
if (previous.additionalData() != m_src.additionalData()) {
emit additionalDataChanged();
}
if (previous.alternativeLabels() != m_src.alternativeLabels()) {
synchronizeAlternativeValues();
emit alternativeLabelsChanged();
}
if (previous.address() != m_src.address()) {
m_address.setAddress(m_src.address());
emit addressChanged();
}
if (previous.displayPosition() != m_src.displayPosition()) {
m_displayPosition.setCoordinate(m_src.displayPosition());
emit displayPositionChanged();
}
if (previous.navigationPositions() != m_src.navigationPositions()) {
synchronizeNavigationPositions();
emit navigationPositionsChanged();
}
if (previous.label() != m_src.label()) {
emit labelChanged();
}
if (previous.locationId() != m_src.locationId()) {
emit locationIdChanged();
}
if (previous.locationScore() != m_src.locationScore()) {
emit locationScoreChanged();
}
if (previous.mapView() != m_src.mapView()) {
emit mapViewChanged();
}
}
QPlaceLocation QDeclarativeLocation::location() const
{
return m_src;
}
/*!
\qmlproperty QVariantHash Location::additionalData
This property holds additional data for location. Those are pairs of strings (key/value).
*/
void QDeclarativeLocation::setAdditionalData(const QVariantHash &additionalData)
{
if (m_src.additionalData() != additionalData) {
m_src.setAdditionalData(additionalData);
emit additionalDataChanged();
}
}
QVariantHash QDeclarativeLocation::additionalData() const
{
return m_src.additionalData();
}
/*!
\qmlproperty string Location::address
This property holds address of the location.
*/
void QDeclarativeLocation::setAddress(QDeclarativeGeoAddress *address)
{
if (m_src.address() != address->address()) {
m_address.setAddress(address->address());
m_src.setAddress(address->address());
emit addressChanged();
}
}
QDeclarativeGeoAddress *QDeclarativeLocation::address()
{
return &m_address;
}
/*!
\qmlproperty string Location::displayPosition
This property holds display coordinates of the location.
*/
void QDeclarativeLocation::setDisplayPosition(QDeclarativeCoordinate *displayPosition)
{
if (m_src.displayPosition() != displayPosition->coordinate()) {
m_displayPosition.setCoordinate(displayPosition->coordinate());
m_src.setDisplayPosition(displayPosition->coordinate());
emit displayPositionChanged();
}
}
QDeclarativeCoordinate *QDeclarativeLocation::displayPosition()
{
return &m_displayPosition;
}
/*!
\qmlproperty string Location::label
This property holds label.
*/
void QDeclarativeLocation::setLabel(const QString &label)
{
if (m_src.label() != label) {
m_src.setLabel(label);
emit labelChanged();
}
}
QString QDeclarativeLocation::label() const
{
return m_src.label();
}
/*!
\qmlproperty string Location::locationId
This property holds location id.
*/
void QDeclarativeLocation::setLocationId(const QString &locationId)
{
if (m_src.locationId() != locationId) {
m_src.setLocationId(locationId);
emit locationIdChanged();
}
}
QString QDeclarativeLocation::locationId() const
{
return m_src.locationId();
}
/*!
\qmlproperty string Location::locationScore
This property holds location score.
*/
void QDeclarativeLocation::setLocationScore(const int &locationScore)
{
if (m_src.locationScore() != locationScore) {
m_src.setLocationScore(locationScore);
emit locationScoreChanged();
}
}
int QDeclarativeLocation::locationScore() const
{
return m_src.locationScore();
}
/*!
\qmlproperty string Location::mapView
This property holds bouding box of area on map ocupied by location.
*/
void QDeclarativeLocation::setMapView(QDeclarativeGeoBoundingBox *mapView)
{
if (m_src.mapView() != mapView->box()) {
m_boundingBox.setBox(mapView->box());
m_src.setMapView(mapView->box());
emit mapViewChanged();
}
}
QDeclarativeGeoBoundingBox *QDeclarativeLocation::mapView()
{
return &m_boundingBox;
}
/*!
\qmlproperty QDeclarativeListProperty<QDeclarativeAlternativeValue> Location::alternativeLabels
This property alternative values for label property.
*/
QDeclarativeListProperty<QDeclarativeAlternativeValue> QDeclarativeLocation::alternativeLabels()
{
return QDeclarativeListProperty<QDeclarativeAlternativeValue>(this,
0, // opaque data parameter
alternativeValue_append,
alternativeValue_count,
alternativeValue_at,
alternativeValue_clear);
}
void QDeclarativeLocation::alternativeValue_append(QDeclarativeListProperty<QDeclarativeAlternativeValue> *prop,
QDeclarativeAlternativeValue *value)
{
QDeclarativeLocation* object = static_cast<QDeclarativeLocation*>(prop->object);
QDeclarativeAlternativeValue *altValue = new QDeclarativeAlternativeValue(object);
altValue->setValueObject(value->valueObject());
object->m_alternativeValues.append(altValue);
QList<QPlaceAlternativeValue> list = object->m_src.alternativeLabels();
list.append(value->valueObject());
object->m_src.setAlternativeLabels(list);
emit object->alternativeLabelsChanged();
}
int QDeclarativeLocation::alternativeValue_count(QDeclarativeListProperty<QDeclarativeAlternativeValue> *prop)
{
return static_cast<QDeclarativeLocation*>(prop->object)->m_alternativeValues.count();
}
QDeclarativeAlternativeValue* QDeclarativeLocation::alternativeValue_at(QDeclarativeListProperty<QDeclarativeAlternativeValue> *prop,
int index)
{
QDeclarativeLocation* object = static_cast<QDeclarativeLocation*>(prop->object);
QDeclarativeAlternativeValue *res = NULL;
if (object->m_alternativeValues.count() > index && index > -1) {
res = object->m_alternativeValues[index];
}
return res;
}
void QDeclarativeLocation::alternativeValue_clear(QDeclarativeListProperty<QDeclarativeAlternativeValue> *prop)
{
QDeclarativeLocation* object = static_cast<QDeclarativeLocation*>(prop->object);
qDeleteAll(object->m_alternativeValues);
object->m_alternativeValues.clear();
object->m_src.setAlternativeLabels(QList<QPlaceAlternativeValue>());
emit object->alternativeLabelsChanged();
}
/*!
\qmlproperty QDeclarativeListProperty<QDeclarativeCoordinate> Location::navigationPositions
This property navigation coordinates for location.
*/
QDeclarativeListProperty<QDeclarativeCoordinate> QDeclarativeLocation::navigationPositions()
{
return QDeclarativeListProperty<QDeclarativeCoordinate>(this,
0, // opaque data parameter
navigationPosition_append,
navigationPosition_count,
navigationPosition_at,
navigationPosition_clear);
}
void QDeclarativeLocation::navigationPosition_append(QDeclarativeListProperty<QDeclarativeCoordinate> *prop,
QDeclarativeCoordinate *value)
{
QDeclarativeLocation* object = static_cast<QDeclarativeLocation*>(prop->object);
QDeclarativeCoordinate *altValue = new QDeclarativeCoordinate(object);
altValue->setCoordinate(value->coordinate());
object->m_navigationPositions.append(altValue);
QList<QGeoCoordinate> list = object->m_src.navigationPositions();
list.append(value->coordinate());
object->m_src.setNavigationPositions(list);
emit object->navigationPositionsChanged();
}
int QDeclarativeLocation::navigationPosition_count(QDeclarativeListProperty<QDeclarativeCoordinate> *prop)
{
return static_cast<QDeclarativeLocation*>(prop->object)->m_navigationPositions.count();
}
QDeclarativeCoordinate* QDeclarativeLocation::navigationPosition_at(QDeclarativeListProperty<QDeclarativeCoordinate> *prop,
int index)
{
QDeclarativeLocation* object = static_cast<QDeclarativeLocation*>(prop->object);
QDeclarativeCoordinate *res = NULL;
if (object->m_navigationPositions.count() > index && index > -1) {
res = object->m_navigationPositions[index];
}
return res;
}
void QDeclarativeLocation::navigationPosition_clear(QDeclarativeListProperty<QDeclarativeCoordinate> *prop)
{
QDeclarativeLocation* object = static_cast<QDeclarativeLocation*>(prop->object);
qDeleteAll(object->m_navigationPositions);
object->m_navigationPositions.clear();
object->m_src.setNavigationPositions(QList<QGeoCoordinate>());
emit object->navigationPositionsChanged();
}
void QDeclarativeLocation::synchronizeAlternativeValues()
{
qDeleteAll(m_alternativeValues);
m_alternativeValues.clear();
foreach (QPlaceAlternativeValue value, m_src.alternativeLabels()) {
QDeclarativeAlternativeValue* declarativeValue = new QDeclarativeAlternativeValue(value, this);
m_alternativeValues.append(declarativeValue);
}
}
void QDeclarativeLocation::synchronizeNavigationPositions()
{
qDeleteAll(m_navigationPositions);
m_navigationPositions.clear();
foreach (QGeoCoordinate value, m_src.navigationPositions()) {
QDeclarativeCoordinate* declarativeValue = new QDeclarativeCoordinate(value, this);
m_navigationPositions.append(declarativeValue);
}
}
|