aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp20
-rw-r--r--autotests/kconfigskeletontest.cpp4
-rw-r--r--src/core/kcoreconfigskeleton.cpp23
-rw-r--r--src/core/kcoreconfigskeleton.h78
-rw-r--r--src/gui/kconfigskeleton.h8
5 files changed, 84 insertions, 49 deletions
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
index 3017fe2f..e98c03a5 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
+++ b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
@@ -114,7 +114,7 @@ void KConfigCompiler_Test_Signals::testSetters()
// make sure we are in the default state
params.obj->setDefaults();
- params.obj->writeConfig();
+ params.obj->save();
QList<QVariant> args;
QSignalSpy spy(params.obj, signal);
@@ -127,8 +127,8 @@ void KConfigCompiler_Test_Signals::testSetters()
QVERIFY(changedValue != params.getter());
params.setter(changedValue);
QCOMPARE(params.getter(), changedValue);
- QCOMPARE(spy.count(), 0); //should have no change yet, only after writeConfig()
- params.obj->writeConfig();
+ QCOMPARE(spy.count(), 0); //should have no change yet, only after save()
+ params.obj->save();
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
QCOMPARE(args.size(), 1);
@@ -142,8 +142,8 @@ void KConfigCompiler_Test_Signals::testSetters()
QCOMPARE(params.getter(), params.defaultGetter());
QCOMPARE(params.getter(), defaultValue);
- QCOMPARE(spy.count(), 0); //should have no change yet, only after writeConfig()
- params.obj->writeConfig();
+ QCOMPARE(spy.count(), 0); //should have no change yet, only after save()
+ params.obj->save();
//TODO: This currently fails since setDefaults() does not yet cause emitting a signal
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
@@ -171,7 +171,7 @@ void KConfigCompiler_Test_Signals::testSetProperty()
const QString defaultValue = QStringLiteral("default");
const QString newValue = QStringLiteral("changed");
obj->setDefaults();
- obj->writeConfig();
+ obj->save();
KConfigSkeletonItem* item = obj->findItem(propertyName);
QVERIFY2(item, "Item must exist");
@@ -186,9 +186,9 @@ void KConfigCompiler_Test_Signals::testSetProperty()
QVERIFY(!item->isEqual(newValue));
item->setProperty(newValue); //change value now
- //should have no change yet, only after writeConfig()
+ //should have no change yet, only after save()
QCOMPARE(spy.count(), 0);
- obj->writeConfig();
+ obj->save();
//now check for the signal emissions
QCOMPARE(spy.count(), 1);
QList<QVariant> args = spy.takeFirst();
@@ -199,9 +199,9 @@ void KConfigCompiler_Test_Signals::testSetProperty()
QVERIFY(!item->isEqual(defaultValue));
item->setDefault();
QVERIFY(item->isEqual(defaultValue));
- //should have no change yet, only after writeConfig()
+ //should have no change yet, only after save()
QCOMPARE(spy.count(), 0);
- obj->writeConfig();
+ obj->save();
//now check for the signal emissions
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp
index a25aaf40..f401b9f0 100644
--- a/autotests/kconfigskeletontest.cpp
+++ b/autotests/kconfigskeletontest.cpp
@@ -58,7 +58,7 @@ void KConfigSkeletonTest::testSimple()
mMyFont = WRITE_SETTING3;
mMyString = WRITE_SETTING4;
- writeConfig();
+ save();
mMyBool = false;
mMyColor = QColor();
@@ -102,6 +102,6 @@ void KConfigSkeletonTest::testDefaults()
QCOMPARE(mMyFont, DEFAULT_SETTING3);
QCOMPARE(mMyString, DEFAULT_SETTING4);
- writeConfig();
+ save();
}
diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp
index 69a4bf04..04b8b071 100644
--- a/src/core/kcoreconfigskeleton.cpp
+++ b/src/core/kcoreconfigskeleton.cpp
@@ -1073,17 +1073,17 @@ void KCoreConfigSkeleton::read()
for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
(*it)->readConfig(d->mConfig.data());
}
- usrReadConfig();
+ usrRead();
}
-bool KCoreConfigSkeleton::writeConfig()
+bool KCoreConfigSkeleton::save()
{
//qDebug();
KConfigSkeletonItem::List::ConstIterator it;
for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
(*it)->writeConfig(d->mConfig.data());
}
- if (!usrWriteConfig()) {
+ if (!usrSave()) {
return false;
}
@@ -1091,7 +1091,6 @@ bool KCoreConfigSkeleton::writeConfig()
if (!d->mConfig->sync()) {
return false;
}
- load();
emit configChanged();
}
return true;
@@ -1106,10 +1105,26 @@ void KCoreConfigSkeleton::usrSetDefaults()
{
}
+void KCoreConfigSkeleton::usrRead()
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ usrReadConfig();
+#pragma GCC diagnostic pop
+}
+
void KCoreConfigSkeleton::usrReadConfig()
{
}
+bool KCoreConfigSkeleton::usrSave()
+{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ return usrWriteConfig();
+#pragma GCC diagnostic pop
+}
+
bool KCoreConfigSkeleton::usrWriteConfig()
{
return true;
diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h
index 41f14289..dc82e968 100644
--- a/src/core/kcoreconfigskeleton.h
+++ b/src/core/kcoreconfigskeleton.h
@@ -394,14 +394,14 @@ private:
* singleton for global access from all over the application without passing
* references to the KCoreConfigSkeleton object around.
*
- * You can write the data to the configuration file by calling @ref writeConfig()
+ * You can write the data to the configuration file by calling @ref save()
* and read the data from the configuration file by calling @ref readConfig().
* If you want to watch for config changes, use @ref configChanged() signal.
*
* If you have items, which are not covered by the existing addItem() functions
* you can add customized code for reading, writing and default setting by
- * implementing the functions @ref usrUseDefaults(), @ref usrReadConfig() and
- * @ref usrWriteConfig().
+ * implementing the functions @ref usrUseDefaults(), @ref usrRead() and
+ * @ref usrSave().
*
* Internally preferences settings are stored in instances of subclasses of
* @ref KConfigSkeletonItem. You can also add KConfigSkeletonItem subclasses
@@ -1032,8 +1032,8 @@ public:
/**
* Read preferences from config file. All registered items are set to the
* values read from disk.
- * This method calls usrReadConfig() after reading the settings of the
- * registered items from the KConfig. You can overridde usrReadConfig()
+ * This method calls usrRead() after reading the settings of the
+ * registered items from the KConfig. You can overridde usrRead()
* in derived classes if you have special requirements.
*/
void load();
@@ -1054,8 +1054,8 @@ public:
* 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()
+ * This method calls usrRead() after reading the settings of the
+ * registered items from the KConfig. You can overridde usrRead()
* in derived classes if you have special requirements.
* @since 5.0
*/
@@ -1089,7 +1089,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1106,7 +1106,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1123,7 +1123,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1140,7 +1140,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1154,7 +1154,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1169,7 +1169,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1183,7 +1183,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1198,7 +1198,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1223,7 +1223,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1248,7 +1248,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1263,7 +1263,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1278,7 +1278,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1293,7 +1293,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1308,7 +1308,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1323,7 +1323,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1338,7 +1338,7 @@ public:
*
* @param name Name used to identify this setting. Names must be unique.
* @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -1419,10 +1419,18 @@ public Q_SLOTS:
* This method calls usrWriteConfig() after writing the settings from the
* registered items to the KConfig. You can overridde usrWriteConfig()
* in derived classes if you have special requirements.
- * If you need more fine-grained control of storing the settings from
- * the registered items you can override writeConfig() in a derived class.
*/
- virtual bool writeConfig();
+ bool save();
+
+#ifndef KCONFIGCORE_NO_DEPRECATED
+ /**
+ * @deprecated since 5.0, call save() instead.
+ */
+ KCONFIGCORE_DEPRECATED void writeConfig()
+ {
+ save();
+ }
+#endif
Q_SIGNALS:
/**
@@ -1451,16 +1459,28 @@ protected:
/**
* Perform the actual reading of the configuration file.
* Override in derived classes to read special config values.
- * Called from @ref readConfig()
+ * Called from @ref read()
*/
- virtual void usrReadConfig();
+ virtual void usrRead();
/**
* Perform the actual writing of the configuration file.
* Override in derived classes to write special config values.
* Called from @ref writeConfig()
*/
- virtual bool usrWriteConfig();
+ virtual bool usrSave();
+
+ /**
+ * @deprecated since 5.0, override usrRead instead. This method is still called from usrRead
+ * for compatibility.
+ */
+ KCONFIGCORE_DEPRECATED virtual void usrReadConfig();
+
+ /**
+ * @deprecated since 5.0, override usrSave instead. This method is still called from usrSave
+ * for compatibility.
+ */
+ KCONFIGCORE_DEPRECATED virtual bool usrWriteConfig();
private:
class Private;
diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h
index 8262f5ce..f87eef6e 100644
--- a/src/gui/kconfigskeleton.h
+++ b/src/gui/kconfigskeleton.h
@@ -108,8 +108,8 @@ public:
* Register an item of type QColor.
*
* @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * @param reference Pointer to the variable, which is set by read()
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.
@@ -123,8 +123,8 @@ public:
* Register an item of type QFont.
*
* @param name Name used to identify this setting. Names must be unique.
- * @param reference Pointer to the variable, which is set by readConfig()
- * calls and read by writeConfig() calls.
+ * @param reference Pointer to the variable, which is set by read()
+ * calls and read by save() calls.
* @param defaultValue Default value, which is used when the config file
* does not yet contain the key of this item.
* @param key Key used in config file. If key is null, name is used as key.