Akonadi

specialcollectionsrequestjob.h
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadicore_export.h"
10#include "collection.h"
11#include "specialcollections.h"
12#include "transactionsequence.h"
13
14#include <QVariant>
15
16#include <memory>
17
18namespace Akonadi
19{
20class SpecialCollectionsRequestJobPrivate;
21
22/**
23 * @short A job to request SpecialCollections.
24 *
25 * Use this job to request the SpecialCollections you need. You can request both
26 * default SpecialCollections and SpecialCollections in a given resource. The default
27 * SpecialCollections resource is created when the first default SpecialCollection is
28 * requested, but if a SpecialCollection in a custom resource is requested, this
29 * job expects that resource to exist already.
30 *
31 * If the folders you requested already exist, this job simply succeeds.
32 * Otherwise, it creates the required collections and registers them with
33 * SpecialCollections.
34 *
35 * This class is not meant to be used directly but as a base class for type
36 * specific special collection request jobs.
37 *
38 * @author Constantin Berzan <exit3219@gmail.com>
39 * @since 4.4
40 */
41class AKONADICORE_EXPORT SpecialCollectionsRequestJob : public TransactionSequence
42{
44
45public:
46 /**
47 * Destroys the special collections request job.
48 */
50
51 /**
52 * Requests a special collection of the given @p type in the default resource.
53 */
54 void requestDefaultCollection(const QByteArray &type);
55
56 /**
57 * Requests a special collection of the given @p type in the given resource @p instance.
58 */
59 void requestCollection(const QByteArray &type, const AgentInstance &instance);
60
61 /**
62 * Returns the requested collection.
63 */
64 [[nodiscard]] Collection collection() const;
65
66protected:
67 /**
68 * Creates a new special collections request job.
69 *
70 * @param collections The SpecialCollections object that shall be used.
71 * @param parent The parent object.
72 */
73 explicit SpecialCollectionsRequestJob(SpecialCollections *collections, QObject *parent = nullptr);
74
75 /**
76 * Sets the @p type of the resource that shall be created if the requested
77 * special collection does not exist yet.
78 */
79 void setDefaultResourceType(const QString &type);
80
81 /**
82 * Sets the configuration @p options that shall be applied to the new resource
83 * that is created if the requested special collection does not exist yet.
84 */
85 void setDefaultResourceOptions(const QVariantMap &options);
86
87 /**
88 * Sets the list of well known special collection @p types.
89 */
90 void setTypes(const QList<QByteArray> &types);
91
92 /**
93 * Sets the @p map of special collection types to display names.
94 */
96
97 /**
98 * Sets the @p map of special collection types to icon names.
99 */
101
102 /* reimpl */
103 void doStart() override;
104 /* reimpl */
105 void slotResult(KJob *job) override;
106
107private:
108 /// @cond PRIVATE
109 friend class SpecialCollectionsRequestJobPrivate;
110 friend class DefaultResourceJobPrivate;
111
112 std::unique_ptr<SpecialCollectionsRequestJobPrivate> const d;
113
114 Q_PRIVATE_SLOT(d, void releaseLock())
115 Q_PRIVATE_SLOT(d, void resourceScanResult(KJob *))
116 Q_PRIVATE_SLOT(d, void collectionCreateResult(KJob *))
117 /// @endcond
118};
119
120} // namespace Akonadi
A representation of an agent instance.
Represents a collection of PIM items.
Definition collection.h:62
void requestCollection(const QByteArray &type, const AgentInstance &instance)
Requests a special collection of the given type in the given resource instance.
void setIconForTypeMap(const QMap< QByteArray, QString > &map)
Sets the map of special collection types to icon names.
void setTypes(const QList< QByteArray > &types)
Sets the list of well known special collection types.
SpecialCollectionsRequestJob(SpecialCollections *collections, QObject *parent=nullptr)
Creates a new special collections request job.
Collection collection() const
Returns the requested collection.
void setNameForTypeMap(const QMap< QByteArray, QString > &map)
Sets the map of special collection types to display names.
~SpecialCollectionsRequestJob() override
Destroys the special collections request job.
void setDefaultResourceOptions(const QVariantMap &options)
Sets the configuration options that shall be applied to the new resource that is created if the reque...
void doStart() override
This method must be reimplemented in the concrete jobs.
void requestDefaultCollection(const QByteArray &type)
Requests a special collection of the given type in the default resource.
void setDefaultResourceType(const QString &type)
Sets the type of the resource that shall be created if the requested special collection does not exis...
An interface to special collections.
TransactionSequence(QObject *parent=nullptr)
Creates a new transaction sequence.
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:57 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.