Changeset View
Changeset View
Standalone View
Standalone View
src/core/kcoreconfigskeleton.h
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Line(s) | 55 | public: | |||
---|---|---|---|---|---|
205 | */ | 205 | */ | ||
206 | virtual void swapDefault() = 0; | 206 | virtual void swapDefault() = 0; | ||
207 | 207 | | |||
208 | /** | 208 | /** | ||
209 | * Return if the entry can be modified. | 209 | * Return if the entry can be modified. | ||
210 | */ | 210 | */ | ||
211 | bool isImmutable() const; | 211 | bool isImmutable() const; | ||
212 | 212 | | |||
213 | /** | ||||
214 | * Indicates if the item is set to its default value. | ||||
215 | * | ||||
216 | * @since 5.64 | ||||
kossebau: -> 5.64 | |||||
217 | */ | ||||
218 | bool isDefault() const; | ||||
davidedmundson: Is this an ABI break?
:/ | |||||
ervin: *gasp* you're right, how stupid of me... we can't merge that... | |||||
219 | | ||||
220 | /** | ||||
221 | * Indicates if the item has a different value than the | ||||
222 | * previously loaded value. | ||||
223 | * | ||||
224 | * @since 5.64 | ||||
225 | */ | ||||
226 | bool isSaveNeeded() const; | ||||
227 | | ||||
213 | protected: | 228 | protected: | ||
214 | /** | 229 | /** | ||
215 | * sets mIsImmutable to true if mKey in config is immutable | 230 | * sets mIsImmutable to true if mKey in config is immutable | ||
216 | * @param group KConfigGroup to check if mKey is immutable in | 231 | * @param group KConfigGroup to check if mKey is immutable in | ||
217 | */ | 232 | */ | ||
218 | void readImmutability(const KConfigGroup &group); | 233 | void readImmutability(const KConfigGroup &group); | ||
219 | 234 | | |||
220 | QString mGroup; ///< The group name for this item | 235 | QString mGroup; ///< The group name for this item | ||
221 | QString mKey; ///< The config key for this item | 236 | QString mKey; ///< The config key for this item | ||
222 | QString mName; ///< The name of this item | 237 | QString mName; ///< The name of this item | ||
223 | 238 | | |||
239 | // HACK: Necessary to avoid introducing new virtuals in KConfigSkeletonItem | ||||
240 | // KF6: Use proper pure virtuals in KConfigSkeletonItem | ||||
241 | void setIsDefaultImpl(const std::function<bool()> &impl); | ||||
242 | void setIsSaveNeededImpl(const std::function<bool()> &impl); | ||||
243 | | ||||
224 | private: | 244 | private: | ||
225 | KConfigSkeletonItemPrivate *const d; | 245 | KConfigSkeletonItemPrivate *const d; | ||
226 | }; | 246 | }; | ||
227 | 247 | | |||
228 | /** | 248 | /** | ||
229 | * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h <KConfigSkeletonGenericItem> | 249 | * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h <KConfigSkeletonGenericItem> | ||
230 | */ | 250 | */ | ||
231 | template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem | 251 | template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem | ||
232 | { | 252 | { | ||
233 | public: | 253 | public: | ||
234 | /** @copydoc KConfigSkeletonItem(const QString&, const QString&) | 254 | /** @copydoc KConfigSkeletonItem(const QString&, const QString&) | ||
235 | @param reference The initial value to hold in the item | 255 | @param reference The initial value to hold in the item | ||
236 | @param defaultValue The default value for the item | 256 | @param defaultValue The default value for the item | ||
237 | */ | 257 | */ | ||
238 | KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, | 258 | KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, | ||
239 | T defaultValue) | 259 | T defaultValue) | ||
240 | : KConfigSkeletonItem(_group, _key), mReference(reference), | 260 | : KConfigSkeletonItem(_group, _key), mReference(reference), | ||
241 | mDefault(defaultValue), mLoadedValue(defaultValue) | 261 | mDefault(defaultValue), mLoadedValue(defaultValue) | ||
242 | { | 262 | { | ||
263 | setIsDefaultImpl([this] { return mReference == mDefault; }); | ||||
264 | setIsSaveNeededImpl([this] { return mReference != mLoadedValue; }); | ||||
243 | } | 265 | } | ||
244 | 266 | | |||
245 | /** | 267 | /** | ||
246 | * Set value of this KConfigSkeletonItem. | 268 | * Set value of this KConfigSkeletonItem. | ||
247 | */ | 269 | */ | ||
248 | void setValue(const T &v) | 270 | void setValue(const T &v) | ||
249 | { | 271 | { | ||
250 | mReference = v; | 272 | mReference = v; | ||
▲ Show 20 Lines • Show All 822 Lines • ▼ Show 20 Line(s) | 1088 | #endif | |||
1073 | * This method calls usrRead() after reading the settings of the | 1095 | * This method calls usrRead() after reading the settings of the | ||
1074 | * registered items from the KConfig. You can override usrRead() | 1096 | * registered items from the KConfig. You can override usrRead() | ||
1075 | * in derived classes if you have special requirements. | 1097 | * in derived classes if you have special requirements. | ||
1076 | * @since 5.0 | 1098 | * @since 5.0 | ||
1077 | */ | 1099 | */ | ||
1078 | void read(); | 1100 | void read(); | ||
1079 | 1101 | | |||
1080 | /** | 1102 | /** | ||
1103 | * Indicates if all the registered items are set to their default value. | ||||
1104 | * | ||||
1105 | * @since 5.64 | ||||
1106 | */ | ||||
1107 | bool isDefaults() const; | ||||
1108 | | ||||
1109 | /** | ||||
1110 | * Indicates if any registered item has a different value than the | ||||
1111 | * previously loaded value. | ||||
1112 | * | ||||
1113 | * @since 5.64 | ||||
1114 | */ | ||||
1115 | bool isSaveNeeded() const; | ||||
1116 | | ||||
1117 | /** | ||||
1081 | * Set the config file group for subsequent addItem() calls. It is valid | 1118 | * Set the config file group for subsequent addItem() calls. It is valid | ||
1082 | * until setCurrentGroup() is called with a new argument. Call this before | 1119 | * until setCurrentGroup() is called with a new argument. Call this before | ||
1083 | * you add any items. The default value is "No Group". | 1120 | * you add any items. The default value is "No Group". | ||
1084 | */ | 1121 | */ | ||
1085 | void setCurrentGroup(const QString &group); | 1122 | void setCurrentGroup(const QString &group); | ||
1086 | 1123 | | |||
1087 | /** | 1124 | /** | ||
1088 | * Returns the current group used for addItem() calls. | 1125 | * Returns the current group used for addItem() calls. | ||
▲ Show 20 Lines • Show All 419 Lines • Show Last 20 Lines |
-> 5.64