summaryrefslogtreecommitdiffstats
path: root/doc/src/qlandmarks.qdoc
blob: 9cea6d95a3af21197a1aa8a14a4f2058a9585f5b (plain)
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
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page landmarks.html

\title Landmark Examples

\brief Landmarks allows management of landmark data, these examples show
how it is done.

The Landmarks portion of the Location API enables the creation,
retrieval, updating and deletion of landmarks from arbitrary data stores.
The following page demonstrates how to perform these operations.

\tableofcontents

\section1 Namespace

The QtMobility APIs are placed into the \i{QtMobility} namespace. This is done
to facilitate the future migration of QtMobility APIs into Qt. See the
\l {Quickstart guide} for an example on how the
namespace impacts on application development.


\section1 Creating/saving categories and landmarks
\section2 Synchronous
\section3 Creating/saving a category
The following example demonstrates how to synchronously add a category.
We create a QLandmarkCategory instance, set the desired properties and then use a
QLandmarkManager instance to save it.  When the category is saved, it is assigned
a QLandmarkCategoryId which is why it passed as a pointer.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add category synchronously

\section3 Creating/saving a landmark
The following example demonstrates synchronously adding a landmark.  We create
a QLandmark instance, set the desired properties and then use a QLandmarkManger instance
to save it.  When the landmark is saved, it is assigned a QLandmarkId, which is why it is
passed as a pointer.
\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add landmark synchronously

\section2 Asynchronous
\section3 Creating/saving a category
We create a QLandmarkCategory instance and set the desired properties.  Next we
have an instance of a QLandmarkCategorySaveRequest and set the category we want to save.
We then connect the \l {QLandmarkAbstractRequest::stateChanged()}
{stateChanged()} signal up to a slot which watches the state of the request.  To begin the request
we invoke \l {QLandmarkAbstractRequest::start()} {start()}.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add category asynchronously req

For brevity, the slot does not process all the different request states or error codes.  In our example
we watch for the QLandmarkAbstractRequest::FinishedState and see if there are any errors or not.
We may reuse the QLandmarkCategorySaveRequest by setting another category and running \l {QLandmarkAbstractRequest::start()}
{start()} again.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add category asynchronously handler

\section3 Creating/saving a landmark
We create a QLandmark instance and set the desired properties.  Next we
have an instance of a QLandmarkSaveRequest and set the landmark we want to save.
We then connect the \l {QLandmarkAbstractRequest::stateChanged()}
{stateChanged()} signal up to a slot which watches the state of the request. To begin the request
we invoke \l {QLandmarkAbstractRequest::start()} {start()}.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add landmark asynchronously

For brevity, the slot does not process all the different request states.  In our example
we watch for the QLandmarkAbstractRequest::FinishedState and see if there are any errors or not.
We may reuse the QLandmarkSaveRequest by setting another landmark and running \l {QLandmarkAbstractRequest::start()}
{start()} again.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Add landmark asynchronously handler

\section1 Retrieving categories and landmarks
\section2 Synchronous
\section3 Retrieving categories
To retrieve categories we simply make the appropriate call to the QLandmarkManager:
\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve categories synchronously

When retrieving categories we may do so by the category ids.  When the category data is needed
we may use the id to retrieve a category object:
\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve categories synchronously by id

\section3 Retrieving landmarks
To retrieve landmarks we create an appropriate filter, in this case a category filter.
In this example, we also provide a \c limit of 5 and \c offset of 0 to only retrieve the first
five landmarks and we provide a sort order to the QLandmarkManager.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve landmarks synchronously

Alternatively we can retrieve just the landmark ids.  When the landmark data is needed at a later
time we can use the id to retrieve the landmark object:
\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve landmarks synchronously by id

\section2 Asynchronous
\section3 Retrieving categories
To retrieve categories we can use a QLandmarkCategoryFetchRequest (or if we wish to fetch id's then a
QLandmarkCategoryIdFetchRequest).  The request's \l {QLandmarkAbstractRequest::stateChanged()} {stateChanged()}
signal is connected to a slot which detects whether the operation is complete.  To begin the request
we invoke \l {QLandmarkAbstractRequest::start()} {start()}.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve categories asynchronously

For brevity, the slot does not process all the different request states.  In our example, we watch for
the QLandmarkAbstractRequest::FinishedState and if there are no errors, print out the categories.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve categories asynchronously handler

\section3 Retrieving landmarks
To retrieve landmarks we create an appropriate filter, in this case a category filter,
and set it in a QLandmarkFetchRequest.
In this example, we also provide a \c limit of 5 and \c offset of 0 to only retrieve the first
five landmarks and we provide a sort order to the QLandmarkFetchRequest.  (If we wanted to operate with ids we would use
a QLandmarkIdFetchRequest instead). The request's  \l {QLandmarkAbstractRequest::stateChanged()}
{stateChanged()} signal is connected to a slot which detects whether the operation is complete. To begin the request
we invoke \l {QLandmarkAbstractRequest::start()} {start()}.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve landmarks asynchronously

For brevity, the slot does not process all the different request states.  In our example, we watch for
the QLandmarkAbstractRequest::FinishedState and if there are no errors, print out the landmarks.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Retrieve landmarks asynchronously handler

