KCMUtils

kcmoduledata.cpp
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 2020 Benjamin Port <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-only
6 */
7 
8 #include "kcmoduledata.h"
9 
10 #include <QList>
11 #include <QPointer>
12 
13 #include <KCoreConfigSkeleton>
14 
15 class KCModuleDataPrivate
16 {
17 public:
18  explicit KCModuleDataPrivate(KCModuleData *probe)
19  : _q(probe)
20  {
21  }
22 
23  KCModuleData *_q;
25 };
26 
27 KCModuleData::KCModuleData(QObject *parent, const QVariantList &)
28  : QObject(parent)
29  , d(new KCModuleDataPrivate(this))
30 {
32  QMetaObject::invokeMethod(this, [this] { aboutToLoad(QPrivateSignal()); }, Qt::QueuedConnection);
33 }
34 
35 KCModuleData::~KCModuleData()
36 {
37  delete d;
38 }
39 
40 void KCModuleData::virtual_hook(int, void *)
41 {
42 }
43 
45 {
46  if (!skeleton || d->_skeletons.contains(skeleton)) {
47  return;
48  }
49 
50  d->_skeletons.append(skeleton);
51 }
52 
54 {
55  bool defaults = true;
56  for (const auto &skeleton : std::as_const(d->_skeletons)) {
57  defaults &= skeleton->isDefaults();
58  }
59  return defaults;
60 }
61 
63 {
64  for (const auto &skeleton : std::as_const(d->_skeletons)) {
65  skeleton->useDefaults(true);
66  skeleton->save();
67  }
68 }
69 
71 {
72  const auto skeletons = findChildren<KCoreConfigSkeleton *>();
73  for (auto *skeleton : skeletons) {
74  registerSkeleton(skeleton);
75  }
76 }
77 
78 bool KCModuleData::matchesQuery(const QString &query) const
79 {
80  // Currently not implemented, here for future use case
81  Q_UNUSED(query)
82  return false;
83 }
84 
85 #include "moc_kcmoduledata.cpp"
void loaded()
This signal is emitted when KCModuleData is loaded.
void autoRegisterSkeletons()
Automatically register child skeletons Call it in your subclass constructor after skeleton creation.
virtual void revertToDefaults()
Revert module to default values and save them.
void registerSkeleton(KCoreConfigSkeleton *skeleton)
Allow to register manually skeleton class.
Definition: dialog.h:19
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QueuedConnection
A base class that offers information about a KCModule state.
Definition: kcmoduledata.h:25
virtual bool matchesQuery(const QString &query) const
Checks if this module matches a given query.
bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0, QGenericArgument val1, QGenericArgument val2, QGenericArgument val3, QGenericArgument val4, QGenericArgument val5, QGenericArgument val6, QGenericArgument val7, QGenericArgument val8, QGenericArgument val9)
virtual bool isDefaults() const
Checks if the configuration is identical to the default one.
void aboutToLoad(QPrivateSignal)
Internal use.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:17:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.