Akonadi::AgentInstanceCreateJob Class
class Akonadi::AgentInstanceCreateJobJob for creating new agent instances. More...
| Header: | #include <Akonadi/AgentInstanceCreateJob> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS AkonadiCore)target_link_libraries(mytarget PRIVATE KPim6::AkonadiCore) |
Public Functions
| AgentInstanceCreateJob(const Akonadi::AgentType &type, QObject *parent = nullptr) | |
| AgentInstanceCreateJob(const QString &typeId, QObject *parent = nullptr) | |
| virtual | ~AgentInstanceCreateJob() override |
| Akonadi::AgentInstance | instance() const |
Reimplemented Public Functions
| virtual void | start() override |
Detailed Description
This class encapsulates the procedure of creating a new agent instance and optionally configuring it immediately.
Example:
using namespace Qt::StringLiterals; MyClass::MyClass(QWidget *parent) : QWidget(parent) { // Get agent type object Akonadi::AgentType type = Akonadi::AgentManager::self()->type(u"akonadi_vcard_resource"_s); auto job = new Akonadi::AgentInstanceCreateJob(type); // Open configuration dialog once created connect(job, &Akonadi::AgentInstanceCreateJob::result, this, [this, job](KJob *) { if (job->error()) { return; } auto configureDialog = new Akonadi::AgentConfigurationDialog(job->instance(), this); configureDialog->setAttribute(Qt::WA_DeleteOnClose); connect(configureDialog, &QDialog::rejected, this, [instance = job->instance()] { Akonadi::AgentManager::self()->removeInstance(instance); }); configureDialog->show(); }); job->start(); } ... void MyClass::slotCreated(KJob *job) { auto createJob = static_cast<Akonadi::AgentInstanceCreateJob*>(job); qDebug() << "Created agent instance:" << createJob->instance().identifier(); }
Note: This is a KJob not an Akonadi::Job, so it won't auto-start!
Author: Volker Krause <vkrause@kde.org>
Member Function Documentation
[explicit] AgentInstanceCreateJob::AgentInstanceCreateJob(const Akonadi::AgentType &type, QObject *parent = nullptr)
Creates a new agent instance create job.
type The type of the agent to create. parent The parent object.
[explicit] AgentInstanceCreateJob::AgentInstanceCreateJob(const QString &typeId, QObject *parent = nullptr)
Creates a new agent instance create job.
typeId The identifier of type of the agent to create. parent The parent object.
[override virtual noexcept] AgentInstanceCreateJob::~AgentInstanceCreateJob()
Destroys the agent instance create job.
Akonadi::AgentInstance AgentInstanceCreateJob::instance() const
Returns the AgentInstance object of the newly created agent instance.
[override virtual] void AgentInstanceCreateJob::start()
Starts the instance creation.