From d46739294d04c72af1e434e414e1c012d7e78a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Tue, 4 Feb 2020 16:03:52 +0100 Subject: Add an isImmutable to know if a property is immutable Summary: Add a utility function isImmutable to access immutability quickly. Generated classes uses them internally to avoid code redundance. Sample: ``` /** Set blocked-by-default */ void setBlockedByDefault( bool v ) { if (v != mBlockedByDefault && !isBlockedByDefaultImmutable() ) { mBlockedByDefault = v; Q_EMIT blockedByDefaultChanged(); } } /** Is blocked-by-default Immutable */ bool isBlockedByDefaultImmutable() { return isImmutable( QStringLiteral( "blockedByDefault" ) ); } ``` ``` /** Set org.kde.ActivityManager.ResourceScoringEnabled */ void setResourceScoringEnabled( bool v ) { if (!isResourceScoringEnabledImmutable() ) mResourceScoringEnabled = v; } /** Is org.kde.ActivityManager.ResourceScoringEnabled Immutable */ bool isResourceScoringEnabledImmutable() { return isImmutable( QStringLiteral( "resourceScoringEnabled" ) ); } ``` Reviewers: ervin, #frameworks, dfaure Reviewed By: ervin Subscribers: dfaure, tcanabrava, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D26368 --- autotests/kconfig_compiler/test13.h.ref | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'autotests/kconfig_compiler/test13.h.ref') diff --git a/autotests/kconfig_compiler/test13.h.ref b/autotests/kconfig_compiler/test13.h.ref index 3a6e7f89..6dad0e57 100644 --- a/autotests/kconfig_compiler/test13.h.ref +++ b/autotests/kconfig_compiler/test13.h.ref @@ -17,6 +17,7 @@ class Test13 : public KConfigSkeleton ~Test13(); Q_PROPERTY(QUrl picturesDir READ picturesDir CONSTANT) + Q_PROPERTY(bool isPicturesDirImmutable CONSTANT) /** Get picturesDir */ @@ -25,18 +26,27 @@ class Test13 : public KConfigSkeleton return mPicturesDir; } + /** + Is picturesDir Immutable + */ + bool isPicturesDirImmutable() const + { + return isImmutable( QStringLiteral( "picturesDir" ) ); + } + /** Set brightness */ void setBrightness( double v ) { - if (v != mBrightness && !isImmutable( QStringLiteral( "brightness" ) )) { + if (v != mBrightness && !isBrightnessImmutable()) { mBrightness = v; Q_EMIT brightnessChanged(); } } Q_PROPERTY(double brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) + Q_PROPERTY(bool isBrightnessImmutable CONSTANT) /** Get brightness */ @@ -45,7 +55,16 @@ class Test13 : public KConfigSkeleton return mBrightness; } + /** + Is brightness Immutable + */ + bool isBrightnessImmutable() const + { + return isImmutable( QStringLiteral( "brightness" ) ); + } + Q_PROPERTY(bool startsWithUppercase READ startsWithUppercase CONSTANT) + Q_PROPERTY(bool isStartsWithUppercaseImmutable CONSTANT) /** Get StartsWithUppercase */ @@ -54,6 +73,14 @@ class Test13 : public KConfigSkeleton return mStartsWithUppercase; } + /** + Is StartsWithUppercase Immutable + */ + bool isStartsWithUppercaseImmutable() const + { + return isImmutable( QStringLiteral( "StartsWithUppercase" ) ); + } + enum { signalBrightnessChanged = 0x1 -- cgit v1.2.1