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/test11a.h.ref | 150 +++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 15 deletions(-) (limited to 'autotests/kconfig_compiler/test11a.h.ref') diff --git a/autotests/kconfig_compiler/test11a.h.ref b/autotests/kconfig_compiler/test11a.h.ref index 62b59381..014501cd 100644 --- a/autotests/kconfig_compiler/test11a.h.ref +++ b/autotests/kconfig_compiler/test11a.h.ref @@ -30,7 +30,7 @@ class Test11a : public MyPrefs */ void setAutoSave( bool v ) { - if (!isImmutable( QStringLiteral( "AutoSave" ) )) + if (!isAutoSaveImmutable()) mAutoSave = v; } @@ -42,6 +42,14 @@ class Test11a : public MyPrefs return mAutoSave; } + /** + Is Enable automatic saving of calendar Immutable + */ + bool isAutoSaveImmutable() const + { + return isImmutable( QStringLiteral( "AutoSave" ) ); + } + /** Get Item object corresponding to AutoSave() */ @@ -55,7 +63,7 @@ class Test11a : public MyPrefs */ void setAutoSaveInterval( int v ) { - if (!isImmutable( QStringLiteral( "AutoSaveInterval" ) )) + if (!isAutoSaveIntervalImmutable()) mAutoSaveInterval = v; } @@ -67,6 +75,14 @@ class Test11a : public MyPrefs return mAutoSaveInterval; } + /** + Is Auto Save Interval Immutable + */ + bool isAutoSaveIntervalImmutable() const + { + return isImmutable( QStringLiteral( "AutoSaveInterval" ) ); + } + /** Get Item object corresponding to AutoSaveInterval() */ @@ -80,7 +96,7 @@ class Test11a : public MyPrefs */ void setConfirm( bool v ) { - if (!isImmutable( QStringLiteral( "Confirm" ) )) + if (!isConfirmImmutable()) mConfirm = v; } @@ -92,6 +108,14 @@ class Test11a : public MyPrefs return mConfirm; } + /** + Is Confirm deletes Immutable + */ + bool isConfirmImmutable() const + { + return isImmutable( QStringLiteral( "Confirm" ) ); + } + /** Get Item object corresponding to Confirm() */ @@ -105,7 +129,7 @@ class Test11a : public MyPrefs */ void setArchiveFile( const QString & v ) { - if (!isImmutable( QStringLiteral( "ArchiveFile" ) )) + if (!isArchiveFileImmutable()) mArchiveFile = v; } @@ -117,6 +141,14 @@ class Test11a : public MyPrefs return mArchiveFile; } + /** + Is Archive File Immutable + */ + bool isArchiveFileImmutable() const + { + return isImmutable( QStringLiteral( "ArchiveFile" ) ); + } + /** Get Item object corresponding to ArchiveFile() */ @@ -130,7 +162,7 @@ class Test11a : public MyPrefs */ void setDestination( EnumDestination::type v ) { - if (!isImmutable( QStringLiteral( "Destination" ) )) + if (!isDestinationImmutable()) mDestination = v; } @@ -142,6 +174,14 @@ class Test11a : public MyPrefs return static_cast(mDestination); } + /** + Is New Events/Todos Should Immutable + */ + bool isDestinationImmutable() const + { + return isImmutable( QStringLiteral( "Destination" ) ); + } + /** Get New Events/Todos Should default value */ @@ -163,7 +203,7 @@ class Test11a : public MyPrefs */ void setHourSize( int v ) { - if (!isImmutable( QStringLiteral( "HourSize" ) )) + if (!isHourSizeImmutable()) mHourSize = v; } @@ -175,6 +215,14 @@ class Test11a : public MyPrefs return mHourSize; } + /** + Is Hour Size Immutable + */ + bool isHourSizeImmutable() const + { + return isImmutable( QStringLiteral( "HourSize" ) ); + } + /** Get Item object corresponding to HourSize() */ @@ -188,7 +236,7 @@ class Test11a : public MyPrefs */ void setSelectionStartsEditor( bool v ) { - if (!isImmutable( QStringLiteral( "SelectionStartsEditor" ) )) + if (!isSelectionStartsEditorImmutable()) mSelectionStartsEditor = v; } @@ -200,6 +248,14 @@ class Test11a : public MyPrefs return mSelectionStartsEditor; } + /** + Is Time range selection in agenda view starts event editor Immutable + */ + bool isSelectionStartsEditorImmutable() const + { + return isImmutable( QStringLiteral( "SelectionStartsEditor" ) ); + } + /** Get Time range selection in agenda view starts event editor default value */ @@ -221,7 +277,7 @@ class Test11a : public MyPrefs */ void setSelectedPlugins( const QStringList & v ) { - if (!isImmutable( QStringLiteral( "SelectedPlugins" ) )) + if (!isSelectedPluginsImmutable()) mSelectedPlugins = v; } @@ -233,6 +289,14 @@ class Test11a : public MyPrefs return mSelectedPlugins; } + /** + Is SelectedPlugins Immutable + */ + bool isSelectedPluginsImmutable() const + { + return isImmutable( QStringLiteral( "SelectedPlugins" ) ); + } + /** Get Item object corresponding to SelectedPlugins() */ @@ -246,7 +310,7 @@ class Test11a : public MyPrefs */ void setHighlightColor( const QColor & v ) { - if (!isImmutable( QStringLiteral( "HighlightColor" ) )) + if (!isHighlightColorImmutable()) mHighlightColor = v; } @@ -258,6 +322,14 @@ class Test11a : public MyPrefs return mHighlightColor; } + /** + Is Highlight color Immutable + */ + bool isHighlightColorImmutable() const + { + return isImmutable( QStringLiteral( "HighlightColor" ) ); + } + /** Get Item object corresponding to HighlightColor() */ @@ -271,7 +343,7 @@ class Test11a : public MyPrefs */ void setAgendaBgColor( const QColor & v ) { - if (!isImmutable( QStringLiteral( "AgendaBgColor" ) )) + if (!isAgendaBgColorImmutable()) mAgendaBgColor = v; } @@ -283,6 +355,14 @@ class Test11a : public MyPrefs return mAgendaBgColor; } + /** + Is Agenda view background color Immutable + */ + bool isAgendaBgColorImmutable() const + { + return isImmutable( QStringLiteral( "AgendaBgColor" ) ); + } + /** Get Item object corresponding to AgendaBgColor() */ @@ -296,7 +376,7 @@ class Test11a : public MyPrefs */ void setTimeBarFont( const QFont & v ) { - if (!isImmutable( QStringLiteral( "TimeBarFont" ) )) + if (!isTimeBarFontImmutable()) mTimeBarFont = v; } @@ -308,6 +388,14 @@ class Test11a : public MyPrefs return mTimeBarFont; } + /** + Is Time bar Immutable + */ + bool isTimeBarFontImmutable() const + { + return isImmutable( QStringLiteral( "TimeBarFont" ) ); + } + /** Get Item object corresponding to TimeBarFont() */ @@ -321,7 +409,7 @@ class Test11a : public MyPrefs */ void setEmailClient( MailClient v ) { - if (!isImmutable( QStringLiteral( "EmailClient" ) )) + if (!isEmailClientImmutable()) mEmailClient = v; } @@ -333,6 +421,14 @@ class Test11a : public MyPrefs return static_cast(mEmailClient); } + /** + Is Email client Immutable + */ + bool isEmailClientImmutable() const + { + return isImmutable( QStringLiteral( "EmailClient" ) ); + } + /** Get Item object corresponding to EmailClient() */ @@ -346,7 +442,7 @@ class Test11a : public MyPrefs */ void setDefaultReminderUnits( TimePeriod::Units v ) { - if (!isImmutable( QStringLiteral( "DefaultReminderUnits" ) )) + if (!isDefaultReminderUnitsImmutable()) mDefaultReminderUnits = v; } @@ -358,6 +454,14 @@ class Test11a : public MyPrefs return static_cast(mDefaultReminderUnits); } + /** + Is Reminder units Immutable + */ + bool isDefaultReminderUnitsImmutable() const + { + return isImmutable( QStringLiteral( "DefaultReminderUnits" ) ); + } + /** Get Reminder units default value */ @@ -379,7 +483,7 @@ class Test11a : public MyPrefs */ void setQueueRate( int i, const QList & v ) { - if (!isImmutable( QStringLiteral( "queueRate%1" ).arg( i ) )) + if (!isQueueRateImmutable( i )) mQueueRate[i] = v; } @@ -391,6 +495,14 @@ class Test11a : public MyPrefs return mQueueRate[i]; } + /** + Is EmptyingRate $(QueueIndex) Immutable + */ + bool isQueueRateImmutable( int i ) const + { + return isImmutable( QStringLiteral( "queueRate%1" ).arg( i ) ); + } + /** Get Item object corresponding to queueRate() */ @@ -404,7 +516,7 @@ class Test11a : public MyPrefs */ void setShowQueueTuner( bool v ) { - if (!isImmutable( QStringLiteral( "ShowQueueTuner" ) )) + if (!isShowQueueTunerImmutable()) mShowQueueTuner = v; } @@ -416,6 +528,14 @@ class Test11a : public MyPrefs return mShowQueueTuner; } + /** + Is ShowQueueTuner Immutable + */ + bool isShowQueueTunerImmutable() const + { + return isImmutable( QStringLiteral( "ShowQueueTuner" ) ); + } + /** Get Item object corresponding to ShowQueueTuner() */ -- cgit v1.2.1