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/test8a.h.ref | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'autotests/kconfig_compiler/test8a.h.ref') diff --git a/autotests/kconfig_compiler/test8a.h.ref b/autotests/kconfig_compiler/test8a.h.ref index 3e890946..9e9c0f4e 100644 --- a/autotests/kconfig_compiler/test8a.h.ref +++ b/autotests/kconfig_compiler/test8a.h.ref @@ -20,7 +20,7 @@ class Test8a : public KConfigSkeleton */ void setFont( const QFont & v ) { - if (!isImmutable( QStringLiteral( "Font" ) )) + if (!isFontImmutable()) mFont = v; } @@ -32,12 +32,20 @@ class Test8a : public KConfigSkeleton return mFont; } + /** + Is Font Immutable + */ + bool isFontImmutable() const + { + return isImmutable( QStringLiteral( "Font" ) ); + } + /** Set TitleFont */ void setTitleFont( const QFont & v ) { - if (!isImmutable( QStringLiteral( "TitleFont" ) )) + if (!isTitleFontImmutable()) mTitleFont = v; } @@ -49,6 +57,14 @@ class Test8a : public KConfigSkeleton return mTitleFont; } + /** + Is TitleFont Immutable + */ + bool isTitleFontImmutable() const + { + return isImmutable( QStringLiteral( "TitleFont" ) ); + } + protected: // Group -- cgit v1.2.1