File indexing completed on 2024-11-10 04:40:36

0001 /*
0002     SPDX-FileCopyrightText: 2018 Daniel Vrátil <dvratil@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "akonadicore_export.h"
0010 
0011 #include <KSharedConfig>
0012 #include <QObject>
0013 
0014 namespace Akonadi
0015 {
0016 class AgentConfigurationBase;
0017 class AKONADICORE_EXPORT AgentConfigurationFactoryBase : public QObject
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit AgentConfigurationFactoryBase(QObject *parent = nullptr);
0022     ~AgentConfigurationFactoryBase() override = default;
0023 
0024     virtual AgentConfigurationBase *create(const KSharedConfigPtr &config, QWidget *parent, const QVariantList &args) const = 0;
0025 };
0026 
0027 }
0028 
0029 #define AKONADI_AGENTCONFIG_FACTORY(FactoryName, metadata, ClassName)                                                                                          \
0030     class FactoryName : public Akonadi::AgentConfigurationFactoryBase                                                                                          \
0031     {                                                                                                                                                          \
0032         Q_OBJECT                                                                                                                                               \
0033         Q_PLUGIN_METADATA(IID "org.freedesktop.Akonadi.AgentConfig" FILE metadata)                                                                             \
0034     public:                                                                                                                                                    \
0035         FactoryName(QObject *parent = nullptr)                                                                                                                 \
0036             : Akonadi::AgentConfigurationFactoryBase(parent)                                                                                                   \
0037         {                                                                                                                                                      \
0038         }                                                                                                                                                      \
0039         Akonadi::AgentConfigurationBase *create(const KSharedConfigPtr &config, QWidget *parent, const QVariantList &args) const override                      \
0040         {                                                                                                                                                      \
0041             return new ClassName(config, parent, args);                                                                                                        \
0042         }                                                                                                                                                      \
0043     };