diff options
4 files changed, 24 insertions, 2 deletions
diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 5cbf2e44..2598e4a1 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -231,6 +231,7 @@ gen_kcfg_test_source(signals_test_singleton kconfigcompiler_test_signals_SRCS GE  gen_kcfg_test_source(signals_test_no_singleton kconfigcompiler_test_signals_SRCS GENERATE_MOC)  gen_kcfg_test_source(signals_test_singleton_dpointer kconfigcompiler_test_signals_SRCS GENERATE_MOC)  gen_kcfg_test_source(signals_test_no_singleton_dpointer kconfigcompiler_test_signals_SRCS GENERATE_MOC) +gen_kcfg_test_source(signals_test_singleton_itemaccessors kconfigcompiler_test_signals_SRCS GENERATE_MOC)  ecm_add_test(${kconfigcompiler_test_signals_SRCS}      TEST_NAME kconfigcompiler-signals-test diff --git a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp index f493d35f..64eb2ca7 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp @@ -8,6 +8,7 @@  #include "signals_test_no_singleton_dpointer.h"  #include "signals_test_singleton.h"  #include "signals_test_singleton_dpointer.h" +#include "signals_test_singleton_itemaccessors.h"  #include <QDebug>  #include <QFileInfo>  #include <QSharedPointer> @@ -40,15 +41,18 @@ void KConfigCompiler_Test_Signals::initTestCase()      QTemporaryFile *tempFile2 = new QTemporaryFile(this);      QTemporaryFile *tempFile3 = new QTemporaryFile(this);      QTemporaryFile *tempFile4 = new QTemporaryFile(this); +    QTemporaryFile *tempFile5 = new QTemporaryFile(this);      QVERIFY(tempFile1->open());      QVERIFY(tempFile2->open());      QVERIFY(tempFile3->open());      QVERIFY(tempFile4->open()); +    QVERIFY(tempFile5->open());      SignalsTestSingleton::instance(QFileInfo(*tempFile1).absoluteFilePath());      SignalsTestSingletonDpointer::instance(QFileInfo(*tempFile2).absoluteFilePath());      noSingleton = new SignalsTestNoSingleton(KSharedConfig::openConfig(QFileInfo(*tempFile3).absoluteFilePath(), KConfig::SimpleConfig));      noSingletonDpointer = new SignalsTestNoSingletonDpointer(KSharedConfig::openConfig(QFileInfo(*tempFile4).absoluteFilePath(), KConfig::SimpleConfig)); +    SignalsTestSingletonItemAccessors::instance(QFileInfo(*tempFile5).absoluteFilePath());  }  void KConfigCompiler_Test_Signals::cleanupTestCase() @@ -58,6 +62,7 @@ void KConfigCompiler_Test_Signals::cleanupTestCase()      delete noSingletonDpointer;      delete SignalsTestSingleton::self();      delete SignalsTestSingletonDpointer::self(); +    delete SignalsTestSingletonItemAccessors::self();  }  struct TestSettersArg { @@ -96,6 +101,7 @@ void KConfigCompiler_Test_Signals::testSetters_data()      QTest::newRow("singleton dpointer") << TestSettersArg(SignalsTestSingletonDpointer::self());      QTest::newRow("non-singleton") << TestSettersArg(noSingleton);      QTest::newRow("non-singleton dpointer") << TestSettersArg(noSingleton); +    QTest::newRow("singleton itemaccessors") << TestSettersArg(SignalsTestSingletonItemAccessors::self());  }  /** Ensure that a signal is emitted whenever the data is changed by using the generated setters */ @@ -154,6 +160,7 @@ void KConfigCompiler_Test_Signals::testSetProperty_data()      QTest::newRow("singleton dpointer") << static_cast<KCoreConfigSkeleton *>(SignalsTestSingletonDpointer::self());      QTest::newRow("non-singleton") << static_cast<KCoreConfigSkeleton *>(noSingleton);      QTest::newRow("non-singleton dpointer") << static_cast<KCoreConfigSkeleton *>(noSingletonDpointer); +    QTest::newRow("singleton itemaccessors") << static_cast<KCoreConfigSkeleton *>(SignalsTestSingletonItemAccessors::self());  }  /** Test that the signal is emitted when modifying the values using the underlying KConfigSkeletonItem (bypassing the setters) */ diff --git a/autotests/kconfig_compiler/signals_test_singleton_itemaccessors.kcfgc b/autotests/kconfig_compiler/signals_test_singleton_itemaccessors.kcfgc new file mode 100644 index 00000000..c71cca8e --- /dev/null +++ b/autotests/kconfig_compiler/signals_test_singleton_itemaccessors.kcfgc @@ -0,0 +1,9 @@ +File=signals_test.kcfg +ClassName=SignalsTestSingletonItemAccessors +Singleton=true +Mutators=true +MemberVariables=private +GlobalEnums=false +UseEnumTypes=false +ItemAccessors=true +DefaultValueGetters=true diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp index ea5a2c75..24b8107f 100644 --- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp +++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp @@ -508,10 +508,13 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt      if (!cfg().itemAccessors) {          return;      } + +    const QString declType = entry->signalList.isEmpty() ? QStringLiteral("Item") + itemType(entry->type) : QStringLiteral("KConfigCompilerSignallingItem"); +      stream() << whitespace() << "/**\n";      stream() << whitespace() << "  Get Item object corresponding to " << entry->name << "()" << '\n';      stream() << whitespace() << "*/\n"; -    stream() << whitespace() << "Item" << itemType(entry->type) << " *" << getFunction(entry->name) << "Item("; +    stream() << whitespace() << declType << " *" << getFunction(entry->name) << "Item(";      if (!entry->param.isEmpty()) {          stream() << " " << cppType(entry->paramType) << " i ";      } @@ -625,7 +628,9 @@ void KConfigHeaderGenerator::createNonDPointerHelpers()      stream() << "\n  private:\n";      if (cfg().itemAccessors) {          for (const auto *entry : std::as_const(parseResult.entries)) { -            stream() << whitespace() << "Item" << itemType(entry->type) << " *" << itemVar(entry, cfg()); +            const QString declType = +                entry->signalList.isEmpty() ? QStringLiteral("Item") + itemType(entry->type) : QStringLiteral("KConfigCompilerSignallingItem"); +            stream() << whitespace() << declType << " *" << itemVar(entry, cfg());              if (!entry->param.isEmpty()) {                  stream() << QStringLiteral("[%1]").arg(entry->paramMax + 1);              }  | 
