Akonadi::ItemCreateJob Class
class Akonadi::ItemCreateJobJob that creates a new item in the Akonadi storage. More...
| Header: | #include <Akonadi/ItemCreateJob> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore) |
| Inherits: | Akonadi::Job |
Public Functions
| ItemCreateJob(const Akonadi::Item &item, const Akonadi::Collection &collection, QObject *parent = nullptr) | |
| virtual | ~ItemCreateJob() override |
| Akonadi::Item | item() const |
| void | setMerge(Akonadi::ItemCreateJob::MergeOptions options) |
Detailed Description
This job creates a new item with all the set properties in the given target collection.
Note that items can not be created in the root collection (Collection::root()) and the collection must have Collection::contentMimeTypes() that match the mimetype of the item being created.
Example:
// Create a contact item in the root collection KContacts::Addressee addr; addr.setNameFromString( "Joe Jr. Miller" ); Akonadi::Item item; item.setMimeType( "text/directory" ); item.setPayload<KContacts::Addressee>( addr ); Akonadi::Collection collection = getCollection(); Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob( item, collection ); connect(job, &KJob::result, this, &MyClass::jobFinished); ... MyClass::jobFinished( KJob *job ) { if ( job->error() ) qDebug() << "Error occurred"; else qDebug() << "Contact item created successfully"; }
Author: Volker Krause <vkrause@kde.org>
Member Function Documentation
ItemCreateJob::ItemCreateJob(const Akonadi::Item &item, const Akonadi::Collection &collection, QObject *parent = nullptr)
Creates a new item create job.
item The item to create.
Note: It must have a mime type set. collection The parent collection where the new item shall be located in. parent The parent object.
[override virtual noexcept] ItemCreateJob::~ItemCreateJob()
Destroys the item create job.
Akonadi::Item ItemCreateJob::item() const
Returns the created item with the new unique id, or an invalid item if the job failed.
void ItemCreateJob::setMerge(Akonadi::ItemCreateJob::MergeOptions options)
Merge this item into an existing one if available.
If an item with same GID and/or remote ID as the created item exists in specified collection (depending on the provided options), the new item will be merged into the existing one and the merged item will be returned (unless the Silent option is used).
If no matching item is found a new item is created.
If the item does not have a GID or RID, this option will be ignored and a new item will be created.
By default, merging is disabled.
options Merge options.