Akonadi

agentinstancecreatejob.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 "agenttype.h"
10#include "akonadicore_export.h"
11
12#include <KJob>
13
14#include <memory>
15
16namespace Akonadi
17{
18class AgentInstance;
19class AgentInstanceCreateJobPrivate;
20
21/**
22 * @short Job for creating new agent instances.
23 *
24 * This class encapsulates the procedure of creating a new agent instance
25 * and optionally configuring it immediately.
26 *
27 * Example:
28 *
29 * @code
30 * using namespace Qt::StringLiterals;
31 *
32 * MyClass::MyClass(QWidget *parent)
33 * : QWidget(parent)
34 * {
35 * // Get agent type object
36 * Akonadi::AgentType type = Akonadi::AgentManager::self()->type(u"akonadi_vcard_resource"_s);
37 *
38 * auto job = new Akonadi::AgentInstanceCreateJob(type);
39 * connect(job, &KJob::result, this, &MyClass::slotCreated);
40 *
41 * // use this widget as parent for the config dialog
42 * job->configure(this);
43 *
44 * job->start();
45 * }
46 *
47 * ...
48 *
49 * void MyClass::slotCreated(KJob *job)
50 * {
51 * auto createJob = static_cast<Akonadi::AgentInstanceCreateJob*>(job);
52 *
53 * qDebug() << "Created agent instance:" << createJob->instance().identifier();
54 * }
55 * @endcode
56 *
57 * @note This is a KJob not an Akonadi::Job, so it won't auto-start!
58 *
59 * @author Volker Krause <vkrause@kde.org>
60 */
61class AKONADICORE_EXPORT AgentInstanceCreateJob : public KJob
62{
63 Q_OBJECT
64
65public:
66 /**
67 * Creates a new agent instance create job.
68 *
69 * @param type The type of the agent to create.
70 * @param parent The parent object.
71 */
72 explicit AgentInstanceCreateJob(const AgentType &type, QObject *parent = nullptr);
73
74 /**
75 * Creates a new agent instance create job.
76 *
77 * @param typeId The identifier of type of the agent to create.
78 * @param parent The parent object.
79 * @since 4.5
80 */
81 explicit AgentInstanceCreateJob(const QString &typeId, QObject *parent = nullptr);
82
83 /**
84 * Destroys the agent instance create job.
85 */
87
88 /**
89 * Setup the job to show agent configuration dialog once the agent instance
90 * has been successfully started.
91 * @param parent The parent window for the configuration dialog.
92 */
93 void configure(QWidget *parent = nullptr);
94
95 /**
96 * Returns the AgentInstance object of the newly created agent instance.
97 */
98 [[nodiscard]] AgentInstance instance() const;
99
100 /**
101 * Starts the instance creation.
102 */
103 void start() override;
104
105private:
106 /// @cond PRIVATE
107 friend class Akonadi::AgentInstanceCreateJobPrivate;
108 std::unique_ptr<AgentInstanceCreateJobPrivate> const d;
109 /// @endcond
110};
111
112}
Represents one agent instance and takes care of communication with it.
Job for creating new agent instances.
~AgentInstanceCreateJob() override
Destroys the agent instance create job.
A representation of an agent instance.
A representation of an agent type.
Q_SCRIPTABLE Q_NOREPLY void start()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:03:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.