Akonadi::ItemModifyJob Class
class Akonadi::ItemModifyJobJob that modifies an existing item in the Akonadi storage. * * This job is used to writing back items to the Akonadi storage, after * the user has changed them in any way. * For performance reasons either the full item (including the full payload) * can written back or only the meta data of the item. * * Example: * *. More...
| Header: | #include <Akonadi/ItemModifyJob> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore) |
| Inherits: | Akonadi::Job |
Public Functions
| ItemModifyJob(const Akonadi::Item &item, QObject *parent = nullptr) | |
| ItemModifyJob(const Akonadi::Item::List &items, QObject *parent = nullptr) | |
| virtual | ~ItemModifyJob() override |
| void | disableAutomaticConflictHandling() |
| void | disableRevisionCheck() |
| bool | ignorePayload() const |
| Akonadi::Item | item() const |
| Akonadi::Item::List | items() const |
| void | setIgnorePayload(bool ignore) |
| void | setUpdateGid(bool update) |
| bool | updateGid() const |
Detailed Description
*
* * // Fetch item with unique id 125 * Akonadi::ItemFetchJob *fetchJob = new Akonadi::ItemFetchJob( Akonadi::Item( 125 ) ); * connect(job, &KJob::result, this, &MyClass::fetchFinished); * * ... * * MyClass::fetchFinished( KJob *job ) * { * if ( job->error() ) * return; * * Akonadi::ItemFetchJob *fetchJob = qobject_cast<Akonadi::ItemFetchJob*>( job ); * * Akonadi::Item item = fetchJob->items().at(0); * * // Set a custom flag * item.setFlag( "\GotIt" ); * * // Store back modified item * Akonadi::ItemModifyJob *modifyJob = new Akonadi::ItemModifyJob( item ); * connect(modifyJob, &KJob::result, this, &MyClass::modifyFinished); * } * * MyClass::modifyFinished( KJob *job ) * { * if ( job->error() ) * qDebug() << "Error occurred"; * else * qDebug() << "Item modified successfully"; * } * *
* * <h3>Conflict Resolution</h3>
* When the job is executed, a check is made to ensure that the Item contained * in the job is not older than the version of the Item already held in the * Akonadi database. If it is older, a conflict resolution dialog is displayed * for the user to choose which version of the Item to use, unless * disableAutomaticConflictHandling() has been called to disable the dialog, or * disableRevisionCheck() has been called to disable version checking * altogether. * * The item version is checked by comparing the Item::revision() values in the * job and in the database. To ensure that two successive ItemModifyJobs for * the same Item work correctly, the revision number of the Item supplied to * the second ItemModifyJob should be set equal to the Item's revision number * on completion of the first ItemModifyJob. This can be obtained by, for * example, calling item().revision() in the job's result slot. * * Author: Volker Krause <vkrause@kde.org> * * * *
Member Function Documentation
[explicit] ItemModifyJob::ItemModifyJob(const Akonadi::Item &item, QObject *parent = nullptr)
Creates a new item modify job.
item The modified item object to store. parent The parent object.
[explicit] ItemModifyJob::ItemModifyJob(const Akonadi::Item::List &items, QObject *parent = nullptr)
Creates a new item modify job for bulk modifications.
Using this is different from running a modification job per item. Use this when applying the same change to a set of items, such as a mass-change of item flags, not if you just want to store a bunch of randomly modified items.
Currently the following modifications are supported: - flag changes
Note: Since this does not do payload modifications, it implies setIgnorePayload( true ) and disableRevisionCheck(). items The list of items to modify, must not be empty.
[override virtual noexcept] ItemModifyJob::~ItemModifyJob()
Destroys the item modify job.
void ItemModifyJob::disableAutomaticConflictHandling()
Disables the automatic handling of conflicts.
By default the item modify job will bring up a dialog to resolve a conflict that might happen when modifying an item. Calling this method will avoid that and the job returns with an error in case of a conflict.
void ItemModifyJob::disableRevisionCheck()
Disables the check of the revision number.
Note: If disabled, no conflict detection is available.
bool ItemModifyJob::ignorePayload() const
Returns whether the payload of the modified item shall be omitted from transmission to the Akonadi storage.
See also setIgnorePayload().
Akonadi::Item ItemModifyJob::item() const
Returns the modified and stored item including the changed revision number.
Note: Use this method only when using the single item constructor.
Akonadi::Item::List ItemModifyJob::items() const
Returns the modified and stored items including the changed revision number.
void ItemModifyJob::setIgnorePayload(bool ignore)
Sets whether the payload of the modified item shall be omitted from transmission to the Akonadi storage. The default is \ false, however it can be set for performance reasons. ignore ignores payload if set as \ true
See also ignorePayload().
void ItemModifyJob::setUpdateGid(bool update)
Sets whether the GID shall be updated either from the gid parameter or by extracting it from the payload. The default is \ false to avoid unnecessarily update the GID, as it should never change once set, and the ItemCreateJob already sets it. update update the GID if set as \ true
Note: If disabled the GID will not be updated, but still be used for identification of the item.
See also updateGid().
bool ItemModifyJob::updateGid() const
Returns whether the GID should be updated.
See also setUpdateGid().