- Qt 5.0
- Qt Organizer Synchronous API
- Qt 5.0.0 Reference Documentation

# Qt Organizer Synchronous API

The Qt Organizer 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.

Most operations which may be performed using the synchronous API may also be performed using the asynchronous API. It is recommended for most applications that the asynchronous API be used where possible.

The synchronous API offered by the Organizer Items module is available through the QOrganizerManager class. It has the following main use cases:

- Manipulating Organizer Items
- Manipulating Item Collections

## Manipulating Organizer Items

The most common type of operation that clients perform involves retrieval or modification of organizer items. For in-depth information about item manipulation, see Qt Organizer C++ API.

The QOrganizerManager class provides API for accessing the IDs of items which are stored in the manager:

- QOrganizerManager::itemIds()

The synchronous, singular item manipulation functions offered by the QOrganizerManager class are:

- QOrganizerManager::item()
- QOrganizerManager::saveItem()
- QOrganizerManager::removeItem()

The synchronous, batch item manipulation functions offered by the QOrganizerManager class are:

- QOrganizerManager::items() which returns persistent and generated items within a given time period
- QOrganizerManager::itemsForExport() which returns only persistent items
- QOrganizerManager::itemOccurrences() which returns the occurrences of a specific recurring item
- QOrganizerManager::saveItems() which may be used to update a recurring item, or save an exceptional occurrence
- QOrganizerManager::removeItems() which may be used to remove a recurring item or exceptional occurrence

## Manipulating Item Collections

Every item is saved in a collection in a manager. Each collection has various properties which, if the manager supports such operations, may be modified by clients. For in-depth information about collections, see Qt Organizer C++ API.

The synchronous API offers the following functions to manipulate collections:

- QOrganizerManager::defaultCollectionId() returns the id of a default collection of the manager
- QOrganizerManager::collection() returns an existing collection by its id
- QOrganizerManager::collections() returns all collections in the manager
- QOrganizerManager::saveCollection() updates an existing collection or adds a new collection
- QOrganizerManager::removeCollection() removes an existing collection (and deletes any items it contains)

It also offers a convenience function which returns a collection with a given collection id.

## Reporting Errors

When a synchronous operation fails, clients need to be able to retrieve error information associated with that synchronous operation. You can call the QOrganizerManager::error() function directly after a failing synchronous operation to determine why it failed.

For some synchronous operations (for example, batch save or remove operations) it is possible that multiple errors may occur during the operation. In those cases, clients can call QOrganizerManager::errorMap() to retrieve a map of input index to error, which will be filled by the function as required. The QOrganizerManager::error() function will report the overall operation error.