Item Class Reference
from PyKDE4.akonadi import *
Inherits: Akonadi.Entity
Namespace: Akonadi
Detailed Description
Represents a PIM item stored in Akonadi storage.
A PIM item consists of one or more parts, allowing a fine-grained access on its content where needed (eg. mail envelope, mail body and attachments).
There is also a namespace (prefix) for special parts which are local to Akonadi. These parts, prefixed by "akonadi-" will never be fetched in the resource. They are useful for local extensions like agents which might want to add meta data to items in order to handle them but the meta data should not be stored back to the resource.
This class contains beside some type-agnostic information (flags, revision) a single payload object representing its actual data. Which objects these actually are depends on the mimetype of the item and the corresponding serializer plugin.
This class is implicitly shared.
<h4>Payload</h4>
Technically the only restriction on payload objects is that they have to be copyable. For safety reasons, pointer payloads are forbidden as well though, as the ownership would not be clear. In this case, usage of a shared pointer is recommended (such as boost.shared_ptr or QSharedPointer).
Using a shared pointer is also recommended in case the payload uses polymorphic types. For supported shared pointer types implicit casting is provided when possible.
When using a value-based class as payload, it is recommended to use one that does support implicit sharing as setting and retrieving a payload as well as copying an Akonadi.Item object imply copying of the payload object.
The availability of a payload of a specific type can be checked using hasPayload(), payloads can be retrieved by using payload() and set by using setPayload(). Refer to the documentation of those methods for more details.
Enumerations | |
UrlType | { UrlShort, UrlWithMimeType } |
Attributes | |
QString | FullPayload |
Methods | |
__init__ (self) | |
__init__ (self, Id id) | |
__init__ (self, QString mimeType) | |
__init__ (self, Akonadi.Item other) | |
clearFlag (self, QByteArray name) | |
clearFlags (self) | |
Akonadi.Item.Flags | flags (self) |
bool | hasFlag (self, QByteArray name) |
bool | hasPayload (self) |
QSet | loadedPayloadParts (self) |
QString | mimeType (self) |
QDateTime | modificationTime (self) |
QByteArray | payloadData (self) |
int | revision (self) |
setFlag (self, QByteArray name) | |
setFlags (self, Akonadi.Item.Flags flags) | |
setMimeType (self, QString mimeType) | |
setModificationTime (self, QDateTime datetime) | |
setPayloadFromData (self, QByteArray data) | |
setRevision (self, int revision) | |
setSize (self, long size) | |
long | size (self) |
Entity.Id | storageCollectionId (self) |
KUrl | url (self, Akonadi.Item.UrlType type=Akonadi.Item.UrlShort) |
Static Methods | |
Akonadi.Item | fromUrl (KUrl url) |
Method Documentation
__init__ | ( | self ) |
__init__ | ( | self, | ||
Id | id | |||
) |
Creates a new item with the given unique id.
__init__ | ( | self, | ||
QString | mimeType | |||
) |
Creates a new item with the given mime type.
- Parameters:
-
mimeType The mime type of the item.
__init__ | ( | self, | ||
Akonadi.Item | other | |||
) |
Creates a new item from an other item.
clearFlag | ( | self, | ||
QByteArray | name | |||
) |
Removes the flag with the given name from the item.
clearFlags | ( | self ) |
Removes all flags from the item.
Akonadi.Item.Flags flags | ( | self ) |
Returns all flags of this item.
Akonadi.Item fromUrl | ( | KUrl | url | |
) |
Creates an item from the given url.
bool hasFlag | ( | self, | ||
QByteArray | name | |||
) |
Returns whether the flag with the given name is set in the item.
bool hasPayload | ( | self ) |
Returns whether the item has a payload object.
QSet |
( | self ) |
Returns the list of loaded payload parts. This is not necessarily identical to all parts in the cache or to all available parts on the backend.
QString mimeType | ( | self ) |
Returns the mime type of the item.
QDateTime modificationTime | ( | self ) |
Returns the timestamp of the last modification of this item.
- Since:
- 4.2
QByteArray payloadData | ( | self ) |
Returns the full payload in its canonical representation, e.g. the binary or textual format usually used for data with this mime type. This is useful when communicating with non-Akonadi application by e.g. drag&drop, copy&paste or stored files.
int revision | ( | self ) |
Returns the revision number of the item.
setFlag | ( | self, | ||
QByteArray | name | |||
) |
Sets the flag with the given name in the item.
setFlags | ( | self, | ||
Akonadi.Item.Flags | flags | |||
) |
Overwrites all flags of the item by the given flags.
setMimeType | ( | self, | ||
QString | mimeType | |||
) |
Sets the mime type of the item to mimeType.
setModificationTime | ( | self, | ||
QDateTime | datetime | |||
) |
Sets the timestamp of the last modification of this item.
- Note:
- Do not modify this value from within an application, it is updated automatically by the revision checking functions.
- Since:
- 4.2
setPayloadFromData | ( | self, | ||
QByteArray | data | |||
) |
Sets the payload based on the canonical representation normally used for data of this mime type.
- Parameters:
-
data The encoded data.
- See also:
- fullPayloadData
setRevision | ( | self, | ||
int | revision | |||
) |
Sets the revision number of the item.
- Note:
- Do not modify this value from within an application, it is updated automatically by the revision checking functions.
setSize | ( | self, | ||
long | size | |||
) |
Set the size of the item in bytes.
- Since:
- 4.2
long size | ( | self ) |
Returns the size of the items in bytes.
- Since:
- 4.2
Entity.Id storageCollectionId | ( | self ) |
Returns the unique identifier of the collection this item is stored in. There is only a single such collection, although the item can be linked into arbitrary many virtual collections. Calling this method makes sense only after running an ItemFetchJob on the item.
- Returns:
- the collection ID if it is know, -1 otherwise.
- Since:
- 4.3
KUrl url | ( | self, | ||
Akonadi.Item.UrlType | type=Akonadi.Item.UrlShort | |||
) |
Returns the url of the item.
Attribute Documentation
QString FullPayload |
Creates a new item.
Enumeration Documentation
UrlType |
Describes the type of url which is returned in url().
- Enumerator:
-
UrlShort = 0 UrlWithMimeType = 1