From 6d3a4405fc2723f5796e845247b6b0eb0448216e Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Thu, 20 Feb 2014 16:56:01 +0100 Subject: Make kconfig_compiler signals actually useful + add unit test Previously the classes generated by kconfig_compiler would only emit the defined signals when using the setters provided by that class. However, when using e.g. KConfigDialog which uses KConfigSkeletonItem::setProperty() to change the items no signal was generated. This patch fixes this by using a wrapper KConfigSkeletonItem subclass that calls a private itemChanged() method in the generated class which updates the set of changed properties. As soon as the item is saved (usrWriteConfig() in the generated class is called) the signal will be emitted REVIEW: 115635 REVIEW: 115634 --- autotests/kconfig_compiler/test_signal.cpp.ref | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'autotests/kconfig_compiler/test_signal.cpp.ref') diff --git a/autotests/kconfig_compiler/test_signal.cpp.ref b/autotests/kconfig_compiler/test_signal.cpp.ref index fd2d4bc9..35b5cba2 100644 --- a/autotests/kconfig_compiler/test_signal.cpp.ref +++ b/autotests/kconfig_compiler/test_signal.cpp.ref @@ -30,19 +30,21 @@ TestSignal::TestSignal( ) { Q_ASSERT(!s_globalTestSignal()->q); s_globalTestSignal()->q = this; + KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast(&TestSignal::itemChanged); + setCurrentGroup( QLatin1String( "Appearance" ) ); - KConfigSkeleton::ItemString *itemEmoticonTheme; - itemEmoticonTheme = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "emoticonTheme" ), mEmoticonTheme, QLatin1String( "Default" ) ); + KConfigCompilerSignallingItem *itemEmoticonTheme; + itemEmoticonTheme = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "emoticonTheme" ), mEmoticonTheme, QLatin1String( "Default" ) ), this, notifyFunction, signalEmoticonSettingsChanged); addItem( itemEmoticonTheme, QLatin1String( "emoticonTheme" ) ); - KConfigSkeleton::ItemBool *itemUseEmoticon; - itemUseEmoticon = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "useEmoticon" ), mUseEmoticon, true ); + KConfigCompilerSignallingItem *itemUseEmoticon; + itemUseEmoticon = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "useEmoticon" ), mUseEmoticon, true ), this, notifyFunction, signalEmoticonSettingsChanged); addItem( itemUseEmoticon, QLatin1String( "useEmoticon" ) ); - KConfigSkeleton::ItemBool *itemEmoticonRequireSpace; - itemEmoticonRequireSpace = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "emoticonRequireSpace" ), mEmoticonRequireSpace, true ); + KConfigCompilerSignallingItem *itemEmoticonRequireSpace; + itemEmoticonRequireSpace = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "emoticonRequireSpace" ), mEmoticonRequireSpace, true ), this, notifyFunction, signalEmoticonSettingsChanged); addItem( itemEmoticonRequireSpace, QLatin1String( "emoticonRequireSpace" ) ); - KConfigSkeleton::ItemString *itemStylePath; - itemStylePath = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "stylePath" ), mStylePath ); + KConfigCompilerSignallingItem *itemStylePath; + itemStylePath = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "stylePath" ), mStylePath ), this, notifyFunction, signalStyleChanged); addItem( itemStylePath, QLatin1String( "stylePath" ) ); KConfigSkeleton::ItemString *itemStyleCSSVariant; itemStyleCSSVariant = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "styleVariant" ), mStyleCSSVariant ); @@ -69,5 +71,9 @@ bool TestSignal::usrWriteConfig() return true; } +void TestSignal::itemChanged(quint64 flags) { + mSettingsChanged |= flags; +} + #include "test_signal.moc" -- cgit v1.2.1