File indexing completed on 2024-04-21 14:53:50
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2020 Benjamin Port <benjamin.port@enioka.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KCMODULEDATA_H 0009 #define KCMODULEDATA_H 0010 0011 #include <QObject> 0012 #include <QVariantList> 0013 #include <kcmutils_export.h> 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 KCMUTILS_EXPORT KCModuleData : public QObject 0026 { 0027 Q_OBJECT 0028 public: 0029 explicit KCModuleData(QObject *parent = nullptr, const QVariantList &args = QVariantList()); 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 protected: 0079 virtual void virtual_hook(int id, void *data); 0080 0081 private: 0082 KCModuleDataPrivate *const d; 0083 friend class KCModuleDataPrivate; 0084 }; 0085 0086 #endif