Akonadi

linkjob.h
1/*
2 SPDX-FileCopyrightText: 2008 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 "item.h"
11#include "job.h"
12#include "private/protocol_p.h"
13
14namespace Akonadi
15{
16class Collection;
17class LinkJobPrivate;
18
19/**
20 * @short Job that links items inside the Akonadi storage.
21 *
22 * This job allows you to create references to a set of items in a virtual
23 * collection.
24 *
25 * Example:
26 *
27 * @code
28 *
29 * // Links the given items to the given virtual collection
30 * const Akonadi::Collection virtualCollection = ...
31 * const Akonadi::Item::List items = ...
32 *
33 * Akonadi::LinkJob *job = new Akonadi::LinkJob( virtualCollection, items );
34 * connect( job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)) );
35 *
36 * ...
37 *
38 * MyClass::jobFinished( KJob *job )
39 * {
40 * if ( job->error() )
41 * qDebug() << "Error occurred";
42 * else
43 * qDebug() << "Linked items successfully";
44 * }
45 *
46 * @endcode
47 *
48 * @author Volker Krause <vkrause@kde.org>
49 * @since 4.2
50 * @see UnlinkJob
51 */
52class AKONADICORE_EXPORT LinkJob : public Job
53{
55public:
56 /**
57 * Creates the link job.
58 *
59 * The job will create references to the given items in the given collection.
60 *
61 * @param collection The collection in which the references should be created.
62 * @param items The items of which the references should be created.
63 * @param parent The parent object.
64 */
65 LinkJob(const Collection &collection, const Item::List &items, QObject *parent = nullptr);
66
67 /**
68 * Destroys the link job.
69 */
70 ~LinkJob() override;
71
72protected:
73 void doStart() override;
74 bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override;
75
76private:
77 Q_DECLARE_PRIVATE(LinkJob)
78 template<typename T, Protocol::LinkItemsCommand::Action>
79 friend class LinkJobImpl;
80};
81
82}
Represents a collection of PIM items.
Definition collection.h:62
QList< Item > List
Describes a list of items.
Definition item.h:110
Job(QObject *parent=nullptr)
Creates a new job.
Definition job.cpp:290
~LinkJob() override
Destroys the link job.
LinkJob(const Collection &collection, const Item::List &items, QObject *parent=nullptr)
Creates the link job.
Definition linkjob.cpp:24
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
Definition linkjob.cpp:40
void doStart() override
This method must be reimplemented in the concrete jobs.
Definition linkjob.cpp:34
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 Mar 28 2025 11:53:21 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.