summaryrefslogtreecommitdiffstats
path: root/doc/src/organizer.qdoc
blob: de1742abc88fce4b4b8b1b4c8edeedeee2efba8b (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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/****************************************************************************
**
** 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$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/




/*!

\page organizer.html

\title Organizer
\brief An API enabling clients to request calendar, schedule and personal data
from local or remote backends.

\ingroup mobility

The Organizer API enables a client to request calendar, schedule and personal
data from local or remote backends. This is part of the QtMobility Project.

\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 Introduction

The Organizer API provides clients with the ability to access calendar,
schedule and personal data in a platform-independent and datastore-agnostic
manner.  This is achieved by defining generic personal information data
abstractions which can sufficiently describe calendar and scheduling data
stored a platform's native calendaring system.  Through the plugin architecture,
it can be used as a front-end API for any calenaring system (eg. an online
calendar).

\section1 Basic Usage

The Qt Organizer API provides both a \l{Organizer Synchronous API}{synchronous}
and an \l{Organizer Asynchronous API}{asynchronous} API.  Note that for clarity,
the short examples on this page demonstrate the synchronous API.  While these
code snippets might be useful for non-GUI applications, it is highly recommended
that the asynchronous API is used for GUI applications.

\section2 The Organizer Manager
Organizer information is stored in datastores whose functionality is exposed
via the QOrganizerManager class.

Most users of the API will want to use the default manager for the platform,
which provides access to the system address book.  Instantiating a manager by
using the default constructor will result in the default manager for that
platform being instantiated:

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Instantiating the default manager for the platform

\section2 Creating a New Item

You can create a new item simply by instantiating one and saving it a manager.

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Creating a non-recurrent entry

\section2 Retrieving Items

You can request all items from the manager that occur in a given time range.

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Retrieving entries for a time period

It is also possible filter the items on the value of a detail.

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Retrieving entries with a filter

The above code will retrieve both items that have been saved to the manager and
items which are generated based on \l {recurrences}{recurrence rules}.  Given a
recurring item, it is possible to retrieve a list of items that it generates;
that is, to get a list of the upcoming occurrences of a single recurring item.
This can be done using QOrganizerManager::itemOccurrences():

You can also retrieve a particular existing item from a manager, by
directly requesting the item with a particular (previously known) id.
The synchronous API provides the QOrganizerManager::item() function to retrieve
a single item by its id.  With the asynchronous API, this can be done using a
QOrganizerItemFetchRequest and a QOrganizerItemIdFilter.

\section2 Updating an Existing Item

You can update a previously saved item retrieving the item, modifying it, and
saving it back to the manager.  The manager uses the id of the item to match up
the provided item with the one in the database.

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Editing a non-recurrent entry

\section2 Removing an item from a manager

You can remove an item from the manager by using its id.

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Removing an entry

\section1 The Organizer Item Model

\section2 Items

A \l QOrganizerItem represents an event, todo, journal or note.

Each item stored in a manager is identified by a \l QOrganizerItemId.  The id
is the means by which the manager can:
\list
\o Determine whether a \l{QOrganizerManager::saveItem()}{save} operation should
make a new item or update an existing one.  (If an item has a null id, it
should be saved as a new item)
\o Match an item to an existing one for updating.
\o Link between items (for example, in QOrganizerItemParent).
\endlist

The QOrganizerItem class provides a generic interface for accessing events,
todos, journals and notes.  To actually access specific fields of an item,
convenience subclasses of QOrganizerItem are offered.  These are
QOrganizerEvent, QOrganizerTodo, QOrganizerJournal and QOrganizerNote.
Additionally, QOrganizerEventOccurrence and QOrganizerTodoOccurrence can be used
for manipulating occurrences of event or todos (see the
\l{recurrences}{Recurring Items} section).  Here is an example of how to
retrieve details specific to an item:

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Downcasting items

\target recurrences
\section2 Recurring Items

A recurring item is an item that occurs more than once; for example, a meeting
that occurs every week for the next 10 weeks.  A recurring item is created by
creating a QOrganizerEvent or QOrganizerTodo and setting a
QOrganizerRecurrenceRule on it to specify the rules for when it should
recur.  When QOrganizerManager::items() is called, recurring items are \i not
returned.  Rather, they expanded into multiple QOrganizerEventOccurrence and
QOrganizerTodoOccurrence items.  Each generated occurrence item has a null id.

You can make an exception for an occurrence by taking a generated item
occurrence from the manager, making the necessary modifications, and resaving
it.  When the manager is then queried with QOrganizerManager::items(), it will
return the list of occurrences as before, but with the modifications in place.
The modified item will be given a non-null id, and replaces the generated one in
the list.

Here is an example of changing a single occurrence of an item:

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Creating an exception to a particular recurrent event

You can also query the manager for a list of unexpanded items by calling
QOrganizerManager::itemsForExport().  The list of returned items will contain all
items that have been saved to the manager with a call to
QOrganizerManager::saveItem() That is, recurring events will be returned as is,
and event occurrences will not appear unless they are exceptions (ie. have a
non-null id).  Fetching the list in this way can be useful for transfering items
to other managers or for exporting to iCalendar with QtVersit.

\section2 Collections

Every item stored in a manager belongs to exactly one
\l{QOrganizerCollection}{collection}.  A collection can have properties such
as a name, a "color", a specified icon, a description, and so on.  Collections
may be added or removed if the manager supports those operations, or modified.
There will always be at least one collection in a manager, and the manager
will always have a default collection into which items are saved if no other
collection is specified.

Some managers will allow users to create collections (for example, a "football
fixtures" collection) while others may have built-in collections (for example,
"work" and "home" collections).

A list of all collections can be retrieved from a manager with one function call:

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Getting a list of collections

To save an item to a collection, set the collection ID on the item object.  If
the collection id is the null id, the item will be saved in the collection in
which it is currently saved (if the item already exists) or into the manager's
default collection (if it is a new item).

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Saving an item to a collection

To retrieve all items in a collection, a QOrganizerItemCollectionFilter should be
used.

    \snippet snippets/qtorganizerdocsample/qtorganizerdocsample.cpp Retrieving items in a collection

\section2 All-day Events

Events and Todos can be specified as all-day or multi-day by setting the
AllDay field to \tt{true} (using QOrganizerEvent::setAllDay()).  When this field
is set to true, it means that the time portion of the StartDateTime and
EndDateTime should be ignored.  An event or todo marked as all-day should be
considered to start and end roughly on its given start and end dates
(inclusive), but without specifying exact times.  For example, a birthday could
be specified as an all-day QOrganizerEvent where the StartDateTime and
EndDateTime have the same value.

\section1 API Usage

\section2 Asynchronous API

The asynchronous API provides a way to access or modify the
organizer item information managed by a particular backend via non-blocking,
asynchronous requests.  It is recommended for most
applications that the asynchronous API be used where possible.

The asynchronous API is offered through various classes derived from the
QOrganizerAbstractRequest class, including
QOrganizerItemIdFetchRequest, QOrganizerItemFetchRequest,
QOrganizerItemFetchForExportRequest,
QOrganizerItemSaveRequest, QOrganizerItemRemoveRequest,
QOrganizerItemOccurrenceFetchRequest, QOrganizerCollectionFetchRequest,
QOrganizerCollectionRemoveRequest, QOrganizerCollectionSaveRequest,
QOrganizerItemDetailDefinitionFetchRequest,
QOrganizerItemDetailDefinitionSaveRequest, and
QOrganizerItemDetailDefinitionRemoveRequest.

The asynchronous API allows manipulation of \l{QOrganizerItem}{items},
\l{QOrganizerCollection}{collections} and
\l{QOrganizerItemDetailDefinition}{schema definitions}, but does not provide
manager capability or meta data information reporting.

For more detailed documentation on the asynchronous API, see the \l{Organizer Asynchronous API}.

\section2 Synchronous API

The synchronous API provides the simplest way to access or modify the
organizer item information managed by a particular backend.  It has the
disadvantage that calls block the current thread of execution until completion
and is therefore most suitable only for applications which interact with
local, high-speed datastores, or for applications which do not require a
responsive user interface.

The synchronous API is offered through the QOrganizerManager class, and
includes manipulation of \l{QOrganizerItem}{items},
\l{QOrganizerCollection}{collections} and
\l{QOrganizerItemDetailDefinition}{schema definitions}.  As previously
described, the meta data reporting and manipulation functions are also
provided via synchronous API only.

For more detailed documentation on the synchronous API, see the
\l{Organizer Synchronous API}.


\section1 More information

While the information on this page should be sufficient for the common
use-cases, please see the discussion on \l{Advanced Organizer API Usage} for
more details on the intricacies of the API.

It is possible for third party developers to implement a manager engine plugin
from which clients may request data.  For more information on this topic (for
example, if you intend to implement a manager backend) please see
\l{Qt Organizer Manager Engines}.

\section1 Reference documentation

\section2 Main Classes

\annotatedlist organizer-main

\section2 QOrganizerItemDetail Leaf Classes

Several subclasses of \l{QOrganizerItemDetail} are provided as part of the
QtMobility Organizer API.  They are general in design but are intended
to fulfill specific use-cases.  Please note that certain backends may
choose not to support one or more of these subclasses as they appear here;
they may offer their own which provide similar functionality.

\annotatedlist organizer-details

Each of these subclasses provide access to information stored in fields which
may have certain constraints, as listed in the \l{Qt Organizer Schema}{schema}.

\section2 Asynchronous Requests

You may use either the \l{Organizer Synchronous API}{synchronous}
or \l{Organizer Asynchronous API}{asynchronous} API to access
functionality provided by a manager backend. The
\l{Organizer Asynchronous API}{asynchronous} API is
offered through subclasses of the \l{QOrganizerAbstractRequest} class:

\annotatedlist organizer-requests

\section2 Organizer Item Selection And Sorting

You may select an organizer item by specifying a unique item id, or by
supplying a \l{QOrganizerItemFilter} which matches the item or items they
wish to select.  The various derivatives of \l{QOrganizerItemFilter} allow for
fine-grained and flexible selection of organizer data according to various
criteria:

\annotatedlist organizer-filters


A client can also request that the results of such a selection be sorted,
by passing a \l{QOrganizerItemSortOrder} (or list of sort orders) to the
manager.

\section2 Implementing Backends

A backend implementor must implement the following interfaces:

\annotatedlist organizer-backends

For more information on this topic, see please see the documentation on
\l{Qt Organizer Manager Engines}{implementing manager engines}.

\section2 Synchronization and Serialization

The organizer API is used by another QtMobility module: the
\l {Versit} {Versit}* module.  It allows
serialization of a QOrganizerItem into an iCalendar document, and vice versa.

[*] Versit \reg is a trademark of the Internet Mail Consortium.

\section1 Examples

The following sample applications show examples of API usage:
\list
    \o \l{CalendarDemo}{Example Calendar Application}
\endlist

\section1 QML Elements

For details on the QML support provided for the Organizer API see the documentation for the \l {Organizer QML Plugin}.


*/