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/test8c.h.ref | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'autotests/kconfig_compiler/test8c.h.ref') diff --git a/autotests/kconfig_compiler/test8c.h.ref b/autotests/kconfig_compiler/test8c.h.ref index 57469dca..7e96da0b 100644 --- a/autotests/kconfig_compiler/test8c.h.ref +++ b/autotests/kconfig_compiler/test8c.h.ref @@ -22,7 +22,7 @@ class Test8c : public KConfigSkeleton static void setFont( const QFont & v ) { - if (!self()->isImmutable( QStringLiteral( "Font" ) )) + if (!self()->isFontImmutable()) self()->mFont = v; } @@ -35,13 +35,22 @@ class Test8c : public KConfigSkeleton return self()->mFont; } + /** + Is Font Immutable + */ + static + bool isFontImmutable() + { + return self()->isImmutable( QStringLiteral( "Font" ) ); + } + /** Set TitleFont */ static void setTitleFont( const QFont & v ) { - if (!self()->isImmutable( QStringLiteral( "TitleFont" ) )) + if (!self()->isTitleFontImmutable()) self()->mTitleFont = v; } @@ -54,6 +63,15 @@ class Test8c : public KConfigSkeleton return self()->mTitleFont; } + /** + Is TitleFont Immutable + */ + static + bool isTitleFontImmutable() + { + return self()->isImmutable( QStringLiteral( "TitleFont" ) ); + } + protected: Test8c(KSharedConfig::Ptr config, QObject *parent = nullptr); friend class Test8cHelper; -- cgit v1.2.1