QtOrganizer OrganizerModel

The OrganizerModel element provides access to organizer items from the organizer store.

Import Statement: import QtOrganizer 5.0

Properties

Signals

Methods

Detailed Description

OrganizerModel provides a model of organizer items from the organizer store. The contents of the model can be specified with filter, sortOrders and fetchHint properties. Whether the model is automatically updated when the store or C++ organizer item changes, can be controlled with OrganizerModel::autoUpdate property.

There are two ways of accessing the organizer item data: via the model by using views and delegates, or alternatively via items list property. Of the two, the model access is preferred. Direct list access (i.e. non-model) is not guaranteed to be in order set by sortOrder.

At the moment the model roles provided by OrganizerModel are display and item. Through the item role can access any data provided by the OrganizerItem element.

Note: Both the startPeriod and endPeriod are set by default to the current time (when the OrganizerModel was created). In most cases, both (or at least one) of the startPeriod and endPeriod should be set; otherwise, the OrganizerModel will contain zero items because the startPeriod and endPeriod are the same value. For example, if only endPeriod is provided, the OrganizerModel will contain all items from now (the time of the OrganizerModel’s creation) to the endPeriod time.

See also OrganizerItem and QOrganizerManager.

Property Documentation

ImportError : enumeration

Defines the errors cases for OrganizerModel::importItems() -function.

  • OrganizerModel::ImportNoError Completed successfully, no error.
  • OrganizerModel::ImportUnspecifiedError Unspecified error.
  • OrganizerModel::ImportIOError Input/output error.
  • OrganizerModel::ImportOutOfMemoryError Out of memory error.
  • OrganizerModel::ImportNotReadyError Not ready for importing. Only one import operation can be active at a time.
  • OrganizerModel::ImportParseError Error during parsing.
autoUpdate : bool

This property indicates whether or not the organizer model should be updated automatically, default value is true.

See also OrganizerModel::update().

availableManagers : list<string>

This property holds the list of available manager names. This property is read only.

collections : list<Collection>

This property holds a list of collections in the organizer model.

See also Collection.

endPeriod : date

This property holds the end date and time period used by the organizer model to fetch organizer items. The default value is the datetime of OrganizerModel creation.

error : string

This property holds the latest error code returned by the organizer manager.

This property is read only.

fetchHint : FetchHint

This property holds the fetch hint instance used by the organizer model.

See also FetchHint.

filter : Filter

This property holds the filter instance used by the organizer model.

Set filter property to ‘null’, when you want to reset it to default value.

See also Filter.

itemCount : int

This property holds the size of organizer items the OrganizerModel currently holds.

This property is read only.

items : list<OrganizerItem>

This property holds a list of organizer items in the organizer model.

See also OrganizerItem.

manager : string

This property holds the manager name or manager uri of the organizer backend engine. The manager uri format: qtorganizer:<managerid>:<key>=<value>&<key>=<value>.

For example, memory organizer engine has an optional id parameter, if user want to share the same memory engine with multiple OrganizerModel instances, the manager property should declared like this:

model : OrganizerModel {
   manager:"qtorganizer:memory:id=organizer1
}

instead of just the manager name:

model : OrganizerModel {
   manager:"memory"
}

See also QOrganizerManager::fromUri().

managerName : string

This property holds the manager name of the organizer backend engine. This property is read only.

See also QOrganizerManager::fromUri().

sortOrders : list<SortOrder>

This property holds a list of sort orders used by the organizer model.

See also SortOrder.

startPeriod : date

This property holds the start date and time period used by the organizer model to fetch organizer items. The default value is the datetime of OrganizerModel creation.

Signal Documentation

onExportCompleted()

This signal is emitted, when OrganizerModel::exportItems() completes. The success of operation can be seen on error which is defined in OrganizerModel::ExportError. url indicates the file, which was exported.

onImportCompleted(ImportError error, URL url, list<string> ids)

This signal is emitted, when OrganizerModel::importItems() completes. The success of operation can be seen on error which is defined in OrganizerModel::ImportError. url indicates the file, which was imported. ids contains the imported items ids.

If the operation was successful, items are now imported to backend. If OrganizerModel::autoUpdate is enabled, OrganizerModel::modelChanged will be emitted when imported items are also visible on OrganizerModel’s data model.

See also OrganizerModel::importItems.

onItemsFetched(int requestId, list<OrganizerItem> fetchedItems)

This handler is called when request of the given requestId is finished with the fetchedItems.

See also fetchItems.

onModelChanged()

This signal is emitted, when there are changes in items contained by OrganizerModel’s data model. Items have either been added, removed or modified. This signal is also always emitted during OrganizerModel construction when data model is ready for use, even in cases when data model is not having any items in it.

Method Documentation

cancelUpdate()

Cancel the running organizer model content update request.

See also OrganizerModel::autoUpdate and OrganizerModel::update.

Collection collection(string collectionId)

Returns the Collection object which collection id is the given collectionId and null if collection id is not found.

bool containsItems(date start, date end)

Returns true if there is at least one OrganizerItem between the given date range. Both the start and end parameters are optional, if no end parameter, returns true if there are item(s) after start, if neither start nor end date time provided, returns true if items in the current model is not empty, otherwise return false.

See also itemIds().

list<bool> containsItems(date start, date end, int interval)

Returns a list of booleans telling if there is any item falling in the given time range.

For example, if the start time is 2011-12-08 14:00:00, the end time is 2011-12-08 20:00:00, and the interval is 3600 (seconds), a list of size 6 is returned, telling if there is any item falling in the range of 14:00:00 to 15:00:00, 15:00:00 to 16:00:00, …, 19:00:00 to 20:00:00.

Collection defaultCollection()

Returns the default Collection object.

exportItems(url url, list<string> profiles)

Export organizer items into a vcalendar file to the given url by optional profiles. At the moment only the local file url is supported in export method.

fetchCollections()

Fetch asynchronously a list of organizer collections from the organizer backend.

int fetchItems(stringlist itemIds)

Starts a request to fetch items by the given itemIds, and returns the unique ID of this request. -1 is returned if the request can’t be started.

Note that the items fetched won’t be added to the model, but can be accessed through the onItemsFetched handler.

See also onItemsFetched.

int fetchItems(date start, date end, Filter filter, int maxCount, list<SortOrder> sortOrders, FetchHint fetchHint)

This method will start a request to fetch items between the given start and end dates. Optionally a sort order, filter, fetchHint and maxCount can be specified to narrow the search. If nothing is set for these optional paramenters then defaults are applied, essentially any sort order, default filter, default storage location and all items.

The unique ID of this request will be returned. If the request can’t be started -1 is returned. The end date must be greater than the start date for this method to start a fetch request.

Note that the items fetched won’t be added to the model, but can be accessed through the onItemsFetched handler. No properties in the model are updated at all.

See also onItemsFetched.

importItems(url url, list<string> profiles)

Import organizer items from a vcalendar by the given url and optional profiles. Only one import operation can be active at a time.

OrganizerItem item(string itemId)

Returns the OrganizerItem object with the given itemId.

list<string> itemIds(date start, date end)

Returns the list of organizer item ids between the given date range start and end, excluding generated occurrences. Both the start and end parameters are optional, if no end parameter, returns all item ids from start, if neither start nor end date time provided, returns all item ids in the current model.

See also containsItems().

list<OrganizerItem> itemsByTimePeriod(date start, date end)

Returns the list of organizer items between the given start and end period.

removeCollection(string collectionId)

Removes asynchronously the organizer collection with the given collectionId from the backend.

removeItem(OrganizerItem item)

Removes the given organizer item from the backend.

removeItem(string itemId)

Removes the organizer item with the given itemId from the backend.

removeItems(list<OrganizerItem> items)

Removes asynchronously the organizer items in the given items list from the backend.

removeItems(list<string> itemId)

Removes asynchronously the organizer items with the given ids from the backend.

saveCollection(Collection collection)

Saves asynchronously the given collection into the organizer backend.

saveItem(OrganizerItem item)

Saves asynchronously the given item into the organizer backend.

update()

Manually update the organizer model content including both items and collections.

See also OrganizerModel::updateItems, OrganizerModel::updateCollections, and OrganizerModel::autoUpdate.

updateCollections()

Manually update the organizer model collections.

See also OrganizerModel::update, OrganizerModel::updateItems, and OrganizerModel::autoUpdate.

updateItems()

Manually update the organizer model items.

See also OrganizerModel::update, OrganizerModel::updateCollections, and OrganizerModel::autoUpdate.