Akonadi

collectioncreatejob.h
1/*
2 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10#include "job.h"
11
12namespace Akonadi
13{
14class Collection;
15class CollectionCreateJobPrivate;
16
17/**
18 * @short Job that creates a new collection in the Akonadi storage.
19 *
20 * This job creates a new collection with all the set properties.
21 * You have to use setParentCollection() to define the collection the
22 * new collection shall be located in.
23 *
24 * Example:
25 *
26 * @code
27 * using namespace Qt::StringLiterals;
28 *
29 * // create a new top-level collection
30 * Akonadi::Collection collection;
31 * collection.setParentCollection(Collection::root());
32 * collection.setName(u"Events"_s);
33 * collection.setContentMimeTypes({ u""text/calendar"_s });
34 *
35 * auto job = new Akonadi::CollectionCreateJob(collection);
36 * connect(job, &KJob::result, this, &MyClass::createResult);
37 * @endcode
38 *
39 * @author Volker Krause <vkrause@kde.org>
40 */
41class AKONADICORE_EXPORT CollectionCreateJob : public Job
42{
43 Q_OBJECT
44public:
45 /**
46 * Creates a new collection create job.
47 *
48 * @param collection The new collection. @p collection must have a parent collection
49 * set with a unique identifier. If a resource context is specified in the current session
50 * (that is you are using it within Akonadi::ResourceBase), the parent collection can be
51 * identified by its remote identifier as well.
52 * @param parent The parent object.
53 */
54 explicit CollectionCreateJob(const Collection &collection, QObject *parent = nullptr);
55
56 /**
57 * Destroys the collection create job.
58 */
59 ~CollectionCreateJob() override;
60
61 /**
62 * Returns the created collection if the job was executed successfully.
63 */
64 [[nodiscard]] Collection collection() const;
65
66protected:
67 void doStart() override;
68 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
69
70private:
71 Q_DECLARE_PRIVATE(CollectionCreateJob)
72};
73
74}
Job that creates a new collection in the Akonadi storage.
Represents a collection of PIM items.
Definition collection.h:62
Base class for all actions in the Akonadi storage.
Definition job.h:81
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:03:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.