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 * @code
25 *
26 * // create a new top-level collection
27 * Akonadi::Collection collection;
28 * collection.setParentCollection( Collection::root() );
29 * collection.setName( "Events" );
30 * collection.setContentMimeTypes( QStringList( "text/calendar" ) );
31 *
32 * Akonadi::CollectionCreateJob *job = new Akonadi::CollectionCreateJob( collection );
33 * connect( job, SIGNAL(result(KJob*)), this, SLOT(createResult(KJob*)) );
34 *
35 * @endcode
36 *
37 * @author Volker Krause <vkrause@kde.org>
38 */
39class AKONADICORE_EXPORT CollectionCreateJob : public Job
40{
41 Q_OBJECT
42public:
43 /**
44 * Creates a new collection create job.
45 *
46 * @param collection The new collection. @p collection must have a parent collection
47 * set with a unique identifier. If a resource context is specified in the current session
48 * (that is you are using it within Akonadi::ResourceBase), the parent collection can be
49 * identified by its remote identifier as well.
50 * @param parent The parent object.
51 */
52 explicit CollectionCreateJob(const Collection &collection, QObject *parent = nullptr);
53
54 /**
55 * Destroys the collection create job.
56 */
57 ~CollectionCreateJob() override;
58
59 /**
60 * Returns the created collection if the job was executed successfully.
61 */
62 [[nodiscard]] Collection collection() const;
63
64protected:
65 void doStart() override;
66 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
67
68private:
69 Q_DECLARE_PRIVATE(CollectionCreateJob)
70};
71
72}
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 Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.