\section1 Deleting categories and landmarks

\section2 Synchronous

\section3 Deleting a category

To remove a category we simply pass the category id to a QLandmarkManager.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove category synchronously

\section3 Deleting a landmark

To remove a landmark we simply pass the landmark id to a QLandmarkManager.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove landmark synchronously

\section2 Asynchronous

\section3 Deleting a category
To remove a category we use a QLandmarkCategoryRemoveRequest and set
the id of the category we want to remove. We then connect the \l {QLandmarkAbstractRequest::stateChanged()}
{stateChanged()} signal up to a slot which watches the state of the request.  To begin the request
we invoke \l {QLandmarkAbstractRequest::start()} {start()}

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove category asynchronously

For brevity, the slot does not process all the different request states.  In our example
we watch for the QLandmarkAbstractRequest::FinishedState and see if there are any errors or not.
We may reuse the QLandmarkCategoryRemoveRequest by setting another category id and running \l {QLandmarkAbstractRequest::start()}
{start()} again.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove category asynchronously handler

\section3 Deleting a landmark
To remove a landmark we use a QLandmarkRemoveRequest and set the id of the landmark we want to remove.
We then connect the \l {QLandmarkAbstractRequest::stateChanged()}
{stateChanged()} signal up to a slot which watches the state of the request.  To begin the request
we invoke \l {QLandmarkAbstractRequest::start()} {start()}

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove landmark asynchronously

For brevity, the slot does not process all the different request states.  In our example
we watch for the QLandmarkAbstractRequest::FinishedState and see if there are any errors or not.
We may reuse the QLandmarkRemoveRequest by setting another landmark id and running \l {QLandmarkAbstractRequest::start()}
{start()} again.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Remove landmark asynchronously handler

\section1 Importing Landmarks

\section2 Synchronous

To import landmarks from a file we can simply provide the filename to the manager
(the manager will try to automatically detect the file format).  If we know
the format we can provide one of the \l {QLandmarkManager::Gpx} {format strings}
as a parameter.  Using a QLandmarkManager::TransferOption, an option for
controlling import/export behavior, we  can choose to include category data
that comes with the landmarks(default), exclude category data meaning that
the landmarks will not be associated with any categories or we can attach the
landmarks to a single category meaning all the imported landmarks will be
assigned to the given category.

\note Typically an import operation will take a long time to execute, it is therefore
recommended that landmarks be imported asynchronously rather than synchronously.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Import landmarks sync complex

\section2 Asynchronous

To import landmarks we use a QLandmarkImportRequest and set the
filename of the file we want to import. We can set other import parameters as necessary
such as the file format or the transfer option.  We then connect the \l
{QLandmarkAbstractRequest::stateChanged()} {stateChanged()} signal up to a slot
which watches the state of the request. To begin the request we invoke \l
{QLandmarkAbstractRequest::start()} {start()}

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Import landmarks asynchronously

For brevity, the slot does not process all the different request states.  In our example
we watch for the QLandmarkAbstractRequest::FinishedState and see if there are any errors or not.
We may reuse the QLandmarkImportRequest by setting filename and running \l {QLandmarkAbstractRequest::start()}
{start()} again.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Import landmarks asynchronously handler

\section1 Exporting Landmarks

\section2 Synchronous

To export landmarks we can pass a filename and \l {QLandmarkManager::Gpx} {format} to the manager.
If we only want to export a subset of landmarks we can provide a list of landmark ids to export.
We may also use a QLandmarkManager::TransferOption to decide whether we want to include(default) or exclude
category data for the export (This will only have an affect if the supplied format supports categories.)
Typically an export operation will take a long time to execute, it is therefore recommended that landmarks
be exported asynchronously rather than synchronously.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Export landmarks sync complex

\section2 Asynchronous
To export landmarks we use a QLandmarkExportRequest and set the filename of the file we want to export
to, as well as the format we wish to use.  We can set other export parameters as necessary,
such as a list of ids of landmarks we want to export or the transfer option.  We then connect the \l
{QLandmarkAbstractRequest::stateChanged()} {stateChanged()} signal up to a slot
which watches the state of the request. To begin the request we invoke \l
{QLandmarkAbstractRequest::start()} {start()}

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Export landmarks asynchronously

For brevity, the slot does not process all the different request states.  In our example
we watch for the QLandmarkAbstractRequest::FinishedState and see if there are any errors or not.
We may reuse the QLandmarkExportRequest by setting another filename and/or format and running \l {QLandmarkAbstractRequest::start()}
{start()} again.

\snippet snippets/qtlandmarksdocsample/qtlandmarksdocsample.cpp Export landmarks asynchronously handler

\section1 C++ Examples

There are no C++ only, documented examples of the Landmarks API. However, there
is the \l {Maps Demo Tutorial} which is C++ only, though being a tutorial it is
longer and more complicated than an example.

\section1 QML Examples

\section2 Landmark Map QML Example

The \l {Landmark Map Example} shows how a mobile application might display
some map information which includes landmark information imported from a landmark
file.

\section2 Map Viewer QML Example

The \l {Declarative Map Viewer Example}{Map Viewer example} displays a map of
the current location or failing that a hard-coded default location to display
a typical map navigation application in form typical of a mobile phone.



*/