KDE 4.2 PyKDE API Reference

- KDE's Python API

# Monitor Class Reference

`from PyKDE4.akonadi import *`

Inherits: QObject
Subclasses: Akonadi.ChangeRecorder
Namespace: Akonadi

## Detailed Description

Monitors an item or collection for changes.

The Monitor emits signals if some of these objects are changed or removed or new ones are added to the Akonadi storage.

Optionally, the changed objects can be fetched automatically from the server. To enable this, see fetchCollection(), fetchItemMetaData(), fetchItemData().

@todo: distinguish between monitoring collection properties and collection content. @todo: special case for collection content counts changed

Author:
  Volker Krause <vkrause@kde.org>

## Signals

| collectionAdded (Akonadi.Collection collection, Akonadi.Collection parent)
| collectionChanged (Akonadi.Collection collection)
| collectionRemoved (Akonadi.Collection collection)
| collectionStatisticsChanged (Akonadi.Collection.Id id, Akonadi.CollectionStatistics statistics)
| itemAdded (Akonadi.Item item, Akonadi.Collection collection)
| itemChanged (Akonadi.Item item, QSet<QByteArray> partIdentifiers)
| itemLinked (Akonadi.Item item, Akonadi.Collection collection)
| itemMoved (Akonadi.Item item, Akonadi.Collection collectionSource, Akonadi.Collection collectionDestination)
| itemRemoved (Akonadi.Item item)
| itemUnlinked (Akonadi.Item item, Akonadi.Collection collection)

## Methods

| __init__ (self, QObject parent=0)
| __init__ (self, MonitorPrivate d, QObject parent=0)
| collectionAdded (self, Akonadi.Collection collection, Akonadi.Collection parent)
| collectionChanged (self, Akonadi.Collection collection)
| collectionRemoved (self, Akonadi.Collection collection)
| collectionStatisticsChanged (self, Akonadi.Collection.Id id, Akonadi.CollectionStatistics statistics)
| fetchCollection (self, bool enable)
| fetchCollectionStatistics (self, bool enable)
| ignoreSession (self, Akonadi.Session session)
| itemAdded (self, Akonadi.Item item, Akonadi.Collection collection)
| itemChanged (self, Akonadi.Item item, QSet<QByteArray> partIdentifiers)
Akonadi.ItemFetchScope | itemFetchScope (self)
| itemLinked (self, Akonadi.Item item, Akonadi.Collection collection)
| itemMoved (self, Akonadi.Item item, Akonadi.Collection collectionSource, Akonadi.Collection collectionDestination)
| itemRemoved (self, Akonadi.Item item)
| itemUnlinked (self, Akonadi.Item item, Akonadi.Collection collection)
| setAllMonitored (self, bool monitored=1)
| setCollectionMonitored (self, Akonadi.Collection collection, bool monitored=1)
| setItemFetchScope (self, Akonadi.ItemFetchScope fetchScope)
| setItemMonitored (self, Akonadi.Item item, bool monitored=1)
| setMimeTypeMonitored (self, QString mimetype, bool monitored=1)
| setResourceMonitored (self, QByteArray resource, bool monitored=1)

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Creates a new monitor.

Parameters:

  | parent | The parent object.

__init__ | ( | self, |
|  | MonitorPrivate | d,
|  | QObject | parent=0
| ) |  |  |

collectionAdded | ( | self, |
|  | Akonadi.Collection | collection,
|  | Akonadi.Collection | parent
| ) |  |  |

This signal is emitted if a new collection has been added to a monitored collection in the Akonadi storage.

Parameters:

  | collection | The new collection.
  | parent | The parent collection.

Signal syntax:
  `QObject.connect(source, SIGNAL("collectionAdded(const Collection&, const Collection&)"), target_slot)`

collectionChanged | ( | self, |
|  | Akonadi.Collection | collection
| ) |  |  |

This signal is emitted if a monitored collection has been changed (properties or content) or has been reparented.

Parameters:

  | collection | The changed collection.

Signal syntax:
  `QObject.connect(source, SIGNAL("collectionChanged(const Collection&)"), target_slot)`

collectionRemoved | ( | self, |
|  | Akonadi.Collection | collection
| ) |  |  |

This signal is emitted if a monitored collection has been removed from the Akonadi storage.

Parameters:

  | collection | The removed collection.

Signal syntax:
  `QObject.connect(source, SIGNAL("collectionRemoved(const Collection&)"), target_slot)`

collectionStatisticsChanged | ( | self, |
|  | Akonadi.Collection.Id | id,
|  | Akonadi.CollectionStatistics | statistics
| ) |  |  |

This signal is emitted if the statistics information of a monitored collection has changed.

Parameters:

  | id | The collection identifier of the changed collection.
  | statistics | The updated collection statistics, invalid if automatic fetching of statistics changes is disabled.

Signal syntax:
  `QObject.connect(source, SIGNAL("collectionStatisticsChanged(Id, const CollectionStatistics&)"), target_slot)`

fetchCollection | ( | self, |
|  | bool | enable
| ) |  |  |

Enables automatic fetching of changed collections from the Akonadi storage.

Parameters:

  | enable | true enables automatic fetching, false disables automatic fetching.

fetchCollectionStatistics | ( | self, |
|  | bool | enable
| ) |  |  |

Enables automatic fetching of changed collection statistics information from the Akonadi storage.

Parameters:

  | enable | true to enables automatic fetching, false disables automatic fetching.

ignoreSession | ( | self, |
|  | Akonadi.Session | session
| ) |  |  |

Ignores all change notifications caused by the given session.

Parameters:

  | session | The session you want to ignore.

itemAdded | ( | self, |
|  | Akonadi.Item | item,
|  | Akonadi.Collection | collection
| ) |  |  |

This signal is emitted if an item has been added to a monitored collection in the Akonadi storage.

Parameters:

  | item | The new item.
  | collection | The collection the item has been added to.

Signal syntax:
  `QObject.connect(source, SIGNAL("itemAdded(const Item&, const Collection&)"), target_slot)`

itemChanged | ( | self, |
|  | Akonadi.Item | item,
|  | QSet<QByteArray> | partIdentifiers
| ) |  |  |

This signal is emitted if a monitored item has changed, e.g. item parts have been modified.

Parameters:

  | item | The changed item.
  | partIdentifiers | The identifiers of the item parts that has been changed.

Signal syntax:
  `QObject.connect(source, SIGNAL("itemChanged(const Item&, const QSet<QByteArray>&)"), target_slot)`

Akonadi.ItemFetchScope itemFetchScope | ( |  | self ) |

Returns the item fetch scope.

Since this returns a reference it can be used to conveniently modify the current scope in-place, i.e. by calling a method on the returned reference without storing it in a local variable. See the ItemFetchScope documentation for an example.

Returns:
  a reference to the current item fetch scope

See also:
  setItemFetchScope() for replacing the current item fetch scope

itemLinked | ( | self, |
|  | Akonadi.Item | item,
|  | Akonadi.Collection | collection
| ) |  |  |

This signal is emitted if a reference to an item is added to a virtual collection.

Parameters:

  | item | The linked item.
  | collection | The collection the item is linked to.

Since:
  4.2

Signal syntax:
  `QObject.connect(source, SIGNAL("itemLinked(const Item&, const Collection&)"), target_slot)`

itemMoved | ( | self, |
|  | Akonadi.Item | item,
|  | Akonadi.Collection | collectionSource,
|  | Akonadi.Collection | collectionDestination
| ) |  |  |

This signal is emitted if a monitored item has been moved between two collections

Parameters:

  | item | The moved item.
  | collectionSource | The collection the item has been moved from.
  | collectionDestination | The collection the item has been moved to.

Signal syntax:
  `QObject.connect(source, SIGNAL("itemMoved(const Item&, const Collection&, const Collection&)"), target_slot)`

itemRemoved | ( | self, |
|  | Akonadi.Item | item
| ) |  |  |

This signal is emitted if - a monitored item has been removed from the Akonadi storage or - a item has been removed from a monitored collection.

Parameters:

  | item | The removed item.

Signal syntax:
  `QObject.connect(source, SIGNAL("itemRemoved(const Item&)"), target_slot)`

itemUnlinked | ( | self, |
|  | Akonadi.Item | item,
|  | Akonadi.Collection | collection
| ) |  |  |

This signal is emitted if a reference to an item is removed from a virtual collection.

Parameters:

  | item | The unlinked item.
  | collection | The collection the item is unlinked from.

Since:
  4.2

Signal syntax:
  `QObject.connect(source, SIGNAL("itemUnlinked(const Item&, const Collection&)"), target_slot)`

setAllMonitored | ( | self, |
|  | bool | monitored=1
| ) |  |  |

Sets whether all items shall be monitored.

setCollectionMonitored | ( | self, |
|  | Akonadi.Collection | collection,
|  | bool | monitored=1
| ) |  |  |

Sets whether the specified collection shall be monitored for changes.

Parameters:

  | collection | The collection to monitor. If this collection is Collection.root(), all collections in the Akonadi storage will be monitored.

setItemFetchScope | ( | self, |
|  | Akonadi.ItemFetchScope | fetchScope
| ) |  |  |

Sets the item fetch scope.

Controls how much of an item's data is fetched from the server, e.g. whether to fetch the full item payload or only meta data.

Parameters:

  | fetchScope | The new scope for item fetch operations.

See also:
  itemFetchScope()

setItemMonitored | ( | self, |
|  | Akonadi.Item | item,
|  | bool | monitored=1
| ) |  |  |

Sets whether the specified item shall be monitored for changes.

Parameters:

  | item | The item to monitor.

setMimeTypeMonitored | ( | self, |
|  | QString | mimetype,
|  | bool | monitored=1
| ) |  |  |

Sets whether objects of the specified mime type shall be monitored for changes.

Parameters:

  | mimetype | The mime type to monitor.

setResourceMonitored | ( | self, |
|  | QByteArray | resource,
|  | bool | monitored=1
| ) |  |  |

Sets whether the specified resource shall be monitored for changes.

Parameters:

  | resource | The resource identifier.