File indexing completed on 2026-08-09 07:09:55

0001 /*
0002     SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef KCMODULEDATA_H
0008 #define KCMODULEDATA_H
0009 
0010 #include <QObject>
0011 #include <QVariantList>
0012 #include <kcmutilscore_export.h>
0013 #include <memory>
0014 
0015 class KCModuleDataPrivate;
0016 class KCoreConfigSkeleton;
0017 
0018 /**
0019  * @short A base class that offers information about a KCModule state
0020  *
0021  * @author Benjamin Port <benjamin.port@enioka.com>
0022  *
0023  * @since 5.74
0024  */
0025 class KCMUTILSCORE_EXPORT KCModuleData : public QObject
0026 {
0027     Q_OBJECT
0028 public:
0029     explicit KCModuleData(QObject *parent = nullptr);
0030     ~KCModuleData() override;
0031 
0032     /**
0033      * Checks if the configuration is identical to the default one.
0034      *
0035      * @return @c true if the module configuration is in the default state, @c false otherwise
0036      */
0037     virtual bool isDefaults() const;
0038 
0039     /**
0040      * Revert module to default values and save them.
0041      */
0042     virtual void revertToDefaults();
0043 
0044     /**
0045      * Checks if this module matches a given query.
0046      * @param query the text user search for, it is not expected to be a regex pattern but a full text search.
0047      * @return @c true if this module matches a given query, @c false otherwise
0048      */
0049     virtual bool matchesQuery(const QString &query) const;
0050 
0051 Q_SIGNALS:
0052     /**
0053      * This signal is emitted when KCModuleData is loaded.
0054      */
0055     void loaded();
0056 
0057     /**
0058      * Internal use
0059      *
0060      * Triggers the emit of @see loaded() signal. This is the default behavior.
0061      * To handle when loaded() is emitted in subclass, disconnect this signal in derived constructor.
0062      */
0063     void aboutToLoad(QPrivateSignal);
0064 
0065 protected Q_SLOTS:
0066     /**
0067      * Allow to register manually skeleton class.
0068      * Used by derived class when automatic discovery is not possible.
0069      */
0070     void registerSkeleton(KCoreConfigSkeleton *skeleton);
0071 
0072     /**
0073      * Automatically register child skeletons
0074      * Call it in your subclass constructor after skeleton creation
0075      */
0076     void autoRegisterSkeletons();
0077 
0078 private:
0079     const std::unique_ptr<KCModuleDataPrivate> d;
0080     friend class KCModuleDataPrivate;
0081 };
0082 
0083 #endif