File indexing completed on 2024-05-05 16:07:09
0001 /* 0002 SPDX-FileCopyrightText: 2013 Marco Martin <notmart@gmail.com> 0003 SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef CONFIGPROPERTYMAP_H 0009 #define CONFIGPROPERTYMAP_H 0010 0011 #include <kdeclarative/kdeclarative_export.h> 0012 0013 #if KDECLARATIVE_ENABLE_DEPRECATED_SINCE(5, 89) 0014 0015 #include <QQmlPropertyMap> 0016 0017 class KCoreConfigSkeleton; 0018 0019 namespace KDeclarative 0020 { 0021 class ConfigPropertyMapPrivate; 0022 0023 /** 0024 * @class KDeclarative::ConfigPropertyMap configpropertymap.h KDeclarative/ConfigPropertyMap 0025 * 0026 * An object that (optionally) automatically saves changes in a 0027 * property map to a configuration object (e.g. a KConfig file). 0028 * @deprecated Since 5.91, use KConfigPropertyMap from KConfig KConfigQml module instead. 0029 * The replacement class does not provide any autosave behavior, instead it requires 0030 * an explicit writeConfig call. 0031 */ 0032 class KDECLARATIVE_EXPORT ConfigPropertyMap : public QQmlPropertyMap 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 KDECLARATIVE_DEPRECATED_VERSION(5, 91, "See class API docs") 0038 ConfigPropertyMap(KCoreConfigSkeleton *config, QObject *parent = nullptr); 0039 ~ConfigPropertyMap() override; 0040 0041 /** 0042 * Indicates if the map calls save() on the config object on each write or not 0043 * 0044 * @return true if the map automatically saves (the default), false otherwise 0045 * @since 5.65 0046 */ 0047 bool isAutosave() const; 0048 0049 /** 0050 * Allows to set the map into autosave mode or not 0051 * 0052 * @param autosave the new value for autosaving 0053 * @since 5.65 0054 */ 0055 void setAutosave(bool autosave); 0056 0057 /** 0058 * Whether notifications on config changes are enabled. Disabled by default. 0059 * @see KConfigBase::Notify 0060 * @return true if writes send (dbus) notifications 0061 * @since 5.73 0062 */ 0063 bool isNotify() const; 0064 0065 /** 0066 * Enable or disable notifications on config changes. 0067 * @see KConfigBase::Notify 0068 * @param notify whether to send notifications 0069 * @since 5.73 0070 */ 0071 void setNotify(bool notify); 0072 0073 /** 0074 * @brief Whether the value at the given key is immutable 0075 * 0076 * @return true if the value is immutable, false if it isn't or it doesn't exist 0077 */ 0078 Q_INVOKABLE bool isImmutable(const QString &key) const; 0079 0080 protected: 0081 QVariant updateValue(const QString &key, const QVariant &input) override; 0082 0083 private: 0084 ConfigPropertyMapPrivate *const d; 0085 }; 0086 0087 } 0088 0089 #endif 0090 #endif