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/test3.h.ref | 40 ++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'autotests/kconfig_compiler/test3.h.ref') diff --git a/autotests/kconfig_compiler/test3.h.ref b/autotests/kconfig_compiler/test3.h.ref index 2b8ef539..7dde3de0 100644 --- a/autotests/kconfig_compiler/test3.h.ref +++ b/autotests/kconfig_compiler/test3.h.ref @@ -22,7 +22,7 @@ class Test3 : public KConfigSkeleton */ void setAutoSave( bool v ) { - if (!isImmutable( QStringLiteral( "AutoSave" ) )) + if (!isAutoSaveImmutable()) mAutoSave = v; } @@ -34,6 +34,14 @@ class Test3 : public KConfigSkeleton return mAutoSave; } + /** + Is Enable automatic saving of calendar Immutable + */ + bool isAutoSaveImmutable() const + { + return isImmutable( QStringLiteral( "AutoSave" ) ); + } + /** Get Item object corresponding to AutoSave() */ @@ -47,7 +55,7 @@ class Test3 : public KConfigSkeleton */ void setBlubb( int v ) { - if (!isImmutable( QStringLiteral( "Blubb" ) )) + if (!isBlubbImmutable()) mBlubb = v; } @@ -59,6 +67,14 @@ class Test3 : public KConfigSkeleton return mBlubb; } + /** + Is Blubb Immutable + */ + bool isBlubbImmutable() const + { + return isImmutable( QStringLiteral( "Blubb" ) ); + } + /** Get Item object corresponding to Blubb() */ @@ -72,7 +88,7 @@ class Test3 : public KConfigSkeleton */ void setBlahBlah( const QString & v ) { - if (!isImmutable( QStringLiteral( "BlahBlah" ) )) + if (!isBlahBlahImmutable()) mBlahBlah = v; } @@ -84,6 +100,14 @@ class Test3 : public KConfigSkeleton return mBlahBlah; } + /** + Is BlahBlah Immutable + */ + bool isBlahBlahImmutable() const + { + return isImmutable( QStringLiteral( "BlahBlah" ) ); + } + /** Get Item object corresponding to BlahBlah() */ @@ -97,7 +121,7 @@ class Test3 : public KConfigSkeleton */ void setMyPassword( const QString & v ) { - if (!isImmutable( QStringLiteral( "MyPassword" ) )) + if (!isMyPasswordImmutable()) mMyPassword = v; } @@ -109,6 +133,14 @@ class Test3 : public KConfigSkeleton return mMyPassword; } + /** + Is MyPassword Immutable + */ + bool isMyPasswordImmutable() const + { + return isImmutable( QStringLiteral( "MyPassword" ) ); + } + /** Get Item object corresponding to MyPassword() */ -- cgit v1.2.1