KCMUtils

kcmoduledata.cpp
1/*
2 SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com>
3
4 SPDX-License-Identifier: LGPL-2.0-only
5*/
6
7#include "kcmoduledata.h"
8
9#include <QList>
10#include <QPointer>
11
12#include <KCoreConfigSkeleton>
13
14class KCModuleDataPrivate
15{
16public:
17 explicit KCModuleDataPrivate(KCModuleData *probe)
18 : _q(probe)
19 {
20 }
21
22 KCModuleData *_q;
24};
25
26KCModuleData::KCModuleData(QObject *parent)
27 : QObject(parent)
28 , d(new KCModuleDataPrivate(this))
29{
32 this,
33 [this] {
34 aboutToLoad(QPrivateSignal());
35 },
37}
38
39KCModuleData::~KCModuleData() = default;
40
42{
43 if (!skeleton || d->_skeletons.contains(skeleton)) {
44 return;
45 }
46
47 d->_skeletons.append(skeleton);
48}
49
51{
52 bool defaults = true;
53 for (const auto &skeleton : std::as_const(d->_skeletons)) {
54 defaults &= skeleton->isDefaults();
55 }
56 return defaults;
57}
58
60{
61 for (const auto &skeleton : std::as_const(d->_skeletons)) {
62 skeleton->useDefaults(true);
63 skeleton->save();
64 }
65}
66
68{
69 const auto skeletons = findChildren<KCoreConfigSkeleton *>();
70 for (auto *skeleton : skeletons) {
71 registerSkeleton(skeleton);
72 }
73}
74
75bool KCModuleData::matchesQuery(const QString &query) const
76{
77 // Currently not implemented, here for future use case
78 Q_UNUSED(query)
79 return false;
80}
81
82#include "moc_kcmoduledata.cpp"
A base class that offers information about a KCModule state.
virtual bool matchesQuery(const QString &query) const
Checks if this module matches a given query.
void registerSkeleton(KCoreConfigSkeleton *skeleton)
Allow to register manually skeleton class.
void autoRegisterSkeletons()
Automatically register child skeletons Call it in your subclass constructor after skeleton creation.
void aboutToLoad(QPrivateSignal)
Internal use.
virtual bool isDefaults() const
Checks if the configuration is identical to the default one.
void loaded()
This signal is emitted when KCModuleData is loaded.
virtual void revertToDefaults()
Revert module to default values and save them.
bool invokeMethod(QObject *context, Functor &&function, FunctorReturnType *ret)
QList< T > findChildren(Qt::FindChildOptions options) const const
QueuedConnection
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.