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_dpointer.cpp.ref | 77 ++++++++++++++++++++---- 1 file changed, 66 insertions(+), 11 deletions(-) (limited to 'autotests/kconfig_compiler/test_dpointer.cpp.ref') diff --git a/autotests/kconfig_compiler/test_dpointer.cpp.ref b/autotests/kconfig_compiler/test_dpointer.cpp.ref index 1bfb9f52..5693fb62 100644 --- a/autotests/kconfig_compiler/test_dpointer.cpp.ref +++ b/autotests/kconfig_compiler/test_dpointer.cpp.ref @@ -157,7 +157,7 @@ TestDPointer::TestDPointer( ) void TestDPointer::setAutoSave( bool v ) { - if (!self()->isImmutable( QStringLiteral( "AutoSave" ) )) + if (!self()->TestDPointer::isAutoSaveImmutable()) self()->d->autoSave = v; } @@ -166,6 +166,11 @@ bool TestDPointer::autoSave() return self()->d->autoSave; } +bool TestDPointer::isAutoSaveImmutable() +{ + return self()->isImmutable( QStringLiteral( "AutoSave" ) ); +} + KConfigSkeleton::ItemBool *TestDPointer::autoSaveItem() { @@ -174,7 +179,7 @@ KConfigSkeleton::ItemBool *TestDPointer::autoSaveItem() void TestDPointer::setAutoSaveInterval( int v ) { - if (!self()->isImmutable( QStringLiteral( "AutoSaveInterval" ) )) + if (!self()->TestDPointer::isAutoSaveIntervalImmutable()) self()->d->autoSaveInterval = v; } @@ -183,6 +188,11 @@ int TestDPointer::autoSaveInterval() return self()->d->autoSaveInterval; } +bool TestDPointer::isAutoSaveIntervalImmutable() +{ + return self()->isImmutable( QStringLiteral( "AutoSaveInterval" ) ); +} + KConfigSkeleton::ItemInt *TestDPointer::autoSaveIntervalItem() { @@ -191,7 +201,7 @@ KConfigSkeleton::ItemInt *TestDPointer::autoSaveIntervalItem() void TestDPointer::setConfirm( bool v ) { - if (!self()->isImmutable( QStringLiteral( "Confirm" ) )) + if (!self()->TestDPointer::isConfirmImmutable()) self()->d->confirm = v; } @@ -200,6 +210,11 @@ bool TestDPointer::confirm() return self()->d->confirm; } +bool TestDPointer::isConfirmImmutable() +{ + return self()->isImmutable( QStringLiteral( "Confirm" ) ); +} + KConfigSkeleton::ItemBool *TestDPointer::confirmItem() { @@ -208,7 +223,7 @@ KConfigSkeleton::ItemBool *TestDPointer::confirmItem() void TestDPointer::setArchiveFile( const QString & v ) { - if (!self()->isImmutable( QStringLiteral( "ArchiveFile" ) )) + if (!self()->TestDPointer::isArchiveFileImmutable()) self()->d->archiveFile = v; } @@ -217,6 +232,11 @@ QString TestDPointer::archiveFile() return self()->d->archiveFile; } +bool TestDPointer::isArchiveFileImmutable() +{ + return self()->isImmutable( QStringLiteral( "ArchiveFile" ) ); +} + KConfigSkeleton::ItemString *TestDPointer::archiveFileItem() { @@ -225,7 +245,7 @@ KConfigSkeleton::ItemString *TestDPointer::archiveFileItem() void TestDPointer::setDestination( int v ) { - if (!self()->isImmutable( QStringLiteral( "Destination" ) )) + if (!self()->TestDPointer::isDestinationImmutable()) self()->d->destination = v; } @@ -234,6 +254,11 @@ int TestDPointer::destination() return self()->d->destination; } +bool TestDPointer::isDestinationImmutable() +{ + return self()->isImmutable( QStringLiteral( "Destination" ) ); +} + KConfigSkeleton::ItemEnum *TestDPointer::destinationItem() { @@ -242,7 +267,7 @@ KConfigSkeleton::ItemEnum *TestDPointer::destinationItem() void TestDPointer::setHourSize( int v ) { - if (!self()->isImmutable( QStringLiteral( "HourSize" ) )) + if (!self()->TestDPointer::isHourSizeImmutable()) self()->d->hourSize = v; } @@ -251,6 +276,11 @@ int TestDPointer::hourSize() return self()->d->hourSize; } +bool TestDPointer::isHourSizeImmutable() +{ + return self()->isImmutable( QStringLiteral( "HourSize" ) ); +} + KConfigSkeleton::ItemInt *TestDPointer::hourSizeItem() { @@ -259,7 +289,7 @@ KConfigSkeleton::ItemInt *TestDPointer::hourSizeItem() void TestDPointer::setSelectionStartsEditor( bool v ) { - if (!self()->isImmutable( QStringLiteral( "SelectionStartsEditor" ) )) + if (!self()->TestDPointer::isSelectionStartsEditorImmutable()) self()->d->selectionStartsEditor = v; } @@ -268,6 +298,11 @@ bool TestDPointer::selectionStartsEditor() return self()->d->selectionStartsEditor; } +bool TestDPointer::isSelectionStartsEditorImmutable() +{ + return self()->isImmutable( QStringLiteral( "SelectionStartsEditor" ) ); +} + KConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem() { @@ -276,7 +311,7 @@ KConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem() void TestDPointer::setSelectedPlugins( const QStringList & v ) { - if (!self()->isImmutable( QStringLiteral( "SelectedPlugins" ) )) + if (!self()->TestDPointer::isSelectedPluginsImmutable()) self()->d->selectedPlugins = v; } @@ -285,6 +320,11 @@ QStringList TestDPointer::selectedPlugins() return self()->d->selectedPlugins; } +bool TestDPointer::isSelectedPluginsImmutable() +{ + return self()->isImmutable( QStringLiteral( "SelectedPlugins" ) ); +} + KConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem() { @@ -293,7 +333,7 @@ KConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem() void TestDPointer::setHighlightColor( const QColor & v ) { - if (!self()->isImmutable( QStringLiteral( "HighlightColor" ) )) + if (!self()->TestDPointer::isHighlightColorImmutable()) self()->d->highlightColor = v; } @@ -302,6 +342,11 @@ QColor TestDPointer::highlightColor() return self()->d->highlightColor; } +bool TestDPointer::isHighlightColorImmutable() +{ + return self()->isImmutable( QStringLiteral( "HighlightColor" ) ); +} + KConfigSkeleton::ItemColor *TestDPointer::highlightColorItem() { @@ -310,7 +355,7 @@ KConfigSkeleton::ItemColor *TestDPointer::highlightColorItem() void TestDPointer::setAgendaBgColor( const QColor & v ) { - if (!self()->isImmutable( QStringLiteral( "AgendaBgColor" ) )) + if (!self()->TestDPointer::isAgendaBgColorImmutable()) self()->d->agendaBgColor = v; } @@ -319,6 +364,11 @@ QColor TestDPointer::agendaBgColor() return self()->d->agendaBgColor; } +bool TestDPointer::isAgendaBgColorImmutable() +{ + return self()->isImmutable( QStringLiteral( "AgendaBgColor" ) ); +} + KConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem() { @@ -327,7 +377,7 @@ KConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem() void TestDPointer::setTimeBarFont( const QFont & v ) { - if (!self()->isImmutable( QStringLiteral( "TimeBarFont" ) )) + if (!self()->TestDPointer::isTimeBarFontImmutable()) self()->d->timeBarFont = v; } @@ -336,6 +386,11 @@ QFont TestDPointer::timeBarFont() return self()->d->timeBarFont; } +bool TestDPointer::isTimeBarFontImmutable() +{ + return self()->isImmutable( QStringLiteral( "TimeBarFont" ) ); +} + KConfigSkeleton::ItemFont *TestDPointer::timeBarFontItem() { -- cgit v1.2.1