Akonadi

agentconfigurationbase.cpp
1 /*
2  Copyright (c) 2018 Daniel Vrátil <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "agentconfigurationbase.h"
21 #include "agentmanager.h"
22 #include "akonadicore_debug.h"
23 
24 
25 #include <KAboutData>
26 #include <QDialogButtonBox>
27 #include <QSize>
28 
29 namespace Akonadi {
30 class Q_DECL_HIDDEN AgentConfigurationBase::Private {
31 public:
32  Private(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args)
33  : config(config)
34  , parentWidget(parentWidget)
35  {
36  Q_ASSERT(args.size() >= 1);
37  if (args.empty()) {
38  qCCritical(AKONADICORE_LOG, "AgentConfigurationBase instantiated with invalid arguments");
39  return;
40  }
41  identifier = args.at(0).toString();
42  }
43 
44  KSharedConfigPtr config;
45  QString identifier;
47  QWidget *parentWidget = nullptr;
48 };
49 }
50 
51 using namespace Akonadi;
52 
53 AgentConfigurationBase::AgentConfigurationBase(const KSharedConfigPtr &config,
54  QWidget *parentWidget,
55  const QVariantList &args)
56  : QObject(reinterpret_cast<QObject*>(parentWidget))
57  , d(new Private(config, parentWidget, args))
58 {
59 }
60 
61 AgentConfigurationBase::~AgentConfigurationBase()
62 {
63 }
64 
65 KSharedConfigPtr AgentConfigurationBase::config() const
66 {
67  return d->config;
68 }
69 
71 {
72  return d->identifier;
73 }
74 
76 {
77  d->config->reparseConfiguration();
78 }
79 
81 {
82  d->config->sync();
83  d->config->reparseConfiguration();
84  return true;
85 }
86 
87 QWidget *AgentConfigurationBase::parentWidget() const
88 {
89  return d->parentWidget;
90 }
91 
93 {
94  d->aboutData.reset(new KAboutData(aboutData));
95 }
96 
98 {
99  return d->aboutData.data();
100 }
101 
103 {
104  return {};
105 }
106 
108 {}
109 
110 QDialogButtonBox::StandardButtons AgentConfigurationBase::standardButtons() const
111 {
112  return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel;
113 }
QString identifier() const
Returns identifier of the Akonadi agent instance currently being configured.
virtual QSize restoreDialogSize() const
Reimplement to restore dialog size.
void setKAboutData(const KAboutData &aboutData)
When KAboutData is provided the dialog will also contain KHelpMenu with access to user help etc...
virtual void load()
Reimplement to load settings from the configuration object into widgets.
void reset(T *other)
virtual void saveDialogSize(const QSize &size)
Reimplement to save dialog size.
virtual bool save() const
Reimplement to save new settings into the configuration object.
T * data() const const
Base class for configuration UI for Akonadi agents.
typedef StandardButtons
KAboutData * aboutData() const
Returns about data for the currently configured component.
Helper integration between Akonadi and Qt.
KSharedConfigPtr config() const
Returns KConfig object belonging to the current Akonadi agent instance.
AgentConfigurationBase(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args)
Creates a new AgentConfigurationBase objects.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:08:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.