Changeset View
Changeset View
Standalone View
Standalone View
src/core/kcoreconfigskeleton.h
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Line(s) | 57 | public: | |||
---|---|---|---|---|---|
238 | /** | 238 | /** | ||
239 | * Indicates if the item has a different value than the | 239 | * Indicates if the item has a different value than the | ||
240 | * previously loaded value. | 240 | * previously loaded value. | ||
241 | * | 241 | * | ||
242 | * @since 5.64 | 242 | * @since 5.64 | ||
243 | */ | 243 | */ | ||
244 | bool isSaveNeeded() const; | 244 | bool isSaveNeeded() const; | ||
245 | 245 | | |||
246 | /** | ||||
247 | * Return the last loaded value of this KConfigSkeletonItem. | ||||
248 | * | ||||
249 | * @since 5.68 | ||||
250 | */ | ||||
251 | QVariant loadedValue() const; | ||||
252 | | ||||
246 | protected: | 253 | protected: | ||
247 | explicit KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd, const QString &_group, const QString &_key); | 254 | explicit KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd, const QString &_group, const QString &_key); | ||
248 | 255 | | |||
249 | /** | 256 | /** | ||
250 | * sets mIsImmutable to true if mKey in config is immutable | 257 | * sets mIsImmutable to true if mKey in config is immutable | ||
251 | * @param group KConfigGroup to check if mKey is immutable in | 258 | * @param group KConfigGroup to check if mKey is immutable in | ||
252 | */ | 259 | */ | ||
253 | void readImmutability(const KConfigGroup &group); | 260 | void readImmutability(const KConfigGroup &group); | ||
254 | 261 | | |||
255 | QString mGroup; ///< The group name for this item | 262 | QString mGroup; ///< The group name for this item | ||
256 | QString mKey; ///< The config key for this item | 263 | QString mKey; ///< The config key for this item | ||
257 | QString mName; ///< The name of this item | 264 | QString mName; ///< The name of this item | ||
258 | 265 | | |||
259 | // HACK: Necessary to avoid introducing new virtuals in KConfigSkeletonItem | 266 | // HACK: Necessary to avoid introducing new virtuals in KConfigSkeletonItem | ||
260 | // KF6: Use proper pure virtuals in KConfigSkeletonItem | 267 | // KF6: Use proper pure virtuals in KConfigSkeletonItem | ||
261 | void setIsDefaultImpl(const std::function<bool()> &impl); | 268 | void setIsDefaultImpl(const std::function<bool()> &impl); | ||
262 | void setIsSaveNeededImpl(const std::function<bool()> &impl); | 269 | void setIsSaveNeededImpl(const std::function<bool()> &impl); | ||
270 | void setLoadedValueImpl(const std::function<QVariant()> &impl); | ||||
263 | 271 | | |||
264 | KConfigSkeletonItemPrivate *const d_ptr; | 272 | KConfigSkeletonItemPrivate *const d_ptr; | ||
265 | }; | 273 | }; | ||
266 | 274 | | |||
267 | class KPropertySkeletonItemPrivate; | 275 | class KPropertySkeletonItemPrivate; | ||
268 | 276 | | |||
269 | /** | 277 | /** | ||
270 | * \class KPropertySkeletonItem kcoreconfigskeleton.h <KCoreConfigSkeleton> | 278 | * \class KPropertySkeletonItem kcoreconfigskeleton.h <KCoreConfigSkeleton> | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 336 | public: | |||
332 | */ | 340 | */ | ||
333 | KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, | 341 | KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, | ||
334 | T defaultValue) | 342 | T defaultValue) | ||
335 | : KConfigSkeletonItem(_group, _key), mReference(reference), | 343 | : KConfigSkeletonItem(_group, _key), mReference(reference), | ||
336 | mDefault(defaultValue), mLoadedValue(defaultValue) | 344 | mDefault(defaultValue), mLoadedValue(defaultValue) | ||
337 | { | 345 | { | ||
338 | setIsDefaultImpl([this] { return mReference == mDefault; }); | 346 | setIsDefaultImpl([this] { return mReference == mDefault; }); | ||
339 | setIsSaveNeededImpl([this] { return mReference != mLoadedValue; }); | 347 | setIsSaveNeededImpl([this] { return mReference != mLoadedValue; }); | ||
348 | setLoadedValueImpl([this] { return QVariant::fromValue<T>(mLoadedValue); }); | ||||
340 | } | 349 | } | ||
341 | 350 | | |||
342 | /** | 351 | /** | ||
343 | * Set value of this KConfigSkeletonItem. | 352 | * Set value of this KConfigSkeletonItem. | ||
344 | */ | 353 | */ | ||
345 | void setValue(const T &v) | 354 | void setValue(const T &v) | ||
346 | { | 355 | { | ||
347 | mReference = v; | 356 | mReference = v; | ||
▲ Show 20 Lines • Show All 1291 Lines • Show Last 20 Lines |