Akonadi

tagfetchjob.h
1/*
2 SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>
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#include "tag.h"
12
13namespace Akonadi
14{
15class TagFetchScope;
16class TagFetchJobPrivate;
17
18/**
19 * @short Job that fetches tags from the Akonadi storage.
20 *
21 * This class is used to fetch tags from the Akonadi storage.
22 *
23 * If you want to fetch all items with given tag, use ItemFetchJob and the
24 * ItemFetchJob(const Tag &tag, QObject *parent = nullptr) constructor (since 4.14)
25 *
26 * @since 4.13
27 */
28class AKONADICORE_EXPORT TagFetchJob : public Job
29{
30 Q_OBJECT
31
32public:
33 /**
34 * Constructs a new tag fetch job that retrieves all tags stored in Akonadi.
35 *
36 * @param parent The parent object.
37 */
38 explicit TagFetchJob(QObject *parent = nullptr);
39
40 /**
41 * Constructs a new tag fetch job that retrieves the specified tag.
42 * If the tag has a uid set, this is used to identify the tag on the Akonadi
43 * server. If only a remote identifier is available, that is used. However
44 * as remote identifiers are internal to resources, it's necessary to set
45 * the resource context (see ResourceSelectJob).
46 *
47 * @param tag The tag to fetch.
48 * @param parent The parent object.
49 */
50 explicit TagFetchJob(const Tag &tag, QObject *parent = nullptr);
51
52 /**
53 * Constructs a new tag fetch job that retrieves specified tags.
54 * If the tags have a uid set, this is used to identify the tags on the Akonadi
55 * server. If only a remote identifier is available, that is used. However
56 * as remote identifiers are internal to resources, it's necessary to set
57 * the resource context (see ResourceSelectJob).
58 *
59 * @param tags Tags to fetch.
60 * @param parent The parent object.
61 */
62 explicit TagFetchJob(const Tag::List &tags, QObject *parent = nullptr);
63
64 /**
65 * Convenience ctor equivalent to ItemFetchJob(const Item::List &items, QObject *parent = nullptr)
66 *
67 * @param ids UIDs of tags to fetch.
68 * @param parent The parent object.
69 */
70 explicit TagFetchJob(const QList<Tag::Id> &ids, QObject *parent = nullptr);
71
72 /**
73 * Sets the tag fetch scope.
74 *
75 * The TagFetchScope controls how much of an tags's data is fetched
76 * from the server.
77 *
78 * @param fetchScope The new fetch scope for tag fetch operations.
79 * @see fetchScope()
80 */
81 void setFetchScope(const TagFetchScope &fetchScope);
82
83 /**
84 * Returns the tag fetch scope.
85 *
86 * Since this returns a reference it can be used to conveniently modify the
87 * current scope in-place, i.e. by calling a method on the returned reference
88 * without storing it in a local variable. See the TagFetchScope documentation
89 * for an example.
90 *
91 * @return a reference to the current tag fetch scope
92 *
93 * @see setFetchScope() for replacing the current tag fetch scope
94 */
95 TagFetchScope &fetchScope();
96
97 /**
98 * Returns the fetched tags after the job has been completed.
99 */
100 [[nodiscard]] Tag::List tags() const;
101
102Q_SIGNALS:
103 /**
104 * This signal is emitted whenever new tags have been fetched completely.
105 *
106 * @param tags The fetched tags
107 */
109
110protected:
111 void doStart() override;
112 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
113
114private:
115 Q_DECLARE_PRIVATE(TagFetchJob)
116
117 /// @cond PRIVATE
118 Q_PRIVATE_SLOT(d_func(), void timeout())
119 /// @endcond
120};
121
122}
Base class for all actions in the Akonadi storage.
Definition job.h:81
Job that fetches tags from the Akonadi storage.
Definition tagfetchjob.h:29
void tagsReceived(const Akonadi::Tag::List &tags)
This signal is emitted whenever new tags have been fetched completely.
Specifies which parts of a tag should be fetched from the Akonadi storage.
An Akonadi Tag.
Definition tag.h:26
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.