Akonadi

collectioncreatejob.h
1 /*
2  SPDX-FileCopyrightText: 2006 Volker Krause <[email protected]>
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 
12 namespace Akonadi
13 {
14 class Collection;
15 class 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 <[email protected]>
38  */
39 class AKONADICORE_EXPORT CollectionCreateJob : public Job
40 {
41  Q_OBJECT
42 public:
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  Q_REQUIRED_RESULT Collection collection() const;
63 
64 protected:
65  void doStart() override;
66  bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
67 
68 private:
69  Q_DECLARE_PRIVATE(CollectionCreateJob)
70 };
71 
72 }
73 
Represents a collection of PIM items.
Definition: collection.h:61
Base class for all actions in the Akonadi storage.
Definition: job.h:80
Job that creates a new collection in the Akonadi storage.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.