diff options
author | Alex Richardson <arichardson.kde@gmail.com> | 2014-02-20 16:56:01 +0100 |
---|---|---|
committer | Alex Richardson <arichardson.kde@gmail.com> | 2014-02-20 18:14:24 +0100 |
commit | 6d3a4405fc2723f5796e845247b6b0eb0448216e (patch) | |
tree | 477c67a7c067ca1b74917bd244485998c8418623 /autotests/kconfig_compiler/test_signal.cpp.ref | |
parent | 9e3d22c3f549b583eb60c958dd923bf7c5bf4586 (diff) | |
download | kconfig-6d3a4405fc2723f5796e845247b6b0eb0448216e.tar.gz kconfig-6d3a4405fc2723f5796e845247b6b0eb0448216e.tar.bz2 |
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
Diffstat (limited to 'autotests/kconfig_compiler/test_signal.cpp.ref')
-rw-r--r-- | autotests/kconfig_compiler/test_signal.cpp.ref | 22 |
1 files changed, 14 insertions, 8 deletions
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<KConfigCompilerSignallingItem::NotifyFunction>(&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" |