aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autotests/kconfig_compiler/test10.cpp.ref2
-rw-r--r--autotests/kconfig_compiler/test1main.cpp13
-rw-r--r--autotests/kconfig_compiler/test4.cpp.ref2
-rw-r--r--autotests/kconfig_compiler/test4main.cpp16
-rw-r--r--autotests/kconfig_compiler/test5.cpp.ref2
-rw-r--r--autotests/kconfig_compiler/test8b.cpp.ref2
-rw-r--r--autotests/kconfig_compiler/test_dpointer.cpp.ref2
-rw-r--r--autotests/kconfig_compiler/test_signal.cpp.ref2
-rw-r--r--autotests/kconfigskeletontest.cpp3
-rw-r--r--src/core/kcoreconfigskeleton.cpp7
-rw-r--r--src/core/kcoreconfigskeleton.h12
-rw-r--r--src/kconfig_compiler/kconfig_compiler.cpp4
12 files changed, 54 insertions, 13 deletions
diff --git a/autotests/kconfig_compiler/test10.cpp.ref b/autotests/kconfig_compiler/test10.cpp.ref
index 21aea9d8..f067cc68 100644
--- a/autotests/kconfig_compiler/test10.cpp.ref
+++ b/autotests/kconfig_compiler/test10.cpp.ref
@@ -18,7 +18,7 @@ Test10 *Test10::self()
{
if (!s_globalTest10()->q) {
new Test10;
- s_globalTest10()->q->readConfig();
+ s_globalTest10()->q->read();
}
return s_globalTest10()->q;
diff --git a/autotests/kconfig_compiler/test1main.cpp b/autotests/kconfig_compiler/test1main.cpp
index d7dc038d..8ab7838c 100644
--- a/autotests/kconfig_compiler/test1main.cpp
+++ b/autotests/kconfig_compiler/test1main.cpp
@@ -20,12 +20,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "test1.h"
#include <QGuiApplication>
+#include <KConfig>
+#include <KConfigGroup>
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
Q_UNUSED(app);
+
+ {
+ KConfig initialConfig(QLatin1String("examplerc"));
+ KConfigGroup group = initialConfig.group(QLatin1String("MyOptions"));
+ group.writeEntry(QLatin1String("MyString"), QStringLiteral("The String"));
+ }
Test1 *t = new Test1(QString(), QString());
+
+ bool ok = t->myString() == QLatin1String("The String");
+
delete t;
- return 0;
+ return ok ? 0 : 1;
}
diff --git a/autotests/kconfig_compiler/test4.cpp.ref b/autotests/kconfig_compiler/test4.cpp.ref
index 66d0357f..2199c166 100644
--- a/autotests/kconfig_compiler/test4.cpp.ref
+++ b/autotests/kconfig_compiler/test4.cpp.ref
@@ -18,7 +18,7 @@ Test4 *Test4::self()
{
if (!s_globalTest4()->q) {
new Test4;
- s_globalTest4()->q->readConfig();
+ s_globalTest4()->q->read();
}
return s_globalTest4()->q;
diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp
index 8f1c1ec8..1df7cc5e 100644
--- a/autotests/kconfig_compiler/test4main.cpp
+++ b/autotests/kconfig_compiler/test4main.cpp
@@ -21,12 +21,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "test4.h"
#include <QGuiApplication>
+#include <QStandardPaths>
+#include <QFile>
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
Q_UNUSED(app);
+ {
+ KConfig initialConfig(QLatin1String("test4rc"));
+ KConfigGroup group = initialConfig.group(QLatin1String("Foo"));
+ group.writeEntry(QLatin1String("foo bar"), QStringLiteral("Value"));
+ }
Test4 *t = Test4::self();
+ bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/test4rc");
+ if (!ok) {
+ qWarning() << "config file was not created!";
+ }
+ if (t->fooBar() != QStringLiteral("Value")) {
+ qWarning() << "wrong value for foo bar:" << t->fooBar();
+ }
delete t;
- return 0;
+ return ok ? 0 : 1;
}
diff --git a/autotests/kconfig_compiler/test5.cpp.ref b/autotests/kconfig_compiler/test5.cpp.ref
index 088cc78f..323c1eee 100644
--- a/autotests/kconfig_compiler/test5.cpp.ref
+++ b/autotests/kconfig_compiler/test5.cpp.ref
@@ -18,7 +18,7 @@ Test5 *Test5::self()
{
if (!s_globalTest5()->q) {
new Test5;
- s_globalTest5()->q->readConfig();
+ s_globalTest5()->q->read();
}
return s_globalTest5()->q;
diff --git a/autotests/kconfig_compiler/test8b.cpp.ref b/autotests/kconfig_compiler/test8b.cpp.ref
index dcd61693..8890815b 100644
--- a/autotests/kconfig_compiler/test8b.cpp.ref
+++ b/autotests/kconfig_compiler/test8b.cpp.ref
@@ -18,7 +18,7 @@ Test8b *Test8b::self()
{
if (!s_globalTest8b()->q) {
new Test8b;
- s_globalTest8b()->q->readConfig();
+ s_globalTest8b()->q->read();
}
return s_globalTest8b()->q;
diff --git a/autotests/kconfig_compiler/test_dpointer.cpp.ref b/autotests/kconfig_compiler/test_dpointer.cpp.ref
index e50bf8aa..324ba168 100644
--- a/autotests/kconfig_compiler/test_dpointer.cpp.ref
+++ b/autotests/kconfig_compiler/test_dpointer.cpp.ref
@@ -57,7 +57,7 @@ TestDPointer *TestDPointer::self()
{
if (!s_globalTestDPointer()->q) {
new TestDPointer;
- s_globalTestDPointer()->q->readConfig();
+ s_globalTestDPointer()->q->read();
}
return s_globalTestDPointer()->q;
diff --git a/autotests/kconfig_compiler/test_signal.cpp.ref b/autotests/kconfig_compiler/test_signal.cpp.ref
index 35b5cba2..58e73efd 100644
--- a/autotests/kconfig_compiler/test_signal.cpp.ref
+++ b/autotests/kconfig_compiler/test_signal.cpp.ref
@@ -18,7 +18,7 @@ TestSignal *TestSignal::self()
{
if (!s_globalTestSignal()->q) {
new TestSignal;
- s_globalTestSignal()->q->readConfig();
+ s_globalTestSignal()->q->read();
}
return s_globalTestSignal()->q;
diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp
index 31278e76..a25aaf40 100644
--- a/autotests/kconfigskeletontest.cpp
+++ b/autotests/kconfigskeletontest.cpp
@@ -65,13 +65,12 @@ void KConfigSkeletonTest::testSimple()
mMyString.clear();
mMyFont = QFont();
- readConfig();
+ read();
QCOMPARE(mMyBool, WRITE_SETTING1);
QCOMPARE(mMyColor, WRITE_SETTING2);
QCOMPARE(mMyFont, WRITE_SETTING3);
QCOMPARE(mMyString, WRITE_SETTING4);
-
}
void KConfigSkeletonTest::testRemoveItem()
diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp
index 0c1a96fa..0a9b0dfe 100644
--- a/src/core/kcoreconfigskeleton.cpp
+++ b/src/core/kcoreconfigskeleton.cpp
@@ -986,7 +986,7 @@ KCoreConfigSkeleton::KCoreConfigSkeleton(const QString &configname, QObject *par
{
//qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
- d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig | KConfig::DelayedParsing);
+ d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig);
}
KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent)
@@ -1065,6 +1065,11 @@ void KCoreConfigSkeleton::readConfig()
{
// qDebug();
d->mConfig->reparseConfiguration();
+ read();
+}
+
+void KCoreConfigSkeleton::read()
+{
KConfigSkeletonItem::List::ConstIterator it;
for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
(*it)->readConfig(d->mConfig.data());
diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h
index a2b828a4..90562f45 100644
--- a/src/core/kcoreconfigskeleton.h
+++ b/src/core/kcoreconfigskeleton.h
@@ -1041,6 +1041,18 @@ public:
virtual void readConfig();
/**
+ * Read preferences from the KConfig object.
+ * This method assumes that the KConfig object was previously loaded,
+ * i.e. it uses the in-memory values from KConfig without reloading from disk.
+ *
+ * This method calls usrReadConfig() after reading the settings of the
+ * registered items from the KConfig. You can overridde usrReadConfig()
+ * in derived classes if you have special requirements.
+ * @since 5.0
+ */
+ void read();
+
+ /**
* Set the config file group for subsequent addItem() calls. It is valid
* until setCurrentGroup() is called with a new argument. Call this before
* you add any items. The default value is "No Group".
diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp
index 7d84cfbc..28b151c5 100644
--- a/src/kconfig_compiler/kconfig_compiler.cpp
+++ b/src/kconfig_compiler/kconfig_compiler.cpp
@@ -2249,7 +2249,7 @@ int main(int argc, char **argv)
} else {
cpp << " if (!s_global" << cfg.className << "()->q) {" << endl;
cpp << " new " << cfg.className << ';' << endl;
- cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl;
+ cpp << " s_global" << cfg.className << "()->q->read();" << endl;
cpp << " }" << endl << endl;
}
cpp << " return s_global" << cfg.className << "()->q;" << endl;
@@ -2263,7 +2263,7 @@ int main(int argc, char **argv)
cpp << " return;" << endl;
cpp << " }" << endl;
cpp << " new " << cfg.className << "(cfgfilename);" << endl;
- cpp << " s_global" << cfg.className << "()->q->readConfig();" << endl;
+ cpp << " s_global" << cfg.className << "()->q->read();" << endl;
cpp << "}" << endl << endl;
}
}