Akonadi::ItemFetchScope Class

class Akonadi::ItemFetchScope

Specifies which parts of an item should be fetched from the Akonadi storage. More...

Header: #include <Akonadi/ItemFetchScope>
CMake: find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore)

Public Types

enum AncestorRetrieval { None, Parent, All }

Public Functions

ItemFetchScope()
ItemFetchScope(const Akonadi::ItemFetchScope &other)
~ItemFetchScope()
bool allAttributes() const
Akonadi::ItemFetchScope::AncestorRetrieval ancestorRetrieval() const
QSet<QByteArray> attributes() const
bool cacheOnly() const
bool checkForCachedPayloadPartsOnly() const
void fetchAllAttributes(bool fetch = true)
void fetchAttribute(bool fetch = true)
void fetchAttribute(const QByteArray &type, bool fetch = true)
QDateTime fetchChangedSince() const
void fetchFullPayload(bool fetch = true)
bool fetchGid() const
bool fetchModificationTime() const
void fetchPayloadPart(const QByteArray &part, bool fetch = true)
bool fetchRemoteIdentification() const
bool fetchTags() const
bool fetchVirtualReferences() const
bool fullPayload() const
bool ignoreRetrievalErrors() const
bool isEmpty() const
QSet<QByteArray> payloadParts() const
void setAncestorRetrieval(Akonadi::ItemFetchScope::AncestorRetrieval ancestorDepth)
void setCacheOnly(bool cacheOnly)
void setCheckForCachedPayloadPartsOnly(bool check = true)
void setFetchChangedSince(const QDateTime &changedSince)
void setFetchGid(bool retrieveGID)
void setFetchModificationTime(bool retrieveMtime)
void setFetchRemoteIdentification(bool retrieveRid)
void setFetchTags(bool fetchTags)
void setFetchVirtualReferences(bool fetchVRefs)
void setIgnoreRetrievalErrors(bool enabled)
void setTagFetchScope(const Akonadi::TagFetchScope &fetchScope)
Akonadi::TagFetchScope &tagFetchScope()
Akonadi::TagFetchScope tagFetchScope() const
Akonadi::ItemFetchScope &operator=(const Akonadi::ItemFetchScope &other)

Detailed Description

When items are fetched from server either by using ItemFetchJob explicitly or when it is being used internally by other classes, e.g. ItemModel, the scope of the fetch operation can be tailored to the application's current needs.

There are two supported ways of changing the currently active ItemFetchScope of classes: - in-place: modify the ItemFetchScope object the other class holds as a member - replace: replace the other class' member with a new scope object

Example: modifying an ItemFetchJob's scope \ in-place

 Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( collection );
 job->fetchScope().fetchFullPayload();
 job->fetchScope().fetchAttribute<MyAttribute>();

Example: \ replacing an ItemFetchJob's scope

 Akonadi::ItemFetchScope scope;
 scope.fetchFullPayload();
 scope.fetchAttribute<MyAttribute>();

 Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( collection );
 job->setFetchScope( scope );

This class is implicitly shared.

Author: Kevin Krammer <kevin.krammer@gmx.at>

Member Type Documentation

enum ItemFetchScope::AncestorRetrieval

Describes the ancestor retrieval depth.

Member Function Documentation

ItemFetchScope::ItemFetchScope()

Creates an empty item fetch scope.

Using an empty scope will only fetch the very basic meta data of items, e.g. local id, remote id and mime type

ItemFetchScope::ItemFetchScope(const Akonadi::ItemFetchScope &other)

Creates a new item fetch scope from an other.

[noexcept] ItemFetchScope::~ItemFetchScope()

Destroys the item fetch scope.

bool ItemFetchScope::allAttributes() const

Returns whether all available attributes should be fetched.

See also fetchAllAttributes().

Akonadi::ItemFetchScope::AncestorRetrieval ItemFetchScope::ancestorRetrieval() const

Returns the ancestor retrieval depth.

See also setAncestorRetrieval().

QSet<QByteArray> ItemFetchScope::attributes() const

Returns all explicitly fetched attributes.

Undefined if fetchAllAttributes() returns true.

See also fetchAttribute().

bool ItemFetchScope::cacheOnly() const

Returns whether payload data should be requested from remote sources or just from the local cache.

See also setCacheOnly().

bool ItemFetchScope::checkForCachedPayloadPartsOnly() const

Returns whether payload data should be fetched or only checked for presence in the cache.

See also setCheckForCachedPayloadPartsOnly().

void ItemFetchScope::fetchAllAttributes(bool fetch = true)

Sets whether all available attributes should be fetched. The default is \ false.

fetch \ true if all available attributes should be fetched, \ false otherwise.

template <typename T> void ItemFetchScope::fetchAttribute(bool fetch = true)

Sets whether the attribute of the requested type should be fetched.

fetch \ true if the attribute should be fetched, \ false otherwise.

void ItemFetchScope::fetchAttribute(const QByteArray &type, bool fetch = true)

Sets whether the attribute of the given type should be fetched.

type The attribute type to fetch. fetch \ true if the attribute should be fetched, \ false otherwise.

QDateTime ItemFetchScope::fetchChangedSince() const

Returns timestamp of the oldest item to fetch.

See also setFetchChangedSince().

void ItemFetchScope::fetchFullPayload(bool fetch = true)

Sets whether the full payload shall be fetched. The default is \ false.

fetch \ true if the full payload should be fetched, \ false otherwise.

bool ItemFetchScope::fetchGid() const

Returns whether item GID should be retrieved.

See also setFetchGid().

bool ItemFetchScope::fetchModificationTime() const

Returns whether item modification time should be retrieved.

See also setFetchModificationTime().

void ItemFetchScope::fetchPayloadPart(const QByteArray &part, bool fetch = true)

Sets which payload parts shall be fetched.

part The payload part identifier. Valid values depend on the item type. fetch \ true to fetch this part, \ false otherwise.

bool ItemFetchScope::fetchRemoteIdentification() const

Returns whether item remote identification should be retrieved.

See also setFetchRemoteIdentification().

bool ItemFetchScope::fetchTags() const

Returns whether tags should be retrieved.

See also setFetchTags().

bool ItemFetchScope::fetchVirtualReferences() const

Returns whether virtual references should be retrieved.

See also setFetchVirtualReferences().

bool ItemFetchScope::fullPayload() const

Returns whether the full payload should be fetched.

See also fetchFullPayload().

bool ItemFetchScope::ignoreRetrievalErrors() const

Returns whether retrieval errors should be ignored.

See also setIgnoreRetrievalErrors().

bool ItemFetchScope::isEmpty() const

Returns \ true if there is nothing to fetch.

QSet<QByteArray> ItemFetchScope::payloadParts() const

Returns the payload parts that should be fetched.

See also fetchPayloadPart().

void ItemFetchScope::setAncestorRetrieval(Akonadi::ItemFetchScope::AncestorRetrieval ancestorDepth)

Sets how many levels of ancestor collections should be included in the retrieval. The default is AncestorRetrieval::None.

ancestorDepth The desired ancestor retrieval depth.

See also ancestorRetrieval().

void ItemFetchScope::setCacheOnly(bool cacheOnly)

Sets whether payload data should be requested from remote sources or just from the local cache.

cacheOnly \ true if no remote data should be requested, \ false otherwise (the default).

See also cacheOnly().

void ItemFetchScope::setCheckForCachedPayloadPartsOnly(bool check = true)

Sets whether payload will be fetched or there will be only a test performed if the requested payload is in the cache. Calling it calls

Default is fetching the data.

See also checkForCachedPayloadPartsOnly(), setCacheOnly, with, true, and automatically.

void ItemFetchScope::setFetchChangedSince(const QDateTime &changedSince)

Only fetch items that were added or modified after given timestamp

When this property is set, all results are filtered, i.e. even when you request an item with a specific ID, it will not be fetched unless it was modified after changedSince timestamp.

changedSince The timestamp of oldest modified item to fetch

See also fetchChangedSince().

void ItemFetchScope::setFetchGid(bool retrieveGID)

Enables retrieval of the item GID. This is disabled by default.

retrieveGID \ true to retrieve the GID, \ false otherwise

See also fetchGid().

void ItemFetchScope::setFetchModificationTime(bool retrieveMtime)

Enables retrieval of the item modification time. This is enabled by default for backward compatibility reasons.

retrieveMtime \ true to retrieve the modification time, \ false otherwise

See also fetchModificationTime().

void ItemFetchScope::setFetchRemoteIdentification(bool retrieveRid)

Fetch remote identification for items.

These include Akonadi::Item::remoteId() and Akonadi::Item::remoteRevision(). This should be off for normal clients usually, to save memory (not to mention normal clients should not be concerned with these information anyway). It is however crucial for resource agents. For backward compatibility the default is \ true.

retrieveRid whether or not to load remote identification.

See also fetchRemoteIdentification().

void ItemFetchScope::setFetchTags(bool fetchTags)

Fetch tags for items.

The fetched tags have only the Tag::id() set and need to be fetched first to access further attributes.

The default is \ false.

fetchTags whether or not to load tags.

See also fetchTags().

void ItemFetchScope::setFetchVirtualReferences(bool fetchVRefs)

Returns whether to fetch list of virtual collections the item is linked to

fetchVRefs whether or not to fetch virtualc references

See also fetchVirtualReferences().

void ItemFetchScope::setIgnoreRetrievalErrors(bool enabled)

Ignore retrieval errors while fetching items, and always deliver what is available. If items have missing parts and the part can't be retrieved from the resource (i.e. because the system is offline), the fetch job would normally just fail. By setting this flag, the errors are ignored, and all items which could be fetched completely are returned. Note that all items that are returned are completely fetched, and incomplete items are simply ignored. This flag is useful for displaying everything that is available, where it is not crucial to have all items. Never use this for things like data migration or alike.

See also ignoreRetrievalErrors().

void ItemFetchScope::setTagFetchScope(const Akonadi::TagFetchScope &fetchScope)

Sets the tag fetch scope.

The TagFetchScope controls how much of an tags's data is fetched from the server.

By default setFetchIdOnly is set to true on the tag fetch scope.

fetchScope The new fetch scope for tag fetch operations.

See also tagFetchScope() and fetchScope().

Akonadi::TagFetchScope &ItemFetchScope::tagFetchScope()

Returns the tag 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 TagFetchScope documentation for an example.

By default setFetchIdOnly is set to true on the tag fetch scope.

Returns a reference to the current tag fetch scope

See also setTagFetchScope(), setFetchScope(), for, replacing, the, current, tag, fetch, and scope.

Akonadi::TagFetchScope ItemFetchScope::tagFetchScope() const

Returns the tag fetch scope.

By default setFetchIdOnly is set to true on the tag fetch scope.

Returns a reference to the current tag fetch scope

See also setFetchScope(), for, replacing, the, current, tag, fetch, and scope.

Akonadi::ItemFetchScope &ItemFetchScope::operator=(const Akonadi::ItemFetchScope &other)

Assigns the other to this scope and returns a reference to this scope.