| 1 | /* |
| 2 | This file is part of KOrganizer. |
| 3 | SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org> |
| 4 | SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> |
| 5 | |
| 6 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | #ifndef KCORECONFIGSKELETON_P_H |
| 10 | #define KCORECONFIGSKELETON_P_H |
| 11 | |
| 12 | #include "kcoreconfigskeleton.h" |
| 13 | |
| 14 | class KCoreConfigSkeletonPrivate |
| 15 | { |
| 16 | public: |
| 17 | KCoreConfigSkeletonPrivate() |
| 18 | : mCurrentGroup(QStringLiteral("No Group" )) |
| 19 | , mUseDefaults(false) |
| 20 | { |
| 21 | } |
| 22 | ~KCoreConfigSkeletonPrivate() |
| 23 | { |
| 24 | qDeleteAll(c: mItems); |
| 25 | } |
| 26 | QString mCurrentGroup; |
| 27 | |
| 28 | KSharedConfig::Ptr mConfig; // pointer to KConfig object |
| 29 | |
| 30 | KConfigSkeletonItem::List mItems; |
| 31 | KConfigSkeletonItem::Dict mItemDict; |
| 32 | |
| 33 | bool mUseDefaults; |
| 34 | }; |
| 35 | |
| 36 | class KConfigSkeletonItemPrivate |
| 37 | { |
| 38 | public: |
| 39 | KConfigSkeletonItemPrivate() |
| 40 | : mIsImmutable(true) |
| 41 | , mWriteFlags(KConfigBase::Normal) |
| 42 | { |
| 43 | } |
| 44 | virtual ~KConfigSkeletonItemPrivate(); |
| 45 | bool mIsImmutable; ///< Indicates this item is immutable |
| 46 | KConfigBase::WriteConfigFlags mWriteFlags; ///< The flags to pass to calls of writeEntry() and revertToDefault() |
| 47 | |
| 48 | QString mLabel; ///< The label for this item |
| 49 | QString mToolTip; ///< The ToolTip text for this item |
| 50 | QString mWhatsThis; ///< The What's This text for this item |
| 51 | KConfigGroup mConfigGroup; ///< KConfigGroup, allow to read/write item in nested groups |
| 52 | |
| 53 | // HACK: Necessary to avoid introducing new virtuals in KConfigSkeletonItem |
| 54 | std::function<bool()> mIsDefaultImpl; |
| 55 | std::function<bool()> mIsSaveNeededImpl; |
| 56 | std::function<QVariant()> mGetDefaultImpl; |
| 57 | }; |
| 58 | |
| 59 | class KPropertySkeletonItemPrivate : public KConfigSkeletonItemPrivate |
| 60 | { |
| 61 | public: |
| 62 | KPropertySkeletonItemPrivate(QObject *object, const QByteArray &propertyName, const QVariant &defaultValue) |
| 63 | : KConfigSkeletonItemPrivate() |
| 64 | , mObject(object) |
| 65 | , mPropertyName(propertyName) |
| 66 | , mDefaultValue(defaultValue) |
| 67 | , mConstDefaultValue(defaultValue) |
| 68 | { |
| 69 | mIsImmutable = false; |
| 70 | } |
| 71 | |
| 72 | QObject *mObject; |
| 73 | const QByteArray mPropertyName; |
| 74 | QVariant mDefaultValue; |
| 75 | const QVariant mConstDefaultValue; |
| 76 | QVariant mReference; |
| 77 | QVariant mLoadedValue; |
| 78 | std::function<void()> mNotifyFunction; |
| 79 | }; |
| 80 | |
| 81 | #endif |
| 82 | |