File indexing completed on 2024-05-12 15:34:12
0001 /* 0002 This file is part of KOrganizer. 0003 SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 0004 SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCORECONFIGSKELETON_P_H 0010 #define KCORECONFIGSKELETON_P_H 0011 0012 #include "kcoreconfigskeleton.h" 0013 0014 class KCoreConfigSkeletonPrivate 0015 { 0016 public: 0017 KCoreConfigSkeletonPrivate() 0018 : mCurrentGroup(QStringLiteral("No Group")) 0019 , mUseDefaults(false) 0020 { 0021 } 0022 ~KCoreConfigSkeletonPrivate() 0023 { 0024 qDeleteAll(mItems); 0025 } 0026 QString mCurrentGroup; 0027 0028 KSharedConfig::Ptr mConfig; // pointer to KConfig object 0029 0030 KConfigSkeletonItem::List mItems; 0031 KConfigSkeletonItem::Dict mItemDict; 0032 0033 bool mUseDefaults; 0034 }; 0035 0036 class KConfigSkeletonItemPrivate 0037 { 0038 public: 0039 KConfigSkeletonItemPrivate() 0040 : mIsImmutable(true) 0041 , mWriteFlags(KConfigBase::Normal) 0042 { 0043 } 0044 virtual ~KConfigSkeletonItemPrivate(); 0045 bool mIsImmutable; ///< Indicates this item is immutable 0046 KConfigBase::WriteConfigFlags mWriteFlags; ///< The flags to pass to calls of writeEntry() and revertToDefault() 0047 0048 QString mLabel; ///< The label for this item 0049 QString mToolTip; ///< The ToolTip text for this item 0050 QString mWhatsThis; ///< The What's This text for this item 0051 KConfigGroup mConfigGroup; ///< KConfigGroup, allow to read/write item in nested groups 0052 QHash<QString, QString> mValues; /// The values used for ItemEnum's choices, name -> value (if set) 0053 0054 // HACK: Necessary to avoid introducing new virtuals in KConfigSkeletonItem 0055 std::function<bool()> mIsDefaultImpl; 0056 std::function<bool()> mIsSaveNeededImpl; 0057 std::function<QVariant()> mGetDefaultImpl; 0058 }; 0059 0060 class KPropertySkeletonItemPrivate : public KConfigSkeletonItemPrivate 0061 { 0062 public: 0063 KPropertySkeletonItemPrivate(QObject *object, const QByteArray &propertyName, const QVariant &defaultValue) 0064 : KConfigSkeletonItemPrivate() 0065 , mObject(object) 0066 , mPropertyName(propertyName) 0067 , mDefaultValue(defaultValue) 0068 , mConstDefaultValue(defaultValue) 0069 { 0070 mIsImmutable = false; 0071 } 0072 0073 QObject *mObject; 0074 const QByteArray mPropertyName; 0075 QVariant mDefaultValue; 0076 const QVariant mConstDefaultValue; 0077 QVariant mReference; 0078 QVariant mLoadedValue; 0079 std::function<void()> mNotifyFunction; 0080 }; 0081 0082 #endif