1/*
2 SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com>
3
4 SPDX-License-Identifier: LGPL-2.0-only
5*/
6
7#ifndef KCMODULEDATA_H
8#define KCMODULEDATA_H
9
10#include <QObject>
11#include <QVariantList>
12#include <kcmutilscore_export.h>
13#include <memory>
14
15class KCModuleDataPrivate;
16class KCoreConfigSkeleton;
17
18/**
19 * @short A base class that offers information about a KCModule state
20 *
21 * @author Benjamin Port <benjamin.port@enioka.com>
22 *
23 * @since 5.74
24 */
25class KCMUTILSCORE_EXPORT KCModuleData : public QObject
26{
27 Q_OBJECT
28public:
29 explicit KCModuleData(QObject *parent = nullptr);
30 ~KCModuleData() override;
31
32 /**
33 * Checks if the configuration is identical to the default one.
34 *
35 * @return @c true if the module configuration is in the default state, @c false otherwise
36 */
37 virtual bool isDefaults() const;
38
39 /**
40 * Revert module to default values and save them.
41 */
42 virtual void revertToDefaults();
43
44 /**
45 * Checks if this module matches a given query.
46 * @param query the text user search for, it is not expected to be a regex pattern but a full text search.
47 * @return @c true if this module matches a given query, @c false otherwise
48 */
49 virtual bool matchesQuery(const QString &query) const;
50
51Q_SIGNALS:
52 /**
53 * This signal is emitted when KCModuleData is loaded.
54 */
55 void loaded();
56
57 /**
58 * Internal use
59 *
60 * Triggers the emit of @see loaded() signal. This is the default behavior.
61 * To handle when loaded() is emitted in subclass, disconnect this signal in derived constructor.
62 */
63 void aboutToLoad(QPrivateSignal);
64
65protected Q_SLOTS:
66 /**
67 * Allow to register manually skeleton class.
68 * Used by derived class when automatic discovery is not possible.
69 */
70 void registerSkeleton(KCoreConfigSkeleton *skeleton);
71
72 /**
73 * Automatically register child skeletons
74 * Call it in your subclass constructor after skeleton creation
75 */
76 void autoRegisterSkeletons();
77
78private:
79 const std::unique_ptr<KCModuleDataPrivate> d;
80 friend class KCModuleDataPrivate;
81};
82
83#endif
84

source code of kcmutils/src/core/kcmoduledata.h