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/test_signal.h.ref | 55 +++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'autotests/kconfig_compiler/test_signal.h.ref') diff --git a/autotests/kconfig_compiler/test_signal.h.ref b/autotests/kconfig_compiler/test_signal.h.ref index a005e140..ef106a8d 100644 --- a/autotests/kconfig_compiler/test_signal.h.ref +++ b/autotests/kconfig_compiler/test_signal.h.ref @@ -21,7 +21,7 @@ class TestSignal : public KConfigSkeleton static void setEmoticonTheme( const QString & v ) { - if (v != self()->mEmoticonTheme && !self()->isImmutable( QStringLiteral( "emoticonTheme" ) )) { + if (v != self()->mEmoticonTheme && !self()->isEmoticonThemeImmutable()) { self()->mEmoticonTheme = v; self()->mSettingsChanged |= signalEmoticonSettingsChanged; } @@ -36,13 +36,22 @@ class TestSignal : public KConfigSkeleton return self()->mEmoticonTheme; } + /** + Is Current emoticon theme. Immutable + */ + static + bool isEmoticonThemeImmutable() + { + return self()->isImmutable( QStringLiteral( "emoticonTheme" ) ); + } + /** Set Enable emoticon support in Kopete. */ static void setUseEmoticon( bool v ) { - if (v != self()->mUseEmoticon && !self()->isImmutable( QStringLiteral( "useEmoticon" ) )) { + if (v != self()->mUseEmoticon && !self()->isUseEmoticonImmutable()) { self()->mUseEmoticon = v; self()->mSettingsChanged |= signalEmoticonSettingsChanged; } @@ -57,13 +66,22 @@ class TestSignal : public KConfigSkeleton return self()->mUseEmoticon; } + /** + Is Enable emoticon support in Kopete. Immutable + */ + static + bool isUseEmoticonImmutable() + { + return self()->isImmutable( QStringLiteral( "useEmoticon" ) ); + } + /** Set Use strict mode in emoticon parsing. */ static void setEmoticonRequireSpace( bool v ) { - if (v != self()->mEmoticonRequireSpace && !self()->isImmutable( QStringLiteral( "emoticonRequireSpace" ) )) { + if (v != self()->mEmoticonRequireSpace && !self()->isEmoticonRequireSpaceImmutable()) { self()->mEmoticonRequireSpace = v; self()->mSettingsChanged |= signalEmoticonSettingsChanged; } @@ -78,13 +96,22 @@ class TestSignal : public KConfigSkeleton return self()->mEmoticonRequireSpace; } + /** + Is Use strict mode in emoticon parsing. Immutable + */ + static + bool isEmoticonRequireSpaceImmutable() + { + return self()->isImmutable( QStringLiteral( "emoticonRequireSpace" ) ); + } + /** Set Absolute path to a directory containing a Adium/Kopete chat window style. */ static void setStylePath( const QString & v ) { - if (v != self()->mStylePath && !self()->isImmutable( QStringLiteral( "stylePath" ) )) { + if (v != self()->mStylePath && !self()->isStylePathImmutable()) { self()->mStylePath = v; self()->mSettingsChanged |= signalStyleChanged; } @@ -99,13 +126,22 @@ class TestSignal : public KConfigSkeleton return self()->mStylePath; } + /** + Is Absolute path to a directory containing a Adium/Kopete chat window style. Immutable + */ + static + bool isStylePathImmutable() + { + return self()->isImmutable( QStringLiteral( "stylePath" ) ); + } + /** Set Relative path to a CSS variant for the current style. */ static void setStyleCSSVariant( const QString & v ) { - if (!self()->isImmutable( QStringLiteral( "StyleCSSVariant" ) )) + if (!self()->isStyleCSSVariantImmutable()) self()->mStyleCSSVariant = v; } @@ -118,6 +154,15 @@ class TestSignal : public KConfigSkeleton return self()->mStyleCSSVariant; } + /** + Is Relative path to a CSS variant for the current style. Immutable + */ + static + bool isStyleCSSVariantImmutable() + { + return self()->isImmutable( QStringLiteral( "StyleCSSVariant" ) ); + } + enum { signalEmoticonSettingsChanged = 0x1, -- cgit v1.2.1