File indexing completed on 2024-05-12 03:54:31
0001 /* 0002 SPDX-FileCopyrightText: 2013 Marco Martin <notmart@gmail.com> 0003 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org> 0004 SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCONFIGPROPERTYMAP_H 0010 #define KCONFIGPROPERTYMAP_H 0011 0012 #include <QQmlPropertyMap> 0013 #include <memory> 0014 0015 class KCoreConfigSkeleton; 0016 0017 #include <kconfigqml_export.h> 0018 0019 class KConfigPropertyMapPrivate; 0020 0021 /** 0022 * @class KConfigPropertyMap configpropertymap.h ConfigPropertyMap 0023 * 0024 * An object that (optionally) automatically saves changes in a 0025 * property map to a configuration object (e.g. a KConfig file). 0026 * @since 5.89 0027 */ 0028 class KCONFIGQML_EXPORT KConfigPropertyMap : public QQmlPropertyMap 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 KConfigPropertyMap(KCoreConfigSkeleton *config, QObject *parent = nullptr); 0034 ~KConfigPropertyMap() override; 0035 0036 /** 0037 * Whether notifications on config changes are enabled. Disabled by default. 0038 * @see KConfigBase::Notify 0039 * @return true if writes send (dbus) notifications 0040 */ 0041 bool isNotify() const; 0042 0043 /** 0044 * Enable or disable notifications on config changes. 0045 * @see KConfigBase::Notify 0046 * @param notify whether to send notifications 0047 */ 0048 void setNotify(bool notify); 0049 0050 /** 0051 * @brief Whether the value at the given key is immutable 0052 * 0053 * @return true if the value is immutable, false if it isn't or it doesn't exist 0054 */ 0055 Q_INVOKABLE bool isImmutable(const QString &key) const; 0056 0057 /** 0058 * Saves the state of the property map on disk. 0059 */ 0060 Q_INVOKABLE void writeConfig(); 0061 0062 protected: 0063 QVariant updateValue(const QString &key, const QVariant &input) override; 0064 0065 private: 0066 std::unique_ptr<KConfigPropertyMapPrivate> const d; 0067 }; 0068 0069 #endif