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 #include "agentconfigurationbase.h"
0008 #include "akonadicore_debug.h"
0009 
0010 #include <KAboutData>
0011 #include <QSize>
0012 
0013 namespace Akonadi
0014 {
0015 class AgentConfigurationBasePrivate
0016 {
0017 public:
0018     AgentConfigurationBasePrivate(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args)
0019         : config(config)
0020         , parentWidget(parentWidget)
0021     {
0022         Q_ASSERT(!args.empty());
0023         if (args.empty()) {
0024             qCCritical(AKONADICORE_LOG, "AgentConfigurationBase instantiated with invalid arguments");
0025             return;
0026         }
0027         identifier = args.at(0).toString();
0028     }
0029 
0030     KSharedConfigPtr config;
0031     QString identifier;
0032     QScopedPointer<KAboutData> aboutData;
0033     QWidget *const parentWidget;
0034 };
0035 } // namespace Akonadi
0036 
0037 using namespace Akonadi;
0038 
0039 AgentConfigurationBase::AgentConfigurationBase(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args)
0040     : QObject(reinterpret_cast<QObject *>(parentWidget))
0041     , d(new AgentConfigurationBasePrivate(config, parentWidget, args))
0042 {
0043 }
0044 
0045 AgentConfigurationBase::~AgentConfigurationBase()
0046 {
0047 }
0048 
0049 KSharedConfigPtr AgentConfigurationBase::config() const
0050 {
0051     return d->config;
0052 }
0053 
0054 QString AgentConfigurationBase::identifier() const
0055 {
0056     return d->identifier;
0057 }
0058 
0059 void AgentConfigurationBase::load()
0060 {
0061     d->config->reparseConfiguration();
0062 }
0063 
0064 bool AgentConfigurationBase::save() const
0065 {
0066     d->config->sync();
0067     d->config->reparseConfiguration();
0068     return true;
0069 }
0070 
0071 QWidget *AgentConfigurationBase::parentWidget() const
0072 {
0073     return d->parentWidget;
0074 }
0075 
0076 void AgentConfigurationBase::setKAboutData(const KAboutData &aboutData)
0077 {
0078     d->aboutData.reset(new KAboutData(aboutData));
0079 }
0080 
0081 KAboutData *AgentConfigurationBase::aboutData() const
0082 {
0083     return d->aboutData.data();
0084 }
0085 
0086 QSize AgentConfigurationBase::restoreDialogSize() const
0087 {
0088     return {};
0089 }
0090 
0091 void AgentConfigurationBase::saveDialogSize(const QSize & /*unused*/) // clazy:exclude=function-args-by-value
0092 {
0093 }
0094 
0095 QDialogButtonBox::StandardButtons AgentConfigurationBase::standardButtons() const
0096 {
0097     return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel;
0098 }
0099 
0100 #include "moc_agentconfigurationbase.cpp"