aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--autotests/fallbackconfigresourcestest.cpp2
-rw-r--r--autotests/helper.h3
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test.cpp153
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test.h2
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp103
-rw-r--r--autotests/kconfig_compiler/myprefs.h5
-rw-r--r--autotests/kconfig_compiler/test1main.cpp2
-rw-r--r--autotests/kconfig_compiler/test4main.cpp2
-rw-r--r--autotests/kconfig_compiler/test9main.cpp2
-rw-r--r--autotests/kconfig_compiler/test_param_minmax_main.cpp1
-rw-r--r--autotests/kconfig_compiler/test_qdebugcategory_debug.cpp2
-rw-r--r--autotests/kconfig_compiler/test_qdebugcategory_debug.h1
-rw-r--r--autotests/kconfigguitest.cpp13
-rw-r--r--autotests/kconfigloadertest.cpp17
-rw-r--r--autotests/kconfignokdehometest.cpp2
-rw-r--r--autotests/kconfigskeletontest.cpp8
-rw-r--r--autotests/kconfigskeletontest.h2
-rw-r--r--autotests/kconfigtest.cpp126
-rw-r--r--autotests/kconfigtest.h13
-rw-r--r--autotests/kdesktopfiletest.cpp141
-rw-r--r--autotests/kdesktopfiletest.h1
-rw-r--r--autotests/kentrymaptest.h2
-rw-r--r--autotests/ksharedconfig_in_global_object.cpp4
-rw-r--r--autotests/ksharedconfigtest.cpp7
-rw-r--r--autotests/kstandardshortcuttest.cpp4
-rw-r--r--autotests/test_kconf_update.cpp757
-rw-r--r--autotests/test_kconfigutils.cpp101
-rw-r--r--src/core/bufferfragment_p.h12
-rw-r--r--src/core/conversioncheck.h31
-rw-r--r--src/core/kauthorized.cpp156
-rw-r--r--src/core/kauthorized.h14
-rw-r--r--src/core/kconfig.cpp116
-rw-r--r--src/core/kconfig.h19
-rw-r--r--src/core/kconfig_p.h36
-rw-r--r--src/core/kconfigbackend.cpp10
-rw-r--r--src/core/kconfigbackend_p.h17
-rw-r--r--src/core/kconfigbase.cpp9
-rw-r--r--src/core/kconfigbase.h6
-rw-r--r--src/core/kconfigdata.cpp58
-rw-r--r--src/core/kconfigdata.h89
-rw-r--r--src/core/kconfiggroup.cpp180
-rw-r--r--src/core/kconfiggroup.h194
-rw-r--r--src/core/kconfiggroup_p.h8
-rw-r--r--src/core/kconfigini.cpp258
-rw-r--r--src/core/kconfigini_p.h20
-rw-r--r--src/core/kconfigwatcher.cpp28
-rw-r--r--src/core/kconfigwatcher.h4
-rw-r--r--src/core/kcoreconfigskeleton.cpp307
-rw-r--r--src/core/kcoreconfigskeleton.h256
-rw-r--r--src/core/kcoreconfigskeleton_p.h10
-rw-r--r--src/core/kdesktopfile.cpp32
-rw-r--r--src/core/kdesktopfile.h3
-rw-r--r--src/core/kemailsettings.cpp8
-rw-r--r--src/core/kemailsettings.h98
-rw-r--r--src/core/ksharedconfig.cpp27
-rw-r--r--src/core/ksharedconfig.h13
-rw-r--r--src/gui/kconfiggroupgui.cpp30
-rw-r--r--src/gui/kconfiggui.cpp11
-rw-r--r--src/gui/kconfigloader.cpp63
-rw-r--r--src/gui/kconfigloader.h2
-rw-r--r--src/gui/kconfigloaderhandler_p.h1
-rw-r--r--src/gui/kconfigskeleton.cpp21
-rw-r--r--src/gui/kconfigskeleton.h20
-rw-r--r--src/gui/kstandardshortcut.cpp471
-rw-r--r--src/gui/kstandardshortcut.h6
-rw-r--r--src/gui/kwindowconfig.cpp4
-rw-r--r--src/gui/kwindowconfig.h4
-rw-r--r--src/kconf_update/kconf_update.cpp99
-rw-r--r--src/kconf_update/kconfigutils.cpp1
-rw-r--r--src/kconf_update/kconfigutils.h1
-rw-r--r--src/kconfig_compiler/KConfigCodeGeneratorBase.cpp30
-rw-r--r--src/kconfig_compiler/KConfigCodeGeneratorBase.h70
-rw-r--r--src/kconfig_compiler/KConfigCommonStructs.h52
-rw-r--r--src/kconfig_compiler/KConfigHeaderGenerator.cpp46
-rw-r--r--src/kconfig_compiler/KConfigHeaderGenerator.h13
-rw-r--r--src/kconfig_compiler/KConfigParameters.h10
-rw-r--r--src/kconfig_compiler/KConfigSourceGenerator.cpp74
-rw-r--r--src/kconfig_compiler/KConfigSourceGenerator.h11
-rw-r--r--src/kconfig_compiler/KConfigXmlParser.cpp69
-rw-r--r--src/kconfig_compiler/KConfigXmlParser.h2
-rw-r--r--src/kconfig_compiler/kconfig_compiler.cpp99
-rw-r--r--src/kreadconfig/kreadconfig.cpp100
-rw-r--r--src/kreadconfig/kwriteconfig.cpp51
84 files changed, 2343 insertions, 2521 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63366aee..dba7a7ef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,7 +31,7 @@ endif()
include(KDEInstallDirs)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
-
+include(KDEGitCommitHooks)
include(ECMGenerateExportHeader)
include(ECMSetupVersion)
@@ -104,3 +104,9 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kconfig_version.h
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
+
+kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
+# Remove these 3 lines when the ECM version is bumped to 5.80
+include(KDEClangFormat)
+file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
+kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
diff --git a/autotests/fallbackconfigresourcestest.cpp b/autotests/fallbackconfigresourcestest.cpp
index 0b1a3697..56d065cc 100644
--- a/autotests/fallbackconfigresourcestest.cpp
+++ b/autotests/fallbackconfigresourcestest.cpp
@@ -6,8 +6,8 @@
*/
#include <QTest>
-#include <ksharedconfig.h>
#include <kconfiggroup.h>
+#include <ksharedconfig.h>
class FallbackConfigResourcesTest : public QObject
{
diff --git a/autotests/helper.h b/autotests/helper.h
index 20aed445..513916a6 100644
--- a/autotests/helper.h
+++ b/autotests/helper.h
@@ -15,13 +15,14 @@ class DefaultLocale
{
public:
DefaultLocale()
- : m_defaultLocale()
+ : m_defaultLocale()
{
}
~DefaultLocale()
{
QLocale::setDefault(m_defaultLocale);
}
+
private:
QLocale m_defaultLocale;
};
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
index 4467a211..090fe01d 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp
+++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
@@ -7,77 +7,101 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
+#include "kconfigcompiler_test.h"
#include <QDir>
#include <QProcess>
#include <QString>
#include <QTest>
#include <qstandardpaths.h>
-#include "kconfigcompiler_test.h"
// QT5 TODO QTEST_GUILESS_MAIN(KConfigCompiler_Test)
QTEST_MAIN(KConfigCompiler_Test)
typedef const char *CompilerTestSet[];
-static CompilerTestSet testCases = {
- "test1.cpp", "test1.h",
- "test2.cpp", "test2.h",
- "test3.cpp", "test3.h",
- "test3a.cpp", "test3a.h",
- "test4.cpp", "test4.h",
- "test5.cpp", "test5.h",
- "test6.cpp", "test6.h",
- "test7.cpp", "test7.h",
- "test8a.cpp", "test8a.h",
- "test8b.cpp", "test8b.h",
- "test8c.cpp", "test8c.h",
- "test9.h", "test9.cpp",
- "test10.h", "test10.cpp",
- "test11.h", "test11.cpp",
- "test11a.h", "test11a.cpp",
- "test12.h", "test12.cpp",
- "test13.h", "test13.cpp",
- "test_dpointer.cpp", "test_dpointer.h",
- "test_qdebugcategory.cpp", "test_qdebugcategory.h",
- "test_signal.cpp", "test_signal.h",
- "test_notifiers.cpp", "test_notifiers.h",
- "test_translation_kde.cpp", "test_translation_kde.h",
- "test_translation_kde_domain.cpp", "test_translation_kde_domain.h",
- "test_translation_qt.cpp", "test_translation_qt.h",
- "test_emptyentries.cpp", "test_emptyentries.h",
- "test_properties_minmax.cpp", "test_properties_minmax.h",
- "test_param_minmax.cpp", "test_param_minmax.h",
- "test_subgroups.cpp", "test_subgroups.h",
- nullptr
-};
-
-static CompilerTestSet testCasesToRun = {
- "test1",
- "test2",
- "test3",
- "test3a",
- "test4",
- "test5",
- "test6",
- "test7",
- "test8",
- "test9",
- "test10",
- "test11",
- "test12",
- "test13",
- "test_dpointer",
- "test_qdebugcategory",
- "test_signal",
- "test_translation_kde",
- "test_translation_kde_domain",
- "test_translation_qt",
- "test_emptyentries",
- "test_properties_minmax",
- "test_param_minmax",
- "test_subgroups",
- nullptr
-};
+static CompilerTestSet testCases = {"test1.cpp",
+ "test1.h",
+ "test2.cpp",
+ "test2.h",
+ "test3.cpp",
+ "test3.h",
+ "test3a.cpp",
+ "test3a.h",
+ "test4.cpp",
+ "test4.h",
+ "test5.cpp",
+ "test5.h",
+ "test6.cpp",
+ "test6.h",
+ "test7.cpp",
+ "test7.h",
+ "test8a.cpp",
+ "test8a.h",
+ "test8b.cpp",
+ "test8b.h",
+ "test8c.cpp",
+ "test8c.h",
+ "test9.h",
+ "test9.cpp",
+ "test10.h",
+ "test10.cpp",
+ "test11.h",
+ "test11.cpp",
+ "test11a.h",
+ "test11a.cpp",
+ "test12.h",
+ "test12.cpp",
+ "test13.h",
+ "test13.cpp",
+ "test_dpointer.cpp",
+ "test_dpointer.h",
+ "test_qdebugcategory.cpp",
+ "test_qdebugcategory.h",
+ "test_signal.cpp",
+ "test_signal.h",
+ "test_notifiers.cpp",
+ "test_notifiers.h",
+ "test_translation_kde.cpp",
+ "test_translation_kde.h",
+ "test_translation_kde_domain.cpp",
+ "test_translation_kde_domain.h",
+ "test_translation_qt.cpp",
+ "test_translation_qt.h",
+ "test_emptyentries.cpp",
+ "test_emptyentries.h",
+ "test_properties_minmax.cpp",
+ "test_properties_minmax.h",
+ "test_param_minmax.cpp",
+ "test_param_minmax.h",
+ "test_subgroups.cpp",
+ "test_subgroups.h",
+ nullptr};
+
+static CompilerTestSet testCasesToRun = {"test1",
+ "test2",
+ "test3",
+ "test3a",
+ "test4",
+ "test5",
+ "test6",
+ "test7",
+ "test8",
+ "test9",
+ "test10",
+ "test11",
+ "test12",
+ "test13",
+ "test_dpointer",
+ "test_qdebugcategory",
+ "test_signal",
+ "test_translation_kde",
+ "test_translation_kde_domain",
+ "test_translation_qt",
+ "test_emptyentries",
+ "test_properties_minmax",
+ "test_param_minmax",
+ "test_subgroups",
+ nullptr};
#if 0
static CompilerTestSet willFailCases = {
@@ -89,7 +113,7 @@ static CompilerTestSet willFailCases = {
void KConfigCompiler_Test::initTestCase()
{
- m_diffExe = QStandardPaths::findExecutable( QStringLiteral("diff") );
+ m_diffExe = QStandardPaths::findExecutable(QStringLiteral("diff"));
if (m_diffExe.isEmpty()) {
qDebug() << "diff command not found, detailed info on comparison failure will not be available.";
}
@@ -122,7 +146,7 @@ void KConfigCompiler_Test::testBaselineComparison()
const QByteArray content = file.readAll();
const QByteArray contentRef = fileRef.readAll();
- if (content != contentRef) {
+ if (content != contentRef) {
appendFileDiff(fileRef.fileName(), file.fileName());
}
@@ -164,10 +188,7 @@ void KConfigCompiler_Test::appendFileDiff(const QString &oldFile, const QString
return;
}
- QStringList args({
- QStringLiteral("-u"),
- QFileInfo(oldFile).absoluteFilePath(),
- QFileInfo(newFile).absoluteFilePath() });
+ QStringList args({QStringLiteral("-u"), QFileInfo(oldFile).absoluteFilePath(), QFileInfo(newFile).absoluteFilePath()});
QProcess process;
process.start(m_diffExe, args, QIODevice::ReadOnly);
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.h b/autotests/kconfig_compiler/kconfigcompiler_test.h
index e0506db0..c8242cfd 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test.h
+++ b/autotests/kconfig_compiler/kconfigcompiler_test.h
@@ -24,6 +24,7 @@ private Q_SLOTS:
void testBaselineComparison();
void testRunning_data();
void testRunning();
+
private:
void appendFileDiff(const QString &oldFile, const QString &newFile);
@@ -31,4 +32,3 @@ private:
};
#endif
-
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
index 3637b1ff..f493d35f 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
+++ b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
@@ -4,17 +4,17 @@
SPDX-License-Identifier: MIT
*/
-#include "signals_test_singleton.h"
#include "signals_test_no_singleton.h"
-#include "signals_test_singleton_dpointer.h"
#include "signals_test_no_singleton_dpointer.h"
-#include <QtTestGui>
-#include <QSignalSpy>
-#include <QSharedPointer>
-#include <QtGlobal>
+#include "signals_test_singleton.h"
+#include "signals_test_singleton_dpointer.h"
#include <QDebug>
-#include <QTemporaryFile>
#include <QFileInfo>
+#include <QSharedPointer>
+#include <QSignalSpy>
+#include <QTemporaryFile>
+#include <QtGlobal>
+#include <QtTestGui>
#include <functional>
class KConfigCompiler_Test_Signals : public QObject
@@ -29,17 +29,17 @@ private Q_SLOTS:
void cleanupTestCase();
};
-static SignalsTestNoSingleton* noSingleton;
-static SignalsTestNoSingletonDpointer* noSingletonDpointer;
+static SignalsTestNoSingleton *noSingleton;
+static SignalsTestNoSingletonDpointer *noSingletonDpointer;
void KConfigCompiler_Test_Signals::initTestCase()
{
// These tests do a lot quite a few I/O operations, speed that up by using a QTemporaryFile.
// At least on Linux this is often a tmpfs which means only RAM operations
- QTemporaryFile* tempFile1 = new QTemporaryFile(this);
- QTemporaryFile* tempFile2 = new QTemporaryFile(this);
- QTemporaryFile* tempFile3 = new QTemporaryFile(this);
- QTemporaryFile* tempFile4 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile1 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile2 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile3 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile4 = new QTemporaryFile(this);
QVERIFY(tempFile1->open());
QVERIFY(tempFile2->open());
QVERIFY(tempFile3->open());
@@ -47,15 +47,13 @@ void KConfigCompiler_Test_Signals::initTestCase()
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));
+ noSingleton = new SignalsTestNoSingleton(KSharedConfig::openConfig(QFileInfo(*tempFile3).absoluteFilePath(), KConfig::SimpleConfig));
+ noSingletonDpointer = new SignalsTestNoSingletonDpointer(KSharedConfig::openConfig(QFileInfo(*tempFile4).absoluteFilePath(), KConfig::SimpleConfig));
}
void KConfigCompiler_Test_Signals::cleanupTestCase()
{
- //ensure these instances are deleted before the temporary files are closed
+ // ensure these instances are deleted before the temporary files are closed
delete noSingleton;
delete noSingletonDpointer;
delete SignalsTestSingleton::self();
@@ -64,18 +62,29 @@ void KConfigCompiler_Test_Signals::cleanupTestCase()
struct TestSettersArg {
// default constructor required for Q_DECLARE_METATYPE
- TestSettersArg() : obj(nullptr) {}
+ TestSettersArg()
+ : obj(nullptr)
+ {
+ }
template<typename T>
- TestSettersArg(T* object) : obj(object) {
+ TestSettersArg(T *object)
+ : obj(object)
+ {
// we can also call static methods using object->foo() so this works for all four cases
- getter = [object]() { return object->foo(); };
- defaultGetter = [object]() { return object->defaultFooValue(); };
- setter = [object](const QString& s) { object->setFoo(s); };
+ getter = [object]() {
+ return object->foo();
+ };
+ defaultGetter = [object]() {
+ return object->defaultFooValue();
+ };
+ setter = [object](const QString &s) {
+ object->setFoo(s);
+ };
}
- KCoreConfigSkeleton* obj;
+ KCoreConfigSkeleton *obj;
std::function<QString()> getter;
std::function<QString()> defaultGetter;
- std::function<void(const QString&)> setter;
+ std::function<void(const QString &)> setter;
};
Q_DECLARE_METATYPE(TestSettersArg) // so that QFETCH works
@@ -93,7 +102,7 @@ void KConfigCompiler_Test_Signals::testSetters_data()
void KConfigCompiler_Test_Signals::testSetters()
{
QFETCH(TestSettersArg, params);
- const char* signal = SIGNAL(fooChanged(QString));
+ const char *signal = SIGNAL(fooChanged(QString));
const QString defaultValue = QStringLiteral("default");
const QString changedValue = QStringLiteral("changed");
@@ -105,21 +114,21 @@ void KConfigCompiler_Test_Signals::testSetters()
QSignalSpy spy(params.obj, signal);
QVERIFY2(spy.isValid(), signal);
- //change value via setter, should get signal
+ // change value via setter, should get signal
QCOMPARE(params.getter(), defaultValue);
QCOMPARE(defaultValue, params.defaultGetter());
QCOMPARE(params.getter(), params.defaultGetter());
QVERIFY(changedValue != params.getter());
params.setter(changedValue);
QCOMPARE(params.getter(), changedValue);
- QCOMPARE(spy.count(), 0); //should have no change yet, only after save()
+ 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);
QCOMPARE(args[0].toString(), changedValue);
- //reset to default values via setDefaults()
+ // reset to default values via setDefaults()
QVERIFY(params.getter() != params.defaultGetter());
QVERIFY(params.getter() != defaultValue);
QCOMPARE(params.getter(), changedValue);
@@ -127,67 +136,67 @@ 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 save()
+ 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
+ // TODO: This currently fails since setDefaults() does not yet cause emitting a signal
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
QCOMPARE(args.size(), 1);
QCOMPARE(args[0].value<QString>(), defaultValue);
}
-Q_DECLARE_METATYPE(KCoreConfigSkeleton*)
+Q_DECLARE_METATYPE(KCoreConfigSkeleton *)
void KConfigCompiler_Test_Signals::testSetProperty_data()
{
- QTest::addColumn<KCoreConfigSkeleton*>("obj");
- QTest::newRow("singleton") << static_cast<KCoreConfigSkeleton*>(SignalsTestSingleton::self());
- 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::addColumn<KCoreConfigSkeleton *>("obj");
+ QTest::newRow("singleton") << static_cast<KCoreConfigSkeleton *>(SignalsTestSingleton::self());
+ 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);
}
/** Test that the signal is emitted when modifying the values using the underlying KConfigSkeletonItem (bypassing the setters) */
void KConfigCompiler_Test_Signals::testSetProperty()
{
- QFETCH(KCoreConfigSkeleton*, obj);
- const char* signal = SIGNAL(fooChanged(QString));
+ QFETCH(KCoreConfigSkeleton *, obj);
+ const char *signal = SIGNAL(fooChanged(QString));
const QString propertyName = QStringLiteral("foo");
const QString defaultValue = QStringLiteral("default");
const QString newValue = QStringLiteral("changed");
obj->setDefaults();
obj->save();
- KConfigSkeletonItem* item = obj->findItem(propertyName);
+ KConfigSkeletonItem *item = obj->findItem(propertyName);
QVERIFY2(item, "Item must exist");
QVERIFY2(!item->isImmutable(), "Item must not be immutable");
QVERIFY2(!obj->isImmutable(propertyName), "Item must not be immutable");
- //listen for all expected signals
+ // listen for all expected signals
QSignalSpy spy(obj, signal);
QVERIFY2(spy.isValid(), signal);
QVERIFY(item->isEqual(defaultValue));
QVERIFY(!item->isEqual(newValue));
- item->setProperty(newValue); //change value now
- //should have no change yet, only after save()
+ item->setProperty(newValue); // change value now
+ // should have no change yet, only after save()
QCOMPARE(spy.count(), 0);
obj->save();
- //now check for the signal emissions
+ // now check for the signal emissions
QCOMPARE(spy.count(), 1);
QList<QVariant> args = spy.takeFirst();
QCOMPARE(args.size(), 1);
QVERIFY(item->isEqual(args[0]));
- //now reset to default
+ // now reset to default
QVERIFY(!item->isEqual(defaultValue));
item->setDefault();
QVERIFY(item->isEqual(defaultValue));
- //should have no change yet, only after save()
+ // should have no change yet, only after save()
QCOMPARE(spy.count(), 0);
obj->save();
- //now check for the signal emissions
+ // now check for the signal emissions
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
QCOMPARE(args.size(), 1);
diff --git a/autotests/kconfig_compiler/myprefs.h b/autotests/kconfig_compiler/myprefs.h
index 609fc546..073352b9 100644
--- a/autotests/kconfig_compiler/myprefs.h
+++ b/autotests/kconfig_compiler/myprefs.h
@@ -6,7 +6,10 @@
class MyPrefs : public KConfigSkeleton
{
public:
- MyPrefs(const QString &a) : KConfigSkeleton(a) {}
+ MyPrefs(const QString &a)
+ : KConfigSkeleton(a)
+ {
+ }
};
#endif
diff --git a/autotests/kconfig_compiler/test1main.cpp b/autotests/kconfig_compiler/test1main.cpp
index 5a7eda0c..43dcd2c1 100644
--- a/autotests/kconfig_compiler/test1main.cpp
+++ b/autotests/kconfig_compiler/test1main.cpp
@@ -4,9 +4,9 @@
SPDX-License-Identifier: MIT
*/
#include "test1.h"
-#include <QGuiApplication>
#include <KConfig>
#include <KConfigGroup>
+#include <QGuiApplication>
int main(int argc, char **argv)
{
diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp
index 8792842f..fa9bf7dc 100644
--- a/autotests/kconfig_compiler/test4main.cpp
+++ b/autotests/kconfig_compiler/test4main.cpp
@@ -5,9 +5,9 @@
*/
#include "test4.h"
+#include <QFile>
#include <QGuiApplication>
#include <QStandardPaths>
-#include <QFile>
int main(int argc, char **argv)
{
diff --git a/autotests/kconfig_compiler/test9main.cpp b/autotests/kconfig_compiler/test9main.cpp
index 03c43f1b..0a7256f1 100644
--- a/autotests/kconfig_compiler/test9main.cpp
+++ b/autotests/kconfig_compiler/test9main.cpp
@@ -5,9 +5,9 @@
*/
#include "test9.h"
+#include <QDebug>
#include <QDir>
#include <QGuiApplication>
-#include <QDebug>
int main(int argc, char **argv)
{
diff --git a/autotests/kconfig_compiler/test_param_minmax_main.cpp b/autotests/kconfig_compiler/test_param_minmax_main.cpp
index 57fc26a7..9756a32f 100644
--- a/autotests/kconfig_compiler/test_param_minmax_main.cpp
+++ b/autotests/kconfig_compiler/test_param_minmax_main.cpp
@@ -26,4 +26,3 @@ int main(int, char **)
delete t;
return 0;
}
-
diff --git a/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp
index 7c4f9f55..2526254c 100644
--- a/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp
+++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp
@@ -1,4 +1,2 @@
#include "test_qdebugcategory_debug.h"
Q_LOGGING_CATEGORY(CATEGORY_LOG, "log_category")
-
-
diff --git a/autotests/kconfig_compiler/test_qdebugcategory_debug.h b/autotests/kconfig_compiler/test_qdebugcategory_debug.h
index 88ac4f35..a92e54ca 100644
--- a/autotests/kconfig_compiler/test_qdebugcategory_debug.h
+++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.h
@@ -5,4 +5,3 @@
Q_DECLARE_LOGGING_CATEGORY(CATEGORY_LOG)
#endif
-
diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp
index 2744d272..a9d3931a 100644
--- a/autotests/kconfigguitest.cpp
+++ b/autotests/kconfigguitest.cpp
@@ -4,13 +4,13 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
-#include <QtTestGui>
#include "kconfigguitest.h"
+#include <QtTestGui>
-#include <kconfig.h>
#include <QDir>
#include <QFont>
#include <QStandardPaths>
+#include <kconfig.h>
#include <kconfiggroup.h>
#include <kconfigskeleton.h>
@@ -77,8 +77,7 @@ void KConfigTest::testComplex()
KConfig sc2(QStringLiteral("kconfigtest"));
KConfigGroup sc3(&sc2, "ComplexTypes");
- QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(),
- QVariant(s_color_entry1).toString());
+ QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(), QVariant(s_color_entry1).toString());
QCOMPARE(sc3.readEntry("colorEntry1", QColor()), s_color_entry1);
QCOMPARE(sc3.readEntry("colorEntry2", QColor()), s_color_entry2);
QCOMPARE(sc3.readEntry("colorEntry3", QColor()), s_color_entry3);
@@ -118,19 +117,19 @@ void KConfigTest::testInvalid()
sc3.writeEntry("badList", list);
QVERIFY(sc.sync());
- QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds
+ QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds
// 4 element list
list << 4;
sc3.writeEntry("badList", list);
QVERIFY(sc.sync());
- QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds
+ QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds
list[2] = -3;
sc3.writeEntry("badList", list);
QVERIFY(sc.sync());
- QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds
+ QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds
// 5 element list
list[2] = 3;
diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp
index ab93c1da..17bfe403 100644
--- a/autotests/kconfigloadertest.cpp
+++ b/autotests/kconfigloadertest.cpp
@@ -7,20 +7,20 @@
#include <kconfig.h>
#include <kconfiggroup.h>
-#include <kconfigskeleton.h>
#include <kconfigloader.h>
+#include <kconfigskeleton.h>
Q_DECLARE_METATYPE(QList<int>)
static const QString s_testName(QStringLiteral("kconfigloadertest")); // clazy:exclude=non-pod-global-static
-#define GET_CONFIG_ITEM_VALUE(type, configName) \
- KConfigSkeletonItem* item = cl->findItem(s_testName, configName); \
- /* Check if we got back a valid item. */ \
- QVERIFY(item != nullptr); \
- /* Cast the item to the given type. */ \
- type typeItem = dynamic_cast<type>(item); \
- /* Make sure the cast was successful. */ \
+#define GET_CONFIG_ITEM_VALUE(type, configName) \
+ KConfigSkeletonItem *item = cl->findItem(s_testName, configName); \
+ /* Check if we got back a valid item. */ \
+ QVERIFY(item != nullptr); \
+ /* Cast the item to the given type. */ \
+ type typeItem = dynamic_cast<type>(item); \
+ /* Make sure the cast was successful. */ \
QVERIFY(typeItem != nullptr);
void ConfigLoaderTest::init()
@@ -191,4 +191,3 @@ void ConfigLoaderTest::ulongLongDefaultValue()
}
QTEST_MAIN(ConfigLoaderTest)
-
diff --git a/autotests/kconfignokdehometest.cpp b/autotests/kconfignokdehometest.cpp
index 1d05d98d..6cb105ef 100644
--- a/autotests/kconfignokdehometest.cpp
+++ b/autotests/kconfignokdehometest.cpp
@@ -6,8 +6,8 @@
#include <QObject>
-#include <QTest>
#include <QStandardPaths>
+#include <QTest>
#include <ksharedconfig.h>
#include <kconfig.h>
diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp
index 950e6581..88936f1e 100644
--- a/autotests/kconfigskeletontest.cpp
+++ b/autotests/kconfigskeletontest.cpp
@@ -6,20 +6,20 @@
#include "kconfigskeletontest.h"
-#include <kconfig.h>
#include <QFont>
#include <QtTestGui>
+#include <kconfig.h>
QTEST_MAIN(KConfigSkeletonTest)
// clazy:excludeall=non-pod-global-static
static const bool s_default_setting1{false};
-static const QColor s_default_setting2{1,2,3};
+static const QColor s_default_setting2{1, 2, 3};
static const QString s_default_setting4{QStringLiteral("Hello World")};
static const bool s_write_setting1{true};
-static const QColor s_write_setting2{3,2,1};
+static const QColor s_write_setting2{3, 2, 1};
static const QString s_write_setting4{QStringLiteral("KDE")};
static QFont defaultSetting3()
@@ -29,7 +29,7 @@ static QFont defaultSetting3()
static QFont writeSettings3()
{
- return QFont{QStringLiteral("helvetica"), 14};
+ return QFont{QStringLiteral("helvetica"), 14};
}
void KConfigSkeletonTest::initTestCase()
diff --git a/autotests/kconfigskeletontest.h b/autotests/kconfigskeletontest.h
index 6bac81d2..8c6d3aa7 100644
--- a/autotests/kconfigskeletontest.h
+++ b/autotests/kconfigskeletontest.h
@@ -12,7 +12,6 @@ class KConfigSkeletonTest : public QObject
{
Q_OBJECT
public:
-
private Q_SLOTS:
void initTestCase();
void init();
@@ -31,7 +30,6 @@ private:
QColor mMyColor;
QFont mMyFont;
QString mMyString;
-
};
#endif
diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp
index be84efec..bf7882f0 100644
--- a/autotests/kconfigtest.cpp
+++ b/autotests/kconfigtest.cpp
@@ -9,16 +9,16 @@
#include "config-kconfig.h"
-#include <QTest>
-#include <qtemporarydir.h>
-#include <QStandardPaths>
#include <QSignalSpy>
+#include <QStandardPaths>
#include <QTemporaryFile>
+#include <QTest>
#include <kdesktopfile.h>
+#include <qtemporarydir.h>
-#include <ksharedconfig.h>
#include <kconfiggroup.h>
#include <kconfigwatcher.h>
+#include <ksharedconfig.h>
#ifdef Q_OS_UNIX
#include <utime.h>
@@ -125,7 +125,7 @@ void KConfigTest::initTestCase()
cg.writeEntry("boolEntry2", s_bool_entry2);
QByteArray data(s_utf8bit_entry);
- QCOMPARE(data.size(), 12); // the source file is in utf8
+ QCOMPARE(data.size(), 12); // the source file is in utf8
QCOMPARE(QString::fromUtf8(data).length(), 9);
cg.writeEntry("Test", data);
cg.writeEntry("bytearrayEntry", s_bytearray_entry);
@@ -139,7 +139,7 @@ void KConfigTest::initTestCase()
cg.writeEntry("urlEntry1", QUrl(QStringLiteral("http://qt-project.org")));
cg.writeEntry("keywith=equalsign", s_string_entry1);
cg.deleteEntry("stringEntry5");
- cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry
+ cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry
cg.writeEntry("byteArrayEntry1", s_string_entry1.toLatin1(), KConfig::Global | KConfig::Persistent);
cg.writeEntry("doubleEntry1", s_double_entry);
cg.writeEntry("floatEntry1", s_float_entry);
@@ -187,7 +187,7 @@ void KConfigTest::initTestCase()
#if defined(_MSC_VER) && _MSC_VER == 1600
cg.writeEntry("dummy", 42);
#else
- //Visual C++ 2010 throws an Internal Compiler Error here
+ // Visual C++ 2010 throws an Internal Compiler Error here
cg.writeEntry("enum-10", Tens);
cg.writeEntry("enum-100", Hundreds);
cg.writeEntry("flags-bit0", Flags(bit0));
@@ -217,7 +217,7 @@ void KConfigTest::initTestCase()
sg0.writeEntry("FatalOutput", 0);
QVERIFY(sc1.sync());
- //Setup stuff to test KConfig::addConfigSources()
+ // Setup stuff to test KConfig::addConfigSources()
KConfig devcfg(s_test_subdir + QLatin1String("specificrc"));
KConfigGroup devonlygrp(&devcfg, "Specific Only Group");
devonlygrp.writeEntry("ExistingEntry", "DevValue");
@@ -236,14 +236,13 @@ void KConfigTest::initTestCase()
KConfig gecfg(s_test_subdir + QLatin1String("groupescapetest"), KConfig::SimpleConfig);
cg = KConfigGroup(&gecfg, s_dollargroup);
cg.writeEntry("entry", "doesntmatter");
-
}
void KConfigTest::cleanupTestCase()
{
- //ensure we don't delete the real directory
+ // ensure we don't delete the real directory
QDir localConfig(m_testConfigDir);
- //qDebug() << "Erasing" << localConfig;
+ // qDebug() << "Erasing" << localConfig;
if (localConfig.exists()) {
QVERIFY(localConfig.removeRecursively());
}
@@ -342,7 +341,7 @@ void KConfigTest::testSimple()
KConfigGroup sc3(&sc2, "AAA");
- QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals
+ QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals
QVERIFY(!sc3.isEntryImmutable("stringEntry1"));
QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1);
@@ -356,7 +355,7 @@ void KConfigTest::testSimple()
QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), s_bytearray_entry);
QCOMPARE(sc3.readEntry(s_escapekey), QString::fromLatin1(s_escape_entry));
QCOMPARE(sc3.readEntry("Test", QString{}), QString::fromUtf8(s_utf8bit_entry));
- QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QLatin1String(""));
+ QCOMPARE(sc3.readEntry("emptyEntry" /*, QString("Fietsbel")*/), QLatin1String(""));
QCOMPARE(sc3.readEntry("emptyEntry", QStringLiteral("Fietsbel")).isEmpty(), true);
QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1);
QCOMPARE(sc3.readEntry("stringEntry2"), s_string_entry2);
@@ -542,7 +541,7 @@ void KConfigTest::testPath()
QVERIFY(group.hasKey("noeol"));
QCOMPARE(group.readEntry("noeol", QString{}), QStringLiteral("foo"));
- const auto val = QStringList { QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")};
+ const auto val = QStringList{QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")};
QCOMPARE(group.readPathEntry(QStringLiteral("escapes"), QStringList()), val);
}
@@ -586,14 +585,17 @@ void KConfigTest::testPathQtHome()
qunsetenv("QT_CACHE_HOME");
qunsetenv("QT_CONFIG_HOME");
QVERIFY(group.hasKey("dataDir"));
- QCOMPARE(group.readEntry("dataDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest")));
+ QCOMPARE(group.readEntry("dataDir", QString{}),
+ QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest")));
QVERIFY(group.hasKey("cacheDir"));
- QCOMPARE(group.readEntry("cacheDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest")));
+ QCOMPARE(group.readEntry("cacheDir", QString{}),
+ QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest")));
QVERIFY(group.hasKey("configDir"));
- QCOMPARE(group.readEntry("configDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest")));
- qputenv("QT_DATA_HOME","/1");
- qputenv("QT_CACHE_HOME","/2");
- qputenv("QT_CONFIG_HOME","/3");
+ QCOMPARE(group.readEntry("configDir", QString{}),
+ QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest")));
+ qputenv("QT_DATA_HOME", "/1");
+ qputenv("QT_CACHE_HOME", "/2");
+ qputenv("QT_CONFIG_HOME", "/3");
QVERIFY(group.hasKey("dataDir"));
QCOMPARE(group.readEntry("dataDir", QString{}), QStringLiteral("/1/kconfigtest"));
QVERIFY(group.hasKey("cacheDir"));
@@ -618,9 +620,9 @@ void KConfigTest::testComplex()
void KConfigTest::testEnums()
{
- //Visual C++ 2010 (compiler version 16.0) throws an Internal Compiler Error
- //when compiling the code in initTestCase that creates these KConfig entries,
- //so we can't run this test
+ // Visual C++ 2010 (compiler version 16.0) throws an Internal Compiler Error
+ // when compiling the code in initTestCase that creates these KConfig entries,
+ // so we can't run this test
#if defined(_MSC_VER) && _MSC_VER == 1600
QSKIP("Visual C++ 2010 can't compile this test");
#endif
@@ -702,7 +704,7 @@ void KConfigTest::testInvalid()
QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint());
QVERIFY(sc3.readEntry("badList", QRect()) == QRect());
QVERIFY(sc3.readEntry("badList", QSize()) == QSize());
- QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); // out of bounds
+ QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); // out of bounds
QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime());
// 4 element list
@@ -819,13 +821,13 @@ void KConfigTest::testDelete()
cg.deleteGroup();
QVERIFY(sc.entryMap(QStringLiteral("Complex Types")).isEmpty());
QVERIFY(sc.entryMap(QStringLiteral("AAA")).isEmpty());
- QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); //not deleted group
- QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); //inexistant group
+ QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); // not deleted group
+ QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); // inexistant group
QVERIFY(cg.sync());
// Check what happens on disk
const QList<QByteArray> lines = readLines();
- //qDebug() << lines;
+ // qDebug() << lines;
QVERIFY(!lines.contains("[Complex Types]\n"));
QVERIFY(!lines.contains("[Complex Types][Nested Group 1]\n"));
QVERIFY(!lines.contains("[Complex Types][Nested Group 2]\n"));
@@ -1181,8 +1183,8 @@ void KConfigTest::testSubGroup()
QVERIFY(negsub4.exists());
// Only subgroups with content show up in groupList()
- //QEXPECT_FAIL("", "Empty subgroups do not show up in groupList()", Continue);
- //QCOMPARE(neg.groupList(), QStringList() << "NEG Child1" << "NEG Child2" << "NEG Child3" << "NEG Child4");
+ // QEXPECT_FAIL("", "Empty subgroups do not show up in groupList()", Continue);
+ // QCOMPARE(neg.groupList(), QStringList() << "NEG Child1" << "NEG Child2" << "NEG Child3" << "NEG Child4");
// This is what happens
QStringList groups = neg.groupList();
groups.sort(); // Qt5 made the ordering unreliable, due to QHash
@@ -1332,7 +1334,7 @@ void KConfigTest::testReparent()
QCOMPARE(group.entryMap(), originalMap);
group.reparent(&cf); // see if it can make it a top-level group again
-// QVERIFY(!parent.hasGroup(name));
+ // QVERIFY(!parent.hasGroup(name));
QCOMPARE(group.entryMap(), originalMap);
}
@@ -1377,8 +1379,7 @@ void KConfigTest::testWriteOnSync()
// Add a global entry and sync the config.
// Should not rewrite the local config file.
KConfigGroup cgGlobal(&sc, "Globals");
- cgGlobal.writeEntry("someGlobalString", "whatever",
- KConfig::Persistent | KConfig::Global);
+ cgGlobal.writeEntry("someGlobalString", "whatever", KConfig::Persistent | KConfig::Global);
QVERIFY(sc.sync());
// Verify that the timestamp of local config file didn't change.
@@ -1436,8 +1437,14 @@ void KConfigTest::testDirtyOnEqual()
void KConfigTest::testDirtyOnEqualOverdo()
{
- QByteArray val1("\0""one", 4);
- QByteArray val2("\0""two", 4);
+ QByteArray val1(
+ "\0"
+ "one",
+ 4);
+ QByteArray val2(
+ "\0"
+ "two",
+ 4);
QByteArray defvalr;
KConfig sc(s_kconfig_test_subdir);
@@ -1624,7 +1631,7 @@ void KConfigTest::testDeleteWhenLocalized()
QVERIFY(config.sync());
// Current state: [ca] and [de] entries left... oops.
- //qDebug() << readLinesFrom(file);
+ // qDebug() << readLinesFrom(file);
// Bug: The group still exists [because of the localized entries]...
QVERIFY(cg.exists());
@@ -1732,7 +1739,17 @@ void KConfigTest::testQByteArrayUtf8()
file.close();
QFile readFile(file.fileName());
QVERIFY(readFile.open(QFile::ReadOnly));
-#define VALUE "Utf8=\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff"
+#define VALUE \
+ "Utf8=" \
+ "\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x" \
+ "1f " \
+ "!\"#$%&'()*+,-./" \
+ "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" \
+ "\\x7f\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\" \
+ "x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xb" \
+ "b\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9" \
+ "\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\" \
+ "xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff"
const QByteArray fileBytes = readFile.readAll();
#ifndef Q_OS_WIN
QCOMPARE(fileBytes, QByteArrayLiteral("[General]\n" VALUE "\n"));
@@ -1815,7 +1832,6 @@ void KConfigTest::testNewlines()
#else
QCOMPARE(readFile.readAll(), QByteArrayLiteral("[General]\r\nBar=Foo\r\nFoo=Bar\r\n"));
#endif
-
}
void KConfigTest::testXdgListEntry()
@@ -1823,7 +1839,7 @@ void KConfigTest::testXdgListEntry()
QTemporaryFile file;
QVERIFY(file.open());
QTextStream out(&file);
- out << "[General]\n"
+ out << "[General]\n"
<< "Key1=\n" // empty list
// emtpty entries
<< "Key2=;\n"
@@ -1852,7 +1868,7 @@ void KConfigTest::testXdgListEntry()
void KConfigTest::testThreads()
{
QThreadPool::globalInstance()->setMaxThreadCount(6);
- QList<QFuture<void> > futures;
+ QList<QFuture<void>> futures;
// Run in parallel some tests that work on different config files,
// otherwise unexpected things might indeed happen.
futures << QtConcurrent::run(this, &KConfigTest::testAddConfigSources);
@@ -1861,8 +1877,8 @@ void KConfigTest::testThreads()
futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig);
futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig);
// QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage...
- //futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized);
- //futures << QtConcurrent::run(this, &KConfigTest::testEntryMap);
+ // futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized);
+ // futures << QtConcurrent::run(this, &KConfigTest::testEntryMap);
for (QFuture<void> f : qAsConst(futures)) {
f.waitForFinished();
}
@@ -1877,28 +1893,28 @@ void KConfigTest::testNotify()
KConfig config(s_kconfig_test_subdir);
auto myConfigGroup = KConfigGroup(&config, "TopLevelGroup");
- //mimics a config in another process, which is watching for events
+ // mimics a config in another process, which is watching for events
auto remoteConfig = KSharedConfig::openConfig(s_kconfig_test_subdir);
KConfigWatcher::Ptr watcher = KConfigWatcher::create(remoteConfig);
- //some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals
+ // some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals
auto otherRemoteConfig = KSharedConfig::openConfig(s_test_subdir + QLatin1String("kconfigtest2"));
KConfigWatcher::Ptr otherWatcher = KConfigWatcher::create(otherRemoteConfig);
QSignalSpy watcherSpy(watcher.data(), &KConfigWatcher::configChanged);
QSignalSpy otherWatcherSpy(otherWatcher.data(), &KConfigWatcher::configChanged);
- //write entries in a group and subgroup
- myConfigGroup.writeEntry("entryA", "foo", KConfig::Persistent | KConfig::Notify);
+ // write entries in a group and subgroup
+ myConfigGroup.writeEntry("entryA", "foo", KConfig::Persistent | KConfig::Notify);
auto subGroup = myConfigGroup.group("aSubGroup");
- subGroup.writeEntry("entry1", "foo", KConfig::Persistent | KConfig::Notify);
- subGroup.writeEntry("entry2", "foo", KConfig::Persistent | KConfig::Notify);
+ subGroup.writeEntry("entry1", "foo", KConfig::Persistent | KConfig::Notify);
+ subGroup.writeEntry("entry2", "foo", KConfig::Persistent | KConfig::Notify);
config.sync();
watcherSpy.wait();
QCOMPARE(watcherSpy.count(), 2);
- std::sort(watcherSpy.begin(), watcherSpy.end(), [] (QList<QVariant> a, QList<QVariant> b) {
- return a[0].value<KConfigGroup>().name() < b[0].value<KConfigGroup>().name();
+ std::sort(watcherSpy.begin(), watcherSpy.end(), [](QList<QVariant> a, QList<QVariant> b) {
+ return a[0].value<KConfigGroup>().name() < b[0].value<KConfigGroup>().name();
});
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
@@ -1908,7 +1924,7 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[1][0].value<KConfigGroup>().parent().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[1][1].value<QByteArrayList>(), QByteArrayList({"entry1", "entry2"}));
- //delete an entry
+ // delete an entry
watcherSpy.clear();
myConfigGroup.deleteEntry("entryA", KConfig::Persistent | KConfig::Notify);
config.sync();
@@ -1917,7 +1933,7 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"entryA"}));
- //revert to default an entry
+ // revert to default an entry
watcherSpy.clear();
myConfigGroup.revertToDefault("entryA", KConfig::Persistent | KConfig::Notify);
config.sync();
@@ -1926,7 +1942,7 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"entryA"}));
- //deleting a group, should notify that every entry in that group has changed
+ // deleting a group, should notify that every entry in that group has changed
watcherSpy.clear();
myConfigGroup.deleteGroup("aSubGroup", KConfig::Persistent | KConfig::Notify);
config.sync();
@@ -1935,16 +1951,16 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("aSubGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"entry1", "entry2"}));
- //global write still triggers our notification
+ // global write still triggers our notification
watcherSpy.clear();
- myConfigGroup.writeEntry("someGlobalEntry", "foo", KConfig::Persistent | KConfig::Notify | KConfig::Global);
+ myConfigGroup.writeEntry("someGlobalEntry", "foo", KConfig::Persistent | KConfig::Notify | KConfig::Global);
config.sync();
watcherSpy.wait();
QCOMPARE(watcherSpy.count(), 1);
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"someGlobalEntry"}));
- //watching another file should have only triggered from the kdeglobals change
+ // watching another file should have only triggered from the kdeglobals change
QCOMPARE(otherWatcherSpy.count(), 1);
QCOMPARE(otherWatcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(otherWatcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"someGlobalEntry"}));
diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h
index cb6e3712..d6502331 100644
--- a/autotests/kconfigtest.h
+++ b/autotests/kconfigtest.h
@@ -14,9 +14,18 @@ class KConfigTest : public QObject
Q_OBJECT
public:
- enum Testing { Ones = 1, Tens = 10, Hundreds = 100,};
+ enum Testing {
+ Ones = 1,
+ Tens = 10,
+ Hundreds = 100,
+ };
Q_ENUM(Testing)
- enum bits { bit0 = 1, bit1 = 2, bit2 = 4, bit3 = 8, };
+ enum bits {
+ bit0 = 1,
+ bit1 = 2,
+ bit2 = 4,
+ bit3 = 8,
+ };
Q_DECLARE_FLAGS(Flags, bits)
Q_FLAG(Flags)
diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp
index e45ba44e..cadc3b3d 100644
--- a/autotests/kdesktopfiletest.cpp
+++ b/autotests/kdesktopfiletest.cpp
@@ -29,13 +29,12 @@ void KDesktopFileTest::testRead()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type= Application\n"
- "Name=My Application\n"
- "Icon = foo\n"
- "MimeType =text/plain;image/png;\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type= Application\n"
+ "Name=My Application\n"
+ "Icon = foo\n"
+ "MimeType =text/plain;image/png;\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
QVERIFY(KDesktopFile::isDesktopFile(fileName));
@@ -44,8 +43,7 @@ void KDesktopFileTest::testRead()
QVERIFY(df.hasApplicationType());
QCOMPARE(df.readName(), QString::fromLatin1("My Application"));
QCOMPARE(df.readIcon(), QString::fromLatin1("foo"));
- QCOMPARE(df.readMimeTypes(), QStringList() << QString::fromLatin1("text/plain")
- << QString::fromLatin1("image/png"));
+ QCOMPARE(df.readMimeTypes(), QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("image/png"));
QVERIFY(!df.hasLinkType());
QCOMPARE(df.fileName(), QFileInfo(fileName).canonicalFilePath());
}
@@ -57,17 +55,15 @@ void KDesktopFileTest::testReadDirectory()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Directory\n"
- "SortOrder=2.desktop;1.desktop;\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Directory\n"
+ "SortOrder=2.desktop;1.desktop;\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
QCOMPARE(df.readType(), QString::fromLatin1("Directory"));
- QCOMPARE(df.sortOrder(), QStringList() << QString::fromLatin1("2.desktop")
- << QString::fromLatin1("1.desktop"));
+ QCOMPARE(df.sortOrder(), QStringList() << QString::fromLatin1("2.desktop") << QString::fromLatin1("1.desktop"));
}
#endif
@@ -77,19 +73,19 @@ void KDesktopFileTest::testReadLocalized_data()
QTest::addColumn<QString>("translation");
const QString german = QStringLiteral("Meine Anwendung");
- const QString swiss = QStringLiteral("Mein Anwendungsli");
+ const QString swiss = QStringLiteral("Mein Anwendungsli");
- QTest::newRow("de") << QLocale(QLocale::German) << german;
- QTest::newRow("de_DE") << QLocale(QStringLiteral("de_DE")) << german;
+ QTest::newRow("de") << QLocale(QLocale::German) << german;
+ QTest::newRow("de_DE") << QLocale(QStringLiteral("de_DE")) << german;
QTest::newRow("de_DE@bayern") << QLocale(QStringLiteral("de_DE@bayern")) << german;
- QTest::newRow("de@bayern") << QLocale(QStringLiteral("de@bayern")) << german;
- QTest::newRow("de@freiburg") << QLocale(QStringLiteral("de@freiburg")) << QStringLiteral("Mein Anwendungsle");
+ QTest::newRow("de@bayern") << QLocale(QStringLiteral("de@bayern")) << german;
+ QTest::newRow("de@freiburg") << QLocale(QStringLiteral("de@freiburg")) << QStringLiteral("Mein Anwendungsle");
// For CH we have a special translation
- QTest::newRow("de_CH") << QLocale(QLocale::German, QLocale::Switzerland) << swiss;
- QTest::newRow("de_CH@bern") << QLocale(QStringLiteral("de_CH@bern")) << swiss;
+ QTest::newRow("de_CH") << QLocale(QLocale::German, QLocale::Switzerland) << swiss;
+ QTest::newRow("de_CH@bern") << QLocale(QStringLiteral("de_CH@bern")) << swiss;
// Austria should fall back to "de"
- QTest::newRow("de_AT") << QLocale(QLocale::German, QLocale::Austria) << german;
- QTest::newRow("de_AT@tirol") << QLocale(QStringLiteral("de_AT@tirol")) << german;
+ QTest::newRow("de_AT") << QLocale(QLocale::German, QLocale::Austria) << german;
+ QTest::newRow("de_AT@tirol") << QLocale(QStringLiteral("de_AT@tirol")) << german;
// no translation for French
QTest::newRow("fr") << QLocale(QLocale::French) << QStringLiteral("My Application");
}
@@ -100,15 +96,14 @@ void KDesktopFileTest::testReadLocalized()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Name[de]=Meine Anwendung\n"
- "Name[de@freiburg]=Mein Anwendungsle\n"
- "Name[de_CH]=Mein Anwendungsli\n"
- "Icon=foo\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Name[de]=Meine Anwendung\n"
+ "Name[de@freiburg]=Mein Anwendungsle\n"
+ "Name[de_CH]=Mein Anwendungsli\n"
+ "Icon=foo\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
QVERIFY(KDesktopFile::isDesktopFile(fileName));
@@ -129,10 +124,9 @@ void KDesktopFileTest::testSuccessfulTryExec()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "TryExec=whoami\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "TryExec=whoami\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
@@ -145,10 +139,9 @@ void KDesktopFileTest::testUnsuccessfulTryExec()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "TryExec=/does/not/exist\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "TryExec=/does/not/exist\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
@@ -161,18 +154,17 @@ void KDesktopFileTest::testActionGroup()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- // make sure escaping of ';' using "\;" works
- "Actions=encrypt;semi\\;colon;decrypt;\n"
- "[Desktop Action encrypt]\n"
- "Name=Encrypt file\n"
- "[Desktop Action decrypt]\n"
- "Name=Decrypt file\n"
- // no escaping needed in group header
- "[Desktop Action semi;colon]\n"
- "Name=With semicolon\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ // make sure escaping of ';' using "\;" works
+ "Actions=encrypt;semi\\;colon;decrypt;\n"
+ "[Desktop Action encrypt]\n"
+ "Name=Encrypt file\n"
+ "[Desktop Action decrypt]\n"
+ "Name=Decrypt file\n"
+ // no escaping needed in group header
+ "[Desktop Action semi;colon]\n"
+ "Name=With semicolon\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
@@ -200,12 +192,11 @@ void KDesktopFileTest::testIsAuthorizedDesktopFile()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Exec=kfoo\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Exec=kfoo\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
QVERIFY(!KDesktopFile::isAuthorizedDesktopFile(fileName));
@@ -232,14 +223,13 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Exec=kfoo\n"
- "TryExec=bash\n"
- "X-KDE-AuthorizeAction=someAction"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Exec=kfoo\n"
+ "TryExec=bash\n"
+ "X-KDE-AuthorizeAction=someAction"
+ "\n";
file.close();
KDesktopFile desktopFile(fileName);
@@ -250,14 +240,13 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Exec=kfoo\n"
- "TryExec=bash\n"
- "X-KDE-AuthorizeAction=someBlockedAction"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Exec=kfoo\n"
+ "TryExec=bash\n"
+ "X-KDE-AuthorizeAction=someBlockedAction"
+ "\n";
file.close();
KDesktopFile desktopFile(fileName);
diff --git a/autotests/kdesktopfiletest.h b/autotests/kdesktopfiletest.h
index 1ab1498c..6bf97bf8 100644
--- a/autotests/kdesktopfiletest.h
+++ b/autotests/kdesktopfiletest.h
@@ -28,7 +28,6 @@ private Q_SLOTS:
void testTryExecWithAuthorizeAction();
void testLocateLocal_data();
void testLocateLocal();
-
};
#endif /* KDESKTOPFILETEST_H */
diff --git a/autotests/kentrymaptest.h b/autotests/kentrymaptest.h
index b1bcea74..faf3ad6d 100644
--- a/autotests/kentrymaptest.h
+++ b/autotests/kentrymaptest.h
@@ -7,8 +7,8 @@
#ifndef KENTRYMAPTEST_H
#define KENTRYMAPTEST_H
-#include <QObject>
#include "kconfigdata.h"
+#include <QObject>
class KEntryMapTest : public QObject
{
diff --git a/autotests/ksharedconfig_in_global_object.cpp b/autotests/ksharedconfig_in_global_object.cpp
index aab982c2..4d9b07d3 100644
--- a/autotests/ksharedconfig_in_global_object.cpp
+++ b/autotests/ksharedconfig_in_global_object.cpp
@@ -6,10 +6,10 @@
*/
#include <QCoreApplication>
-#include <QtGlobal>
#include <QTimer>
-#include <ksharedconfig.h>
+#include <QtGlobal>
#include <kconfiggroup.h>
+#include <ksharedconfig.h>
#include <stdio.h>
class Tester
diff --git a/autotests/ksharedconfigtest.cpp b/autotests/ksharedconfigtest.cpp
index 957b509f..06ed7898 100644
--- a/autotests/ksharedconfigtest.cpp
+++ b/autotests/ksharedconfigtest.cpp
@@ -6,8 +6,8 @@
*/
#include <QTest>
-#include <ksharedconfig.h>
#include <kconfiggroup.h>
+#include <ksharedconfig.h>
class KSharedConfigTest : public QObject
{
@@ -18,6 +18,7 @@ private Q_SLOTS:
void testReadWrite();
void testReadWriteSync();
void testQrcFile();
+
private:
QString m_path;
};
@@ -26,8 +27,8 @@ void KSharedConfigTest::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
- m_path = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)
- + QLatin1Char('/') + QCoreApplication::applicationName() + QStringLiteral("rc");
+ m_path =
+ QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + QCoreApplication::applicationName() + QStringLiteral("rc");
QFile::remove(m_path);
}
diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp
index 1b7f88ff..cafad63f 100644
--- a/autotests/kstandardshortcuttest.cpp
+++ b/autotests/kstandardshortcuttest.cpp
@@ -4,10 +4,10 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
-#include <QTest>
#include "kstandardshortcuttest.h"
+#include <QTest>
-QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel
+QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel
#include <kstandardshortcut.h>
diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp
index f08e06ca..565a86f8 100644
--- a/autotests/test_kconf_update.cpp
+++ b/autotests/test_kconf_update.cpp
@@ -9,13 +9,13 @@
#include <memory>
// Qt
-#include <QFile>
+#include "config-kconf.h"
#include <QDir>
-#include <QSharedPointer>
+#include <QFile>
#include <QProcess>
-#include <qtemporaryfile.h>
+#include <QSharedPointer>
#include <qstandardpaths.h>
-#include "config-kconf.h"
+#include <qtemporaryfile.h>
#include <qtest.h>
@@ -80,225 +80,146 @@ void TestKConfUpdate::test_data()
QTest::addColumn<bool>("useVersion5");
QTest::addColumn<bool>("shouldUpdateWork");
- QTest::newRow("moveKeysSameFile")
- <<
- "File=testrc\n"
- "Group=group\n"
- "Key=old,new\n"
- "Options=overwrite\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- "testrc"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "new=value\n"
- <<
- ""
- << true
- << true
- ;
- QTest::newRow("moveKeysOtherFile")
- <<
- "File=oldrc,newrc\n"
- "Group=group1,group2\n"
- "Key=old,new\n"
- "Options=overwrite\n"
- <<
- "oldrc"
- <<
- "[group1]\n"
- "old=value\n"
- "[stay]\n"
- "foo=bar\n"
- <<
- "newrc"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group2]\n"
- "new=value\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[stay]\n"
- "foo=bar\n"
- << true
- << true
- ;
- QTest::newRow("allKeys")
- <<
- "File=testrc\n"
- "Group=group1,group2\n"
- "AllKeys\n"
- <<
- "testrc"
- <<
- "[group1]\n"
- "key1=value1\n"
- "key2=value2\n"
- "\n"
- "[stay]\n"
- "foo=bar\n"
- <<
- "testrc"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group2]\n"
- "key1=value1\n"
- "key2=value2\n"
- "\n"
- "[stay]\n"
- "foo=bar\n"
- <<
- ""
- << true
- << true
- ;
- QTest::newRow("allKeysSubGroup")
- <<
- "File=testrc\n"
- "Group=[group][sub1],[group][sub2]\n"
- "AllKeys\n"
- <<
- "testrc"
- <<
- "[group][sub1]\n"
- "key1=value1\n"
- "key2=value2\n"
- "\n"
- "[group][sub1][subsub]\n"
- "key3=value3\n"
- "key4=value4\n"
- "\n"
- "[stay]\n"
- "foo=bar\n"
- <<
- "testrc"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group][sub2]\n"
- "key1=value1\n"
- "key2=value2\n"
- "\n"
- "[group][sub2][subsub]\n"
- "key3=value3\n"
- "key4=value4\n"
- "\n"
- "[stay]\n"
- "foo=bar\n"
- <<
- ""
- << true
- << true
- ;
- QTest::newRow("removeGroup")
- <<
- "File=testrc\n"
- "RemoveGroup=remove\n"
- <<
- "testrc"
- <<
- "[keep]\n"
- "key=value\n"
- ""
- "[remove]\n"
- "key=value\n"
- <<
- "testrc"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[keep]\n"
- "key=value\n"
- <<
- ""
- << true
- << true
- ;
- QTest::newRow("moveKeysSameFileDontExist")
- <<
- "File=testrc\n"
- "Group=group,group2\n"
- "Key=key1\n"
- "Key=key2\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "key1=value1\n"
- "key3=value3\n"
- <<
- "testrc"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "key3=value3\n"
- "\n"
- "[group2]\n"
- "key1=value1\n"
- <<
- ""
- << true
- << true
- ;
- QTest::newRow("DontMigrateWhenFileDoesntHaveVersion")
- <<
- "File=testrc\n"
- "Group=group\n"
- "Key=old,new\n"
- "Options=overwrite\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- ""
- << false
- << false
- ;
-
- QTest::newRow("DontMigrateWhenUpdateCantDoItMissingFilename")
- <<
- "Group=group\n"
- "Key=old,new\n"
- "Options=overwrite\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- ""
- << true
- << false
- ;
+ QTest::newRow("moveKeysSameFile") << "File=testrc\n"
+ "Group=group\n"
+ "Key=old,new\n"
+ "Options=overwrite\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "testrc"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "new=value\n"
+ << "" << true << true;
+ QTest::newRow("moveKeysOtherFile") << "File=oldrc,newrc\n"
+ "Group=group1,group2\n"
+ "Key=old,new\n"
+ "Options=overwrite\n"
+ << "oldrc"
+ << "[group1]\n"
+ "old=value\n"
+ "[stay]\n"
+ "foo=bar\n"
+ << "newrc"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group2]\n"
+ "new=value\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[stay]\n"
+ "foo=bar\n"
+ << true << true;
+ QTest::newRow("allKeys") << "File=testrc\n"
+ "Group=group1,group2\n"
+ "AllKeys\n"
+ << "testrc"
+ << "[group1]\n"
+ "key1=value1\n"
+ "key2=value2\n"
+ "\n"
+ "[stay]\n"
+ "foo=bar\n"
+ << "testrc"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group2]\n"
+ "key1=value1\n"
+ "key2=value2\n"
+ "\n"
+ "[stay]\n"
+ "foo=bar\n"
+ << "" << true << true;
+ QTest::newRow("allKeysSubGroup") << "File=testrc\n"
+ "Group=[group][sub1],[group][sub2]\n"
+ "AllKeys\n"
+ << "testrc"
+ << "[group][sub1]\n"
+ "key1=value1\n"
+ "key2=value2\n"
+ "\n"
+ "[group][sub1][subsub]\n"
+ "key3=value3\n"
+ "key4=value4\n"
+ "\n"
+ "[stay]\n"
+ "foo=bar\n"
+ << "testrc"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group][sub2]\n"
+ "key1=value1\n"
+ "key2=value2\n"
+ "\n"
+ "[group][sub2][subsub]\n"
+ "key3=value3\n"
+ "key4=value4\n"
+ "\n"
+ "[stay]\n"
+ "foo=bar\n"
+ << "" << true << true;
+ QTest::newRow("removeGroup") << "File=testrc\n"
+ "RemoveGroup=remove\n"
+ << "testrc"
+ << "[keep]\n"
+ "key=value\n"
+ ""
+ "[remove]\n"
+ "key=value\n"
+ << "testrc"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[keep]\n"
+ "key=value\n"
+ << "" << true << true;
+ QTest::newRow("moveKeysSameFileDontExist") << "File=testrc\n"
+ "Group=group,group2\n"
+ "Key=key1\n"
+ "Key=key2\n"
+ << "testrc"
+ << "[group]\n"
+ "key1=value1\n"
+ "key3=value3\n"
+ << "testrc"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "key3=value3\n"
+ "\n"
+ "[group2]\n"
+ "key1=value1\n"
+ << "" << true << true;
+ QTest::newRow("DontMigrateWhenFileDoesntHaveVersion") << "File=testrc\n"
+ "Group=group\n"
+ "Key=old,new\n"
+ "Options=overwrite\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "" << false << false;
+
+ QTest::newRow("DontMigrateWhenUpdateCantDoItMissingFilename") << "Group=group\n"
+ "Key=old,new\n"
+ "Options=overwrite\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "" << true << false;
}
void TestKConfUpdate::test()
@@ -362,238 +283,172 @@ void TestKConfUpdate::testScript_data()
QTest::addColumn<QString>("oldConfContent");
QTest::addColumn<QString>("expectedNewConfContent");
- QTest::newRow("delete-key")
- <<
- "File=testrc\n"
- "Group=group\n"
- "Script=test.sh,sh\n"
- <<
- "echo '# DELETE deprecated'\n"
- <<
- "[group]\n"
- "deprecated=foo\n"
- "valid=bar\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "valid=bar\n"
- ;
-
- QTest::newRow("delete-key2")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '# DELETE [group]deprecated'\n"
- "echo '# DELETE [group][sub]deprecated2'\n"
- <<
- "[group]\n"
- "deprecated=foo\n"
- "valid=bar\n"
- "\n"
- "[group][sub]\n"
- "deprecated2=foo\n"
- "valid2=bar\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "valid=bar\n"
- "\n"
- "[group][sub]\n"
- "valid2=bar\n"
- ;
-
- QTest::newRow("delete-group")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '# DELETEGROUP [group1]'\n"
- "echo '# DELETEGROUP [group2][sub]'\n"
- <<
- "[group1]\n"
- "key=value\n"
- "\n"
- "[group2]\n"
- "valid=bar\n"
- "\n"
- "[group2][sub]\n"
- "key=value\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group2]\n"
- "valid=bar\n"
- ;
-
- QTest::newRow("delete-group2")
- <<
- "File=testrc\n"
- "Group=group\n"
- "Script=test.sh,sh\n"
- <<
- "echo '# DELETEGROUP'\n"
- <<
- "[group]\n"
- "key=value\n"
- "\n"
- "[group2]\n"
- "valid=bar\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group2]\n"
- "valid=bar\n"
- ;
-
- QTest::newRow("new-key")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '[group]'\n"
- "echo 'new=value'\n"
- <<
- "[group]\n"
- "valid=bar\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "new=value\n"
- "valid=bar\n"
- ;
-
- QTest::newRow("modify-key-no-overwrite")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '[group]'\n"
- "echo 'existing=new'\n"
- <<
- "[group]\n"
- "existing=old\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "existing=old\n"
- ;
-
- QTest::newRow("modify-key-overwrite")
- <<
- "File=testrc\n"
- "Options=overwrite\n"
- "Script=test.sh,sh\n"
- <<
- "echo '[group]'\n"
- "echo 'existing=new'\n"
- <<
- "[group]\n"
- "existing=old\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "existing=new\n"
- ;
-
- QTest::newRow("new-key-in-subgroup")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '[group][sub]'\n"
- "echo 'new=value2'\n"
- <<
- "[group][sub]\n"
- "existing=foo\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group][sub]\n"
- "existing=foo\n"
- "new=value2\n"
- ;
-
- QTest::newRow("new-key-in-subgroup2")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '[group][sub]'\n"
- "echo 'new=value3'\n"
- <<
- "[group][sub]\n"
- "existing=foo\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group][sub]\n"
- "existing=foo\n"
- "new=value3\n"
- ;
+ QTest::newRow("delete-key") << "File=testrc\n"
+ "Group=group\n"
+ "Script=test.sh,sh\n"
+ << "echo '# DELETE deprecated'\n"
+ << "[group]\n"
+ "deprecated=foo\n"
+ "valid=bar\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "valid=bar\n";
+
+ QTest::newRow("delete-key2") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '# DELETE [group]deprecated'\n"
+ "echo '# DELETE [group][sub]deprecated2'\n"
+ << "[group]\n"
+ "deprecated=foo\n"
+ "valid=bar\n"
+ "\n"
+ "[group][sub]\n"
+ "deprecated2=foo\n"
+ "valid2=bar\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "valid=bar\n"
+ "\n"
+ "[group][sub]\n"
+ "valid2=bar\n";
+
+ QTest::newRow("delete-group") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '# DELETEGROUP [group1]'\n"
+ "echo '# DELETEGROUP [group2][sub]'\n"
+ << "[group1]\n"
+ "key=value\n"
+ "\n"
+ "[group2]\n"
+ "valid=bar\n"
+ "\n"
+ "[group2][sub]\n"
+ "key=value\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group2]\n"
+ "valid=bar\n";
+
+ QTest::newRow("delete-group2") << "File=testrc\n"
+ "Group=group\n"
+ "Script=test.sh,sh\n"
+ << "echo '# DELETEGROUP'\n"
+ << "[group]\n"
+ "key=value\n"
+ "\n"
+ "[group2]\n"
+ "valid=bar\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group2]\n"
+ "valid=bar\n";
+
+ QTest::newRow("new-key") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '[group]'\n"
+ "echo 'new=value'\n"
+ << "[group]\n"
+ "valid=bar\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "new=value\n"
+ "valid=bar\n";
+
+ QTest::newRow("modify-key-no-overwrite") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '[group]'\n"
+ "echo 'existing=new'\n"
+ << "[group]\n"
+ "existing=old\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "existing=old\n";
+
+ QTest::newRow("modify-key-overwrite") << "File=testrc\n"
+ "Options=overwrite\n"
+ "Script=test.sh,sh\n"
+ << "echo '[group]'\n"
+ "echo 'existing=new'\n"
+ << "[group]\n"
+ "existing=old\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "existing=new\n";
+
+ QTest::newRow("new-key-in-subgroup") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '[group][sub]'\n"
+ "echo 'new=value2'\n"
+ << "[group][sub]\n"
+ "existing=foo\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group][sub]\n"
+ "existing=foo\n"
+ "new=value2\n";
+
+ QTest::newRow("new-key-in-subgroup2") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '[group][sub]'\n"
+ "echo 'new=value3'\n"
+ << "[group][sub]\n"
+ "existing=foo\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group][sub]\n"
+ "existing=foo\n"
+ "new=value3\n";
if (QStandardPaths::findExecutable(QStringLiteral("sed")).isEmpty()) {
qWarning("sed executable not found, cannot run all tests!");
} else {
- QTest::newRow("filter")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '# DELETE [group]changed'\n"
- "sed s/value/VALUE/\n"
- <<
- "[group]\n"
- "changed=value\n"
- "unchanged=value\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "changed=VALUE\n"
- "unchanged=value\n"
- ;
-
- QTest::newRow("filter-subgroup")
- <<
- "File=testrc\n"
- "Script=test.sh,sh\n"
- <<
- "echo '# DELETE [group][sub]changed'\n"
- "sed s/value/VALUE/\n"
- <<
- "[group]\n"
- "unchanged=value\n"
- "\n"
- "[group][sub]\n"
- "changed=value\n"
- "unchanged=value\n"
- <<
- "[$Version]\n"
- "update_info=%1\n"
- "\n"
- "[group]\n"
- "unchanged=value\n"
- "\n"
- "[group][sub]\n"
- "changed=VALUE\n"
- "unchanged=value\n"
- ;
+ QTest::newRow("filter") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '# DELETE [group]changed'\n"
+ "sed s/value/VALUE/\n"
+ << "[group]\n"
+ "changed=value\n"
+ "unchanged=value\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "changed=VALUE\n"
+ "unchanged=value\n";
+
+ QTest::newRow("filter-subgroup") << "File=testrc\n"
+ "Script=test.sh,sh\n"
+ << "echo '# DELETE [group][sub]changed'\n"
+ "sed s/value/VALUE/\n"
+ << "[group]\n"
+ "unchanged=value\n"
+ "\n"
+ "[group][sub]\n"
+ "changed=value\n"
+ "unchanged=value\n"
+ << "[$Version]\n"
+ "update_info=%1\n"
+ "\n"
+ "[group]\n"
+ "unchanged=value\n"
+ "\n"
+ "[group][sub]\n"
+ "changed=VALUE\n"
+ "unchanged=value\n";
}
}
diff --git a/autotests/test_kconfigutils.cpp b/autotests/test_kconfigutils.cpp
index 1e6c49f7..96959474 100644
--- a/autotests/test_kconfigutils.cpp
+++ b/autotests/test_kconfigutils.cpp
@@ -20,35 +20,16 @@ void TestKConfigUtils::testParseGroupString_data()
QTest::addColumn<QStringList>("expected");
QTest::addColumn<bool>("expectedOk");
- QTest::newRow("simple-group")
- << " group "
- << (QStringList() << QStringLiteral("group"))
- << true
- ;
-
- QTest::newRow("sub-group")
- << "[group][sub]"
- << (QStringList() << QStringLiteral("group") << QStringLiteral("sub"))
- << true
- ;
-
- QTest::newRow("crazy-sub-group")
- << "[a\\ttab\\x5d[and some hex esc\\x61pe]"
- << (QStringList() << QStringLiteral("a\ttab") << QStringLiteral("and some hex escape"))
- << true
- ;
-
- QTest::newRow("missing-closing-brace")
- << "[group][sub"
- << QStringList()
- << false
- ;
-
- QTest::newRow("invalid-escape-string")
- << "[a\\z]"
- << QStringList()
- << false
- ;
+ QTest::newRow("simple-group") << " group " << (QStringList() << QStringLiteral("group")) << true;
+
+ QTest::newRow("sub-group") << "[group][sub]" << (QStringList() << QStringLiteral("group") << QStringLiteral("sub")) << true;
+
+ QTest::newRow("crazy-sub-group") << "[a\\ttab\\x5d[and some hex esc\\x61pe]"
+ << (QStringList() << QStringLiteral("a\ttab") << QStringLiteral("and some hex escape")) << true;
+
+ QTest::newRow("missing-closing-brace") << "[group][sub" << QStringList() << false;
+
+ QTest::newRow("invalid-escape-string") << "[a\\z]" << QStringList() << false;
}
void TestKConfigUtils::testParseGroupString()
@@ -76,47 +57,26 @@ void TestKConfigUtils::testUnescapeString_data()
QTest::addColumn<QString>("expected");
QTest::addColumn<bool>("expectedOk");
- QTest::newRow("plain")
- << "Some text"
- << "Some text"
- << true
- ;
-
- QTest::newRow("single-char-escapes")
- << "01\\s23\\t45\\n67\\r89\\\\"
- << "01 23\t45\n67\r89\\"
- << true
- ;
-
- QTest::newRow("hex-escapes")
- << "kd\\x65"
- << "kde"
- << true
- ;
-
- QTest::newRow("unfinished-hex-escape")
- << "kd\\x6"
- << ""
- << false
- ;
-
- QTest::newRow("invalid-hex-escape")
- << "kd\\xzz"
- << ""
- << false
- ;
-
- QTest::newRow("invalid-escape-sequence")
- << "Foo\\a"
- << ""
- << false
- ;
-
- QTest::newRow("unfinished-escape-sequence")
- << "Foo\\"
- << ""
- << false
- ;
+ QTest::newRow("plain") << "Some text"
+ << "Some text" << true;
+
+ QTest::newRow("single-char-escapes") << "01\\s23\\t45\\n67\\r89\\\\"
+ << "01 23\t45\n67\r89\\" << true;
+
+ QTest::newRow("hex-escapes") << "kd\\x65"
+ << "kde" << true;
+
+ QTest::newRow("unfinished-hex-escape") << "kd\\x6"
+ << "" << false;
+
+ QTest::newRow("invalid-hex-escape") << "kd\\xzz"
+ << "" << false;
+
+ QTest::newRow("invalid-escape-sequence") << "Foo\\a"
+ << "" << false;
+
+ QTest::newRow("unfinished-escape-sequence") << "Foo\\"
+ << "" << false;
}
void TestKConfigUtils::testUnescapeString()
@@ -137,4 +97,3 @@ void TestKConfigUtils::testUnescapeString()
qDebug() << error;
}
}
-
diff --git a/src/core/bufferfragment_p.h b/src/core/bufferfragment_p.h
index 3edbb6b6..f75af1d6 100644
--- a/src/core/bufferfragment_p.h
+++ b/src/core/bufferfragment_p.h
@@ -24,14 +24,16 @@
class KConfigIniBackend::BufferFragment
{
-
public:
-
- BufferFragment() : d(nullptr), len(0)
+ BufferFragment()
+ : d(nullptr)
+ , len(0)
{
}
- BufferFragment(char *buf, int size) : d(buf), len(size)
+ BufferFragment(char *buf, int size)
+ : d(buf)
+ , len(size)
{
}
@@ -184,7 +186,7 @@ private:
uint qHash(const KConfigIniBackend::BufferFragment fragment)
{
- const uchar *p = reinterpret_cast<const uchar*>(fragment.constData());
+ const uchar *p = reinterpret_cast<const uchar *>(fragment.constData());
const int len = fragment.length();
// This algorithm is copied from qhash.cpp (Qt5 version).
diff --git a/src/core/conversioncheck.h b/src/core/conversioncheck.h
index 7f0e78a4..8537d81e 100644
--- a/src/core/conversioncheck.h
+++ b/src/core/conversioncheck.h
@@ -8,11 +8,11 @@
#ifndef CONVERSION_CHECK_H
#define CONVERSION_CHECK_H
-#include <QString>
#include <QDate>
#include <QPoint>
-#include <QSize>
#include <QRect>
+#include <QSize>
+#include <QString>
#include <QVariant>
class QColor;
@@ -20,20 +20,21 @@ class QFont;
namespace ConversionCheck
{
-
// used to distinguish between supported/unsupported types
-struct supported { };
-struct unsupported { };
+struct supported {
+};
+struct unsupported {
+};
// traits type class to define support for constraints
-template <typename T>
+template<typename T>
struct QVconvertible {
typedef unsupported toQString;
typedef unsupported toQVariant;
};
// constraint classes
-template <typename T>
+template<typename T>
struct type_toQString {
void constraint()
{
@@ -43,7 +44,7 @@ struct type_toQString {
typename QVconvertible<T>::toQString y;
};
-template <typename T>
+template<typename T>
struct type_toQVariant {
void constraint()
{
@@ -55,7 +56,7 @@ struct type_toQVariant {
// check if T is convertible to QString thru QVariant
// if not supported can't be used in QList<T> functions
-template <typename T>
+template<typename T>
inline void to_QString()
{
void (type_toQString<T>::*x)() = &type_toQString<T>::constraint;
@@ -63,7 +64,7 @@ inline void to_QString()
}
// check if T is convertible to QVariant & supported in readEntry/writeEntry
-template <typename T>
+template<typename T>
inline void to_QVariant()
{
void (type_toQVariant<T>::*x)() = &type_toQVariant<T>::constraint;
@@ -74,10 +75,11 @@ inline void to_QVariant()
// string_support - is supported by QVariant(type).toString(),
// can be used in QList<T> functions
// variant_support - has a QVariant constructor
-#define QVConversions(type, string_support, variant_support) \
- template <> struct QVconvertible<type> {\
- typedef string_support toQString;\
- typedef variant_support toQVariant;\
+#define QVConversions(type, string_support, variant_support) \
+ template<> \
+ struct QVconvertible<type> { \
+ typedef string_support toQString; \
+ typedef variant_support toQVariant; \
}
// The only types needed here are the types handled in readEntry/writeEntry
@@ -108,4 +110,3 @@ QVConversions(QList<QUrl>, unsupported, supported);
}
#endif
-
diff --git a/src/core/kauthorized.cpp b/src/core/kauthorized.cpp
index 1abd83eb..a08586c5 100644
--- a/src/core/kauthorized.cpp
+++ b/src/core/kauthorized.cpp
@@ -15,41 +15,54 @@
#include <ksharedconfig.h>
#include <stdlib.h> // srand(), rand()
#ifndef Q_OS_WIN
-#include <unistd.h>
#include <netdb.h>
+#include <unistd.h>
#endif
#include <kconfiggroup.h>
-#include <QRecursiveMutex>
#include <QMutexLocker>
+#include <QRecursiveMutex>
extern bool kde_kiosk_exception;
class URLActionRule
{
public:
-#define checkExactMatch(s, b) \
- if (s.isEmpty()) b = true; \
- else if (s[s.length()-1] == QLatin1Char('!')) \
- { b = false; s.chop(1); } \
- else b = true;
-#define checkStartWildCard(s, b) \
- if (s.isEmpty()) b = true; \
- else if (s[0] == QLatin1Char('*')) \
- { b = true; s.remove(0, 1); } \
- else b = false;
-#define checkEqual(s, b) \
- b = (s == QLatin1String("="));
+#define checkExactMatch(s, b) \
+ if (s.isEmpty()) \
+ b = true; \
+ else if (s[s.length() - 1] == QLatin1Char('!')) { \
+ b = false; \
+ s.chop(1); \
+ } else \
+ b = true;
+#define checkStartWildCard(s, b) \
+ if (s.isEmpty()) \
+ b = true; \
+ else if (s[0] == QLatin1Char('*')) { \
+ b = true; \
+ s.remove(0, 1); \
+ } else \
+ b = false;
+#define checkEqual(s, b) b = (s == QLatin1String("="));
URLActionRule(const QByteArray &act,
- const QString &bProt, const QString &bHost, const QString &bPath,
- const QString &dProt, const QString &dHost, const QString &dPath,
+ const QString &bProt,
+ const QString &bHost,
+ const QString &bPath,
+ const QString &dProt,
+ const QString &dHost,
+ const QString &dPath,
bool perm)
- : action(act),
- baseProt(bProt), baseHost(bHost), basePath(bPath),
- destProt(dProt), destHost(dHost), destPath(dPath),
- permission(perm)
+ : action(act)
+ , baseProt(bProt)
+ , baseHost(bHost)
+ , basePath(bPath)
+ , destProt(dProt)
+ , destHost(dHost)
+ , destPath(dPath)
+ , permission(perm)
{
checkExactMatch(baseProt, baseProtWildCard);
checkStartWildCard(baseHost, baseHostWildCard);
@@ -64,13 +77,11 @@ public:
bool baseMatch(const QUrl &url, const QString &protClass) const
{
if (baseProtWildCard) {
- if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) &&
- (protClass.isEmpty() || (protClass != baseProt))) {
+ if (!baseProt.isEmpty() && !url.scheme().startsWith(baseProt) && (protClass.isEmpty() || (protClass != baseProt))) {
return false;
}
} else {
- if ((url.scheme() != baseProt) &&
- (protClass.isEmpty() || (protClass != baseProt))) {
+ if ((url.scheme() != baseProt) && (protClass.isEmpty() || (protClass != baseProt))) {
return false;
}
}
@@ -98,18 +109,15 @@ public:
bool destMatch(const QUrl &url, const QString &protClass, const QUrl &base, const QString &baseClass) const
{
if (destProtEqual) {
- if ((url.scheme() != base.scheme()) &&
- (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) {
+ if ((url.scheme() != base.scheme()) && (protClass.isEmpty() || baseClass.isEmpty() || protClass != baseClass)) {
return false;
}
} else if (destProtWildCard) {
- if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) &&
- (protClass.isEmpty() || (protClass != destProt))) {
+ if (!destProt.isEmpty() && !url.scheme().startsWith(destProt) && (protClass.isEmpty() || (protClass != destProt))) {
return false;
}
} else {
- if ((url.scheme() != destProt) &&
- (protClass.isEmpty() || (protClass != destProt))) {
+ if ((url.scheme() != destProt) && (protClass.isEmpty() || (protClass != destProt))) {
return false;
}
}
@@ -151,8 +159,8 @@ public:
bool destProtWildCard : 1;
bool destHostWildCard : 1;
bool destPathWildCard : 1;
- bool destProtEqual : 1;
- bool destHostEqual : 1;
+ bool destProtEqual : 1;
+ bool destHostEqual : 1;
bool permission;
};
@@ -160,7 +168,8 @@ class KAuthorizedPrivate
{
public:
KAuthorizedPrivate()
- : actionRestrictions(false), blockEverything(false)
+ : actionRestrictions(false)
+ , blockEverything(false)
{
Q_ASSERT_X(QCoreApplication::instance(), "KAuthorizedPrivate()", "There has to be an existing QCoreApplication::instance() pointer");
@@ -185,12 +194,12 @@ public:
};
Q_GLOBAL_STATIC(KAuthorizedPrivate, authPrivate)
-#define MY_D KAuthorizedPrivate *d=authPrivate();
+#define MY_D KAuthorizedPrivate *d = authPrivate();
bool KAuthorized::authorize(const QString &genericAction)
{
- MY_D
- if (d->blockEverything) {
+ MY_D if (d->blockEverything)
+ {
return false;
}
@@ -204,8 +213,8 @@ bool KAuthorized::authorize(const QString &genericAction)
bool KAuthorized::authorizeAction(const QString &action)
{
- MY_D
- if (d->blockEverything) {
+ MY_D if (d->blockEverything)
+ {
return false;
}
if (!d->actionRestrictions || action.isEmpty()) {
@@ -235,8 +244,7 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds)
{
KConfigGroup cg(KSharedConfig::openConfig(), "KDE Control Module Restrictions");
QStringList result;
- for (QStringList::ConstIterator it = menuIds.begin();
- it != menuIds.end(); ++it) {
+ for (QStringList::ConstIterator it = menuIds.begin(); it != menuIds.end(); ++it) {
if (cg.readEntry(*it, true)) {
result.append(*it);
}
@@ -247,49 +255,37 @@ QStringList KAuthorized::authorizeControlModules(const QStringList &menuIds)
// Exported for unittests (e.g. in KIO, we're missing tests for this in kconfig)
KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg)
{
- MY_D
- const QString Any;
+ MY_D const QString Any;
d->urlActionRestrictions.clear();
- d->urlActionRestrictions.append(
- URLActionRule("open", Any, Any, Any, Any, Any, Any, true));
- d->urlActionRestrictions.append(
- URLActionRule("list", Any, Any, Any, Any, Any, Any, true));
-// TEST:
-// d->urlActionRestrictions.append(
-// URLActionRule("list", Any, Any, Any, Any, Any, Any, false));
-// d->urlActionRestrictions.append(
-// URLActionRule("list", Any, Any, Any, "file", Any, QDir::homePath(), true));
- d->urlActionRestrictions.append(
- URLActionRule("link", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true));
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("open", Any, Any, Any, Any, Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("list", Any, Any, Any, Any, Any, Any, true));
+ // TEST:
+ // d->urlActionRestrictions.append(
+ // URLActionRule("list", Any, Any, Any, Any, Any, Any, false));
+ // d->urlActionRestrictions.append(
+ // URLActionRule("list", Any, Any, Any, "file", Any, QDir::homePath(), true));
+ d->urlActionRestrictions.append(URLActionRule("link", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral(":internet"), Any, Any, true));
// We allow redirections to file: but not from internet protocols, redirecting to file:
// is very popular among io-slaves and we don't want to break them
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QStringLiteral("file"), Any, Any, true));
- d->urlActionRestrictions.append(
- URLActionRule("redirect", QStringLiteral(":internet"), Any, Any, QStringLiteral("file"), Any, Any, false));
+ d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("file"), Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral(":internet"), Any, Any, QStringLiteral("file"), Any, Any, false));
// local protocols may redirect everywhere
- d->urlActionRestrictions.append(
- URLActionRule("redirect", QStringLiteral(":local"), Any, Any, Any, Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral(":local"), Any, Any, Any, Any, Any, true));
// Anyone may redirect to about:
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QStringLiteral("about"), Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("about"), Any, Any, true));
// Anyone may redirect to mailto:
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QStringLiteral("mailto"), Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("mailto"), Any, Any, true));
// Anyone may redirect to itself, cq. within it's own group
- d->urlActionRestrictions.append(
- URLActionRule("redirect", Any, Any, Any, QStringLiteral("="), Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("redirect", Any, Any, Any, QStringLiteral("="), Any, Any, true));
- d->urlActionRestrictions.append(
- URLActionRule("redirect", QStringLiteral("about"), Any, Any, Any, Any, Any, true));
+ d->urlActionRestrictions.append(URLActionRule("redirect", QStringLiteral("about"), Any, Any, Any, Any, Any, true));
int count = cg.readEntry("rule_count", 0);
QString keyFormat = QStringLiteral("rule_%1");
@@ -326,8 +322,7 @@ KCONFIGCORE_EXPORT void loadUrlActionRestrictions(const KConfigGroup &cg)
urlPath.replace(0, 4, QDir::tempPath());
}
- d->urlActionRestrictions.append(
- URLActionRule(action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
+ d->urlActionRestrictions.append(URLActionRule(action, refProt, refHost, refPath, urlProt, urlHost, urlPath, bEnabled));
}
}
@@ -339,25 +334,23 @@ namespace KAuthorized
*/
KCONFIGCORE_EXPORT void allowUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL)
{
- MY_D
- QMutexLocker locker((&d->mutex));
+ MY_D QMutexLocker locker((&d->mutex));
const QString basePath = _baseURL.adjusted(QUrl::StripTrailingSlash).path();
const QString destPath = _destURL.adjusted(QUrl::StripTrailingSlash).path();
- d->urlActionRestrictions.append(URLActionRule
- (action.toLatin1(), _baseURL.scheme(), _baseURL.host(), basePath,
- _destURL.scheme(), _destURL.host(), destPath, true));
+ d->urlActionRestrictions.append(
+ URLActionRule(action.toLatin1(), _baseURL.scheme(), _baseURL.host(), basePath, _destURL.scheme(), _destURL.host(), destPath, true));
}
/**
* Helper for KAuthorized::authorizeUrlAction in KIO
* @private
*/
-KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass)
+KCONFIGCORE_EXPORT bool
+authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass)
{
- MY_D
- QMutexLocker locker(&(d->mutex));
+ MY_D QMutexLocker locker(&(d->mutex));
if (d->blockEverything) {
return false;
}
@@ -380,9 +373,8 @@ KCONFIGCORE_EXPORT bool authorizeUrlActionInternal(const QString &action, const
for (const URLActionRule &rule : qAsConst(d->urlActionRestrictions)) {
if ((result != rule.permission) && // No need to check if it doesn't make a difference
- (action == QLatin1String(rule.action.constData())) &&
- rule.baseMatch(baseURL, baseClass) &&
- rule.destMatch(destURL, destClass, baseURL, baseClass)) {
+ (action == QLatin1String(rule.action.constData())) && rule.baseMatch(baseURL, baseClass)
+ && rule.destMatch(destURL, destClass, baseURL, baseClass)) {
result = rule.permission;
}
}
diff --git a/src/core/kauthorized.h b/src/core/kauthorized.h
index 57a99e23..ac3cfa7e 100644
--- a/src/core/kauthorized.h
+++ b/src/core/kauthorized.h
@@ -16,13 +16,13 @@ class QUrl;
class QString;
/**
-* The functions in this namespace provide the core of the Kiosk action
-* restriction system; the KIO and KXMLGui frameworks build on this.
-*
-* The relevant settings are read from the application's KSharedConfig
-* instance, so actions can be disabled on a per-application or global
-* basis (by using the kdeglobals file).
-*/
+ * The functions in this namespace provide the core of the Kiosk action
+ * restriction system; the KIO and KXMLGui frameworks build on this.
+ *
+ * The relevant settings are read from the application's KSharedConfig
+ * instance, so actions can be disabled on a per-application or global
+ * basis (by using the kdeglobals file).
+ */
namespace KAuthorized
{
/**
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index ed389ea3..2da1dd48 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -19,20 +19,19 @@
#include "kconfigbackend_p.h"
#include "kconfiggroup.h"
-#include <QCoreApplication>
-#include <QProcess>
+#include <QBasicMutex>
#include <QByteArray>
+#include <QCoreApplication>
+#include <QDir>
#include <QFile>
#include <QLocale>
-#include <QDir>
+#include <QMutexLocker>
#include <QProcess>
#include <QSet>
-#include <QBasicMutex>
-#include <QMutexLocker>
#if KCONFIG_USE_DBUS
-#include <QDBusMessage>
#include <QDBusConnection>
+#include <QDBusMessage>
#include <QDBusMetaType>
#endif
@@ -51,12 +50,17 @@ static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseSensitive;
static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseInsensitive;
#endif
-KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
- QStandardPaths::StandardLocation resourceType)
- : openFlags(flags), resourceType(resourceType), mBackend(nullptr),
- bDynamicBackend(true), bDirty(false), bReadDefaults(false),
- bFileImmutable(false), bForceGlobal(false), bSuppressGlobal(false),
- configState(KConfigBase::NoAccess)
+KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags, QStandardPaths::StandardLocation resourceType)
+ : openFlags(flags)
+ , resourceType(resourceType)
+ , mBackend(nullptr)
+ , bDynamicBackend(true)
+ , bDirty(false)
+ , bReadDefaults(false)
+ , bFileImmutable(false)
+ , bForceGlobal(false)
+ , bSuppressGlobal(false)
+ , configState(KConfigBase::NoAccess)
{
const bool isTestMode = QStandardPaths::isTestModeEnabled();
// If sGlobalFileName was initialised and testMode has been toggled,
@@ -68,7 +72,7 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1);
if (use_etc_kderc.loadRelaxed() < 0) {
- use_etc_kderc.storeRelaxed( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests
+ use_etc_kderc.storeRelaxed(!qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests
}
if (use_etc_kderc.loadRelaxed()) {
etc_kderc =
@@ -83,20 +87,20 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
}
}
-// if (!mappingsRegistered) {
-// KEntryMap tmp;
-// if (!etc_kderc.isEmpty()) {
-// QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(etc_kderc, QLatin1String("INI"));
-// backend->parseConfig( "en_US", tmp, KConfigBackend::ParseDefaults);
-// }
-// const QString kde5rc(QDir::home().filePath(".kde5rc"));
-// if (KStandardDirs::checkAccess(kde5rc, R_OK)) {
-// QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(kde5rc, QLatin1String("INI"));
-// backend->parseConfig( "en_US", tmp, KConfigBackend::ParseOptions());
-// }
-// KConfigBackend::registerMappings(tmp);
-// mappingsRegistered = true;
-// }
+ // if (!mappingsRegistered) {
+ // KEntryMap tmp;
+ // if (!etc_kderc.isEmpty()) {
+ // QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(etc_kderc, QLatin1String("INI"));
+ // backend->parseConfig( "en_US", tmp, KConfigBackend::ParseDefaults);
+ // }
+ // const QString kde5rc(QDir::home().filePath(".kde5rc"));
+ // if (KStandardDirs::checkAccess(kde5rc, R_OK)) {
+ // QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(kde5rc, QLatin1String("INI"));
+ // backend->parseConfig( "en_US", tmp, KConfigBackend::ParseOptions());
+ // }
+ // KConfigBackend::registerMappings(tmp);
+ // mappingsRegistered = true;
+ // }
setLocale(QLocale().name());
}
@@ -110,8 +114,7 @@ bool KConfigPrivate::lockLocal()
return true;
}
-void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &destination,
- KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const
+void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &destination, KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const
{
KEntryMap &otherMap = otherGroup->config()->d_ptr->entryMap;
const int len = source.length();
@@ -144,7 +147,7 @@ void KConfigPrivate::copyGroup(const QByteArray &source, const QByteArray &desti
newKey.mGroup.replace(0, len, destination);
}
- KEntry entry = entryMap[ entryMapIt.key() ];
+ KEntry entry = entryMap[entryMapIt.key()];
dirtied = entry.bDirty = flags & KConfigBase::Persistent;
if (flags & KConfigBase::Global) {
@@ -182,10 +185,7 @@ QString KConfigPrivate::expandString(const QString &value)
++nEndPos;
aVarName = aValue.midRef(nDollarPos + 2, nEndPos - nDollarPos - 3);
} else {
- while (nEndPos < aValue.length() &&
- (aValue[nEndPos].isNumber() ||
- aValue[nEndPos].isLetter() ||
- aValue[nEndPos] == QLatin1Char('_'))) {
+ while (nEndPos < aValue.length() && (aValue[nEndPos].isNumber() || aValue[nEndPos].isLetter() || aValue[nEndPos] == QLatin1Char('_'))) {
++nEndPos;
}
aVarName = aValue.midRef(nDollarPos + 1, nEndPos - nDollarPos - 1);
@@ -227,8 +227,7 @@ QString KConfigPrivate::expandString(const QString &value)
return aValue;
}
-KConfig::KConfig(const QString &file, OpenFlags mode,
- QStandardPaths::StandardLocation resourceType)
+KConfig::KConfig(const QString &file, OpenFlags mode, QStandardPaths::StandardLocation resourceType)
: d_ptr(new KConfigPrivate(mode, resourceType))
{
d_ptr->changeFileName(file); // set the local file name
@@ -298,7 +297,7 @@ QStringList KConfigPrivate::groupList(const QByteArray &group) const
static bool isGroupOrSubGroupMatch(const QByteArray &potentialGroup, const QByteArray &group)
{
if (!potentialGroup.startsWith(group)) {
- return false;
+ return false;
}
return potentialGroup.length() == group.length() || potentialGroup[group.length()] == '\x1d';
}
@@ -441,7 +440,7 @@ bool KConfig::sync()
if (d->configState == ReadWrite && !tmp->lock()) {
qCWarning(KCONFIG_CORE_LOG) << "couldn't lock global file";
- //unlock the local config if we're returning early
+ // unlock the local config if we're returning early
if (d->mBackend->isLocked()) {
d->mBackend->unlock();
}
@@ -484,9 +483,7 @@ void KConfigPrivate::notifyClients(const QHash<QString, QByteArrayList> &changes
qDBusRegisterMetaType<QHash<QString, QByteArrayList>>();
- QDBusMessage message = QDBusMessage::createSignal(path,
- QStringLiteral("org.kde.kconfig.notify"),
- QStringLiteral("ConfigChanged"));
+ QDBusMessage message = QDBusMessage::createSignal(path, QStringLiteral("org.kde.kconfig.notify"), QStringLiteral("ConfigChanged"));
message.setArguments({QVariant::fromValue(changes)});
QDBusConnection::sessionBus().send(message);
#else
@@ -520,7 +517,7 @@ void KConfig::checkUpdate(const QString &id, const QString &updateFile)
const QString cfg_id = updateFile + QLatin1Char(':') + id;
const QStringList ids = cg.readEntry("update_info", QStringList());
if (!ids.contains(cfg_id)) {
- QProcess::execute(QStringLiteral(KCONF_UPDATE_INSTALL_LOCATION), QStringList { QStringLiteral("--check"), updateFile });
+ QProcess::execute(QStringLiteral(KCONF_UPDATE_INSTALL_LOCATION), QStringList{QStringLiteral("--check"), updateFile});
reparseConfiguration();
}
}
@@ -550,15 +547,13 @@ QString KConfig::name() const
return d->fileName;
}
-
KConfig::OpenFlags KConfig::openFlags() const
{
Q_D(const KConfig);
return d->openFlags;
}
-struct KConfigStaticData
-{
+struct KConfigStaticData {
QString globalMainConfigName;
// Keep a copy so we can use it in global dtors, after qApp is gone
QStringList appArgs;
@@ -572,7 +567,7 @@ void KConfig::setMainConfigName(const QString &str)
QString KConfig::mainConfigName()
{
- KConfigStaticData* data = globalData();
+ KConfigStaticData *data = globalData();
if (data->appArgs.isEmpty())
data->appArgs = QCoreApplication::arguments();
@@ -690,7 +685,7 @@ QStringList KConfigPrivate::getGlobalFiles() const
void KConfigPrivate::parseGlobalFiles()
{
const QStringList globalFiles = getGlobalFiles();
-// qDebug() << "parsing global files" << globalFiles;
+ // qDebug() << "parsing global files" << globalFiles;
// TODO: can we cache the values in etc_kderc / other global files
// on a per-application basis?
@@ -712,7 +707,6 @@ void KConfigPrivate::parseConfigFiles()
{
// can only read the file if there is a backend and a file name
if (mBackend && !fileName.isEmpty()) {
-
bFileImmutable = false;
QList<QString> files;
@@ -745,7 +739,7 @@ void KConfigPrivate::parseConfigFiles()
files = QList<QString>(extraFiles.cbegin(), extraFiles.cend()) + files;
}
-// qDebug() << "parsing local files" << files;
+ // qDebug() << "parsing local files" << files;
const QByteArray utf8Locale = locale.toUtf8();
for (const QString &file : qAsConst(files)) {
@@ -762,8 +756,7 @@ void KConfigPrivate::parseConfigFiles()
}
} else {
QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(file);
- bFileImmutable = (backend->parseConfig(utf8Locale, entryMap,
- KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions)
+ bFileImmutable = (backend->parseConfig(utf8Locale, entryMap, KConfigBackend::ParseDefaults | KConfigBackend::ParseExpansions)
== KConfigBackend::ParseImmutable);
}
@@ -844,7 +837,7 @@ bool KConfig::isImmutable() const
bool KConfig::isGroupImmutableImpl(const QByteArray &aGroup) const
{
Q_D(const KConfig);
- return isImmutable() || d->entryMap.getEntryOption(aGroup, {},{}, KEntryMap::EntryImmutable);
+ return isImmutable() || d->entryMap.getEntryOption(aGroup, {}, {}, KEntryMap::EntryImmutable);
}
#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(4, 0)
@@ -925,13 +918,12 @@ bool KConfig::isConfigWritable(bool warnUser)
errorMsg += QCoreApplication::translate("KConfig", "Please contact your system administrator.");
QString cmdToExec = QStandardPaths::findExecutable(QStringLiteral("kdialog"));
if (!cmdToExec.isEmpty()) {
- QProcess::execute(cmdToExec, QStringList()
- << QStringLiteral("--title") << QCoreApplication::applicationName()
- << QStringLiteral("--msgbox") << errorMsg);
+ QProcess::execute(cmdToExec,
+ QStringList() << QStringLiteral("--title") << QCoreApplication::applicationName() << QStringLiteral("--msgbox") << errorMsg);
}
}
- d->configState = allWritable ? ReadWrite : ReadOnly; // update the read/write status
+ d->configState = allWritable ? ReadWrite : ReadOnly; // update the read/write status
return allWritable;
}
@@ -948,15 +940,13 @@ bool KConfig::hasGroupImpl(const QByteArray &aGroup) const
bool KConfigPrivate::canWriteEntry(const QByteArray &group, const char *key, bool isDefault) const
{
- if (bFileImmutable ||
- entryMap.getEntryOption(group, key, KEntryMap::SearchLocalized, KEntryMap::EntryImmutable)) {
+ if (bFileImmutable || entryMap.getEntryOption(group, key, KEntryMap::SearchLocalized, KEntryMap::EntryImmutable)) {
return isDefault;
}
return true;
}
-void KConfigPrivate::putData(const QByteArray &group, const char *key,
- const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand)
+void KConfigPrivate::putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand)
{
KEntryMap::EntryOptions options = convertToOptions(flags);
@@ -987,8 +977,7 @@ void KConfigPrivate::revertEntry(const QByteArray &group, const char *key, KConf
}
}
-QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key,
- KEntryMap::SearchFlags flags) const
+QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const
{
if (bReadDefaults) {
flags |= KEntryMap::SearchDefaults;
@@ -1000,8 +989,7 @@ QByteArray KConfigPrivate::lookupData(const QByteArray &group, const char *key,
return it->mValue;
}
-QString KConfigPrivate::lookupData(const QByteArray &group, const char *key,
- KEntryMap::SearchFlags flags, bool *expand) const
+QString KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const
{
if (bReadDefaults) {
flags |= KEntryMap::SearchDefaults;
diff --git a/src/core/kconfig.h b/src/core/kconfig.h
index 4b652059..792a9a6b 100644
--- a/src/core/kconfig.h
+++ b/src/core/kconfig.h
@@ -15,11 +15,11 @@
#include <kconfigcore_export.h>
-#include <QString>
-#include <QVariant>
#include <QByteArray>
#include <QList>
#include <QStandardPaths>
+#include <QString>
+#include <QVariant>
class KConfigGroup;
class KEntryMap;
@@ -80,13 +80,13 @@ public:
* @see OpenFlags
*/
enum OpenFlag {
- IncludeGlobals = 0x01, ///< Blend kdeglobals into the config object.
- CascadeConfig = 0x02, ///< Cascade to system-wide config files.
+ IncludeGlobals = 0x01, ///< Blend kdeglobals into the config object.
+ CascadeConfig = 0x02, ///< Cascade to system-wide config files.
- SimpleConfig = 0x00, ///< Just a single config file.
- NoCascade = IncludeGlobals, ///< Include user's globals, but omit system settings.
- NoGlobals = CascadeConfig, ///< Cascade to system settings, but omit user's globals.
- FullConfig = IncludeGlobals | CascadeConfig, ///< Fully-fledged config, including globals and cascading to system settings
+ SimpleConfig = 0x00, ///< Just a single config file.
+ NoCascade = IncludeGlobals, ///< Include user's globals, but omit system settings.
+ NoGlobals = CascadeConfig, ///< Cascade to system settings, but omit user's globals.
+ FullConfig = IncludeGlobals | CascadeConfig, ///< Fully-fledged config, including globals and cascading to system settings
};
/**
* Stores a combination of #OpenFlag values.
@@ -121,7 +121,8 @@ public:
*
* @sa KSharedConfig::openConfig(const QString&, OpenFlags, QStandardPaths::StandardLocation)
*/
- explicit KConfig(const QString &file = QString(), OpenFlags mode = FullConfig,
+ explicit KConfig(const QString &file = QString(),
+ OpenFlags mode = FullConfig,
QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
/**
diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h
index 917872f3..b201df17 100644
--- a/src/core/kconfig_p.h
+++ b/src/core/kconfig_p.h
@@ -11,18 +11,19 @@
#ifndef KCONFIG_P_H
#define KCONFIG_P_H
-#include "kconfigdata.h"
#include "kconfigbackend_p.h"
+#include "kconfigdata.h"
#include "kconfiggroup.h"
-#include <QStringList>
-#include <QStack>
-#include <QFile>
#include <QDir>
+#include <QFile>
+#include <QStack>
+#include <QStringList>
class KConfigPrivate
{
friend class KConfig;
+
public:
KConfig::OpenFlags openFlags;
QStandardPaths::StandardLocation resourceType;
@@ -31,19 +32,15 @@ public:
// functions for KConfigGroup
bool canWriteEntry(const QByteArray &group, const char *key, bool isDefault = false) const;
- QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags,
- bool *expand) const;
+ QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const;
QByteArray lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const;
- void putData(const QByteArray &group, const char *key, const QByteArray &value,
- KConfigBase::WriteConfigFlags flags, bool expand = false);
- void revertEntry(const QByteArray &group, const char *key,
- KConfigBase::WriteConfigFlags flags);
+ void putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand = false);
+ void revertEntry(const QByteArray &group, const char *key, KConfigBase::WriteConfigFlags flags);
QStringList groupList(const QByteArray &group) const;
// copies the entries from @p source to @p otherGroup changing all occurrences
// of @p source with @p destination
- void copyGroup(const QByteArray &source, const QByteArray &destination,
- KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const;
+ void copyGroup(const QByteArray &source, const QByteArray &destination, KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const;
QStringList keyListImpl(const QByteArray &theGroup) const;
QSet<QByteArray> allSubGroups(const QByteArray &parentGroup) const;
bool hasNonDeletedEntries(const QByteArray &group) const;
@@ -55,20 +52,19 @@ public:
protected:
QExplicitlySharedDataPointer<KConfigBackend> mBackend;
- KConfigPrivate(KConfig::OpenFlags flags,
- QStandardPaths::StandardLocation type);
+ KConfigPrivate(KConfig::OpenFlags flags, QStandardPaths::StandardLocation type);
virtual ~KConfigPrivate()
{
}
- bool bDynamicBackend: 1; // do we own the backend?
+ bool bDynamicBackend : 1; // do we own the backend?
private:
- bool bDirty: 1;
- bool bReadDefaults: 1;
- bool bFileImmutable: 1;
- bool bForceGlobal: 1;
- bool bSuppressGlobal: 1;
+ bool bDirty : 1;
+ bool bReadDefaults : 1;
+ bool bFileImmutable : 1;
+ bool bForceGlobal : 1;
+ bool bSuppressGlobal : 1;
static bool mappingsRegistered;
diff --git a/src/core/kconfigbackend.cpp b/src/core/kconfigbackend.cpp
index 0f95a5f6..13455dbd 100644
--- a/src/core/kconfigbackend.cpp
+++ b/src/core/kconfigbackend.cpp
@@ -10,14 +10,14 @@
#include "kconfigbackend_p.h"
#include <QDateTime>
-#include <QStringList>
+#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QHash>
-#include <QDebug>
+#include <QStringList>
-#include "kconfigini_p.h"
#include "kconfigdata.h"
+#include "kconfigini_p.h"
typedef QExplicitlySharedDataPointer<KConfigBackend> BackendPtr;
@@ -38,7 +38,7 @@ void KConfigBackend::registerMappings(const KEntryMap & /*entryMap*/)
BackendPtr KConfigBackend::create(const QString &file, const QString &sys)
{
- //qDebug() << "creating a backend for file" << file << "with system" << sys;
+ // qDebug() << "creating a backend for file" << file << "with system" << sys;
KConfigBackend *backend = nullptr;
#if 0 // TODO port to Qt5 plugin loading
@@ -61,7 +61,7 @@ BackendPtr KConfigBackend::create(const QString &file, const QString &sys)
Q_UNUSED(sys);
#endif
- //qDebug() << "default creation of the Ini backend";
+ // qDebug() << "default creation of the Ini backend";
backend = new KConfigIniBackend;
backend->setFilePath(file);
return BackendPtr(backend);
diff --git a/src/core/kconfigbackend_p.h b/src/core/kconfigbackend_p.h
index 7eb1774e..5b38634f 100644
--- a/src/core/kconfigbackend_p.h
+++ b/src/core/kconfigbackend_p.h
@@ -10,12 +10,12 @@
#ifndef KCONFIGBACKEND_H
#define KCONFIGBACKEND_H
+#include <QExplicitlySharedDataPointer>
#include <QObject>
#include <QString>
-#include <QExplicitlySharedDataPointer>
-#include <kconfigcore_export.h>
#include <kconfigbase.h>
+#include <kconfigcore_export.h>
class KConfigBackendPrivate;
class KEntryMap;
@@ -48,8 +48,7 @@ public:
* @param system the configuration system to use
* @return a KConfigBackend object to be used with KConfig
*/
- static QExplicitlySharedDataPointer<KConfigBackend> create(const QString &fileName = QString(),
- const QString &system = QString());
+ static QExplicitlySharedDataPointer<KConfigBackend> create(const QString &fileName = QString(), const QString &system = QString());
/**
* Registers mappings from directories/files to configuration systems
@@ -99,9 +98,7 @@ public:
* @param options See ParseOptions
* @return See ParseInfo
*/
- virtual ParseInfo parseConfig(const QByteArray &locale,
- KEntryMap &pWriteBackMap,
- ParseOptions options = ParseOptions()) = 0;
+ virtual ParseInfo parseConfig(const QByteArray &locale, KEntryMap &pWriteBackMap, ParseOptions options = ParseOptions()) = 0;
/**
* Write the @em dirty entries to permanent storage
@@ -112,8 +109,7 @@ public:
*
* @return @c true if the write was successful, @c false if writing the configuration failed
*/
- virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap,
- WriteOptions options) = 0;
+ virtual bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) = 0;
/**
* If isWritable() returns false, writeConfig() will always fail.
@@ -185,8 +181,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(KConfigBackend::WriteOptions)
/**
* Register a KConfig backend when it is contained in a loadable module
*/
-#define K_EXPORT_KCONFIGBACKEND(libname, classname) \
- K_PLUGIN_FACTORY(factory, registerPlugin<classname>();)
+#define K_EXPORT_KCONFIGBACKEND(libname, classname) K_PLUGIN_FACTORY(factory, registerPlugin<classname>();)
#endif
#endif // KCONFIGBACKEND_H
diff --git a/src/core/kconfigbase.cpp b/src/core/kconfigbase.cpp
index 6bae0e25..9eee6420 100644
--- a/src/core/kconfigbase.cpp
+++ b/src/core/kconfigbase.cpp
@@ -89,10 +89,13 @@ bool KConfigBase::isGroupImmutable(const char *aGroup) const
}
KConfigBase::~KConfigBase()
-{}
+{
+}
KConfigBase::KConfigBase()
-{}
+{
+}
void KConfigBase::virtual_hook(int, void *)
-{}
+{
+}
diff --git a/src/core/kconfigbase.h b/src/core/kconfigbase.h
index a7693275..79af8854 100644
--- a/src/core/kconfigbase.h
+++ b/src/core/kconfigbase.h
@@ -56,9 +56,9 @@ public:
*/
Normal = Persistent,
/**<
- * Save the entry to the application specific config file without
- * a locale tag. This is the default.
- */
+ * Save the entry to the application specific config file without
+ * a locale tag. This is the default.
+ */
};
/**
diff --git a/src/core/kconfigdata.cpp b/src/core/kconfigdata.cpp
index 5ead8167..accf869b 100644
--- a/src/core/kconfigdata.cpp
+++ b/src/core/kconfigdata.cpp
@@ -11,28 +11,26 @@
QDebug operator<<(QDebug dbg, const KEntryKey &key)
{
- dbg.nospace() << "[" << key.mGroup << ", " << key.mKey << (key.bLocal ? " localized" : "") <<
- (key.bDefault ? " default" : "") << (key.bRaw ? " raw" : "") << "]";
+ dbg.nospace() << "[" << key.mGroup << ", " << key.mKey << (key.bLocal ? " localized" : "") << (key.bDefault ? " default" : "") << (key.bRaw ? " raw" : "")
+ << "]";
return dbg.space();
}
QDebug operator<<(QDebug dbg, const KEntry &entry)
{
- dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") <<
- (entry.bGlobal ? " global" : "") << (entry.bImmutable ? " immutable" : "") <<
- (entry.bDeleted ? " deleted" : "") << (entry.bReverted ? " reverted" : "") <<
- (entry.bExpand ? " expand" : "") << "]";
+ dbg.nospace() << "[" << entry.mValue << (entry.bDirty ? " dirty" : "") << (entry.bGlobal ? " global" : "") << (entry.bImmutable ? " immutable" : "")
+ << (entry.bDeleted ? " deleted" : "") << (entry.bReverted ? " reverted" : "") << (entry.bExpand ? " expand" : "") << "]";
return dbg.space();
}
-QMap< KEntryKey, KEntry >::Iterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags)
+QMap<KEntryKey, KEntry>::Iterator KEntryMap::findExactEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags)
{
KEntryKey theKey(group, key, bool(flags & SearchLocalized), bool(flags & SearchDefaults));
return find(theKey);
}
-QMap< KEntryKey, KEntry >::Iterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags)
+QMap<KEntryKey, KEntry>::Iterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags)
{
KEntryKey theKey(group, key, false, bool(flags & SearchDefaults));
@@ -50,7 +48,7 @@ QMap< KEntryKey, KEntry >::Iterator KEntryMap::findEntry(const QByteArray &group
return find(theKey);
}
-QMap< KEntryKey, KEntry >::ConstIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const
+QMap<KEntryKey, KEntry>::ConstIterator KEntryMap::findEntry(const QByteArray &group, const QByteArray &key, KEntryMap::SearchFlags flags) const
{
KEntryKey theKey(group, key, false, bool(flags & SearchDefaults));
@@ -95,11 +93,11 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
if (it != end()) {
if (it->bImmutable) {
- return false; // we cannot change this entry. Inherits group immutability.
+ return false; // we cannot change this entry. Inherits group immutability.
}
k = it.key();
e = *it;
- //qDebug() << "found existing entry for key" << k;
+ // qDebug() << "found existing entry for key" << k;
// If overridden entry is global and not default. And it's overridden by a non global
if (e.bGlobal && !(options & EntryGlobal) && !k.bDefault) {
e.bOverridesGlobal = true;
@@ -111,7 +109,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
if (cit == constEnd()) {
insert(KEntryKey(group), KEntry());
} else if (cit->bImmutable) {
- return false; // this group is immutable, so we cannot change this entry.
+ return false; // this group is immutable, so we cannot change this entry.
}
k = KEntryKey(group, key);
@@ -127,14 +125,14 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
e.bDirty = e.bDirty || (options & EntryDirty);
e.bNotify = e.bNotify || (options & EntryNotify);
- e.bGlobal = (options & EntryGlobal); //we can't use || here, because changes to entries in
- //kdeglobals would be written to kdeglobals instead
- //of the local config file, regardless of the globals flag
+ e.bGlobal = (options & EntryGlobal); // we can't use || here, because changes to entries in
+ // kdeglobals would be written to kdeglobals instead
+ // of the local config file, regardless of the globals flag
e.bImmutable = e.bImmutable || (options & EntryImmutable);
if (value.isNull()) {
e.bDeleted = e.bDeleted || (options & EntryDeleted);
} else {
- e.bDeleted = false; // setting a value to a previously deleted entry
+ e.bDeleted = false; // setting a value to a previously deleted entry
}
e.bExpand = (options & EntryExpansion);
e.bReverted = false;
@@ -145,17 +143,17 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
}
if (newKey) {
- //qDebug() << "inserting" << k << "=" << value;
+ // qDebug() << "inserting" << k << "=" << value;
insert(k, e);
if (k.bDefault) {
k.bDefault = false;
- //qDebug() << "also inserting" << k << "=" << value;
+ // qDebug() << "also inserting" << k << "=" << value;
insert(k, e);
}
// TODO check for presence of unlocalized key
return true;
} else {
-// KEntry e2 = it.value();
+ // KEntry e2 = it.value();
if (options & EntryLocalized) {
// fast exit checks for cases where the existing entry is more specific
const KEntry &e2 = it.value();
@@ -165,7 +163,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
}
}
if (it.value() != e) {
- //qDebug() << "changing" << k << "from" << e.mValue << "to" << value;
+ // qDebug() << "changing" << k << "from" << e.mValue << "to" << value;
it.value() = e;
if (k.bDefault) {
KEntryKey nonDefaultKey(k);
@@ -174,7 +172,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
}
if (!(options & EntryLocalized)) {
KEntryKey theKey(group, key, true, false);
- //qDebug() << "non-localized entry, remove localized one:" << theKey;
+ // qDebug() << "non-localized entry, remove localized one:" << theKey;
remove(theKey);
if (k.bDefault) {
theKey.bDefault = true;
@@ -183,9 +181,9 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
}
return true;
} else {
- //qDebug() << k << "was already set to" << e.mValue;
+ // qDebug() << k << "was already set to" << e.mValue;
if (!(options & EntryLocalized)) {
- //qDebug() << "unchanged non-localized entry, remove localized one.";
+ // qDebug() << "unchanged non-localized entry, remove localized one.";
KEntryKey theKey(group, key, true, false);
bool ret = false;
Iterator cit = find(theKey);
@@ -203,7 +201,7 @@ bool KEntryMap::setEntry(const QByteArray &group, const QByteArray &key, const Q
}
return ret;
}
- //qDebug() << "localized entry, unchanged, return false";
+ // qDebug() << "localized entry, unchanged, return false";
// When we are writing a default, we know that the non-
// default is the same as the default, so we can simply
// use the same branch.
@@ -246,7 +244,7 @@ bool KEntryMap::hasEntry(const QByteArray &group, const QByteArray &key, KEntryM
return true;
}
-bool KEntryMap::getEntryOption(const QMap< KEntryKey, KEntry >::ConstIterator &it, KEntryMap::EntryOption option) const
+bool KEntryMap::getEntryOption(const QMap<KEntryKey, KEntry>::ConstIterator &it, KEntryMap::EntryOption option) const
{
if (it != constEnd()) {
switch (option) {
@@ -272,7 +270,7 @@ bool KEntryMap::getEntryOption(const QMap< KEntryKey, KEntry >::ConstIterator &i
return false;
}
-void KEntryMap::setEntryOption(QMap< KEntryKey, KEntry >::Iterator it, KEntryMap::EntryOption option, bool bf)
+void KEntryMap::setEntryOption(QMap<KEntryKey, KEntry>::Iterator it, KEntryMap::EntryOption option, bool bf)
{
if (it != end()) {
switch (option) {
@@ -305,18 +303,18 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt
Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0);
Iterator entry = findEntry(group, key, flags);
if (entry != end()) {
- //qDebug() << "reverting" << entry.key() << " = " << entry->mValue;
+ // qDebug() << "reverting" << entry.key() << " = " << entry->mValue;
if (entry->bReverted) { // already done before
return false;
}
KEntryKey defaultKey(entry.key());
defaultKey.bDefault = true;
- //qDebug() << "looking up default entry with key=" << defaultKey;
+ // qDebug() << "looking up default entry with key=" << defaultKey;
const ConstIterator defaultEntry = constFind(defaultKey);
if (defaultEntry != constEnd()) {
Q_ASSERT(defaultEntry.key().bDefault);
- //qDebug() << "found, update entry";
+ // qDebug() << "found, update entry";
*entry = *defaultEntry; // copy default value, for subsequent lookups
} else {
entry->mValue = QByteArray();
@@ -325,7 +323,7 @@ bool KEntryMap::revertEntry(const QByteArray &group, const QByteArray &key, KEnt
entry->bDirty = true;
entry->bReverted = true; // skip it when writing out to disk
- //qDebug() << "Here's what we have now:" << *this;
+ // qDebug() << "Here's what we have now:" << *this;
return true;
}
return false;
diff --git a/src/core/kconfigdata.h b/src/core/kconfigdata.h
index 36d90335..bb9ee717 100644
--- a/src/core/kconfigdata.h
+++ b/src/core/kconfigdata.h
@@ -11,9 +11,9 @@
#define KCONFIGDATA_H
#include <QByteArray>
-#include <QString>
-#include <QMap>
#include <QDebug>
+#include <QMap>
+#include <QString>
/**
* map/dict/list config node entry.
@@ -22,60 +22,67 @@
struct KEntry {
/** Constructor. @internal */
KEntry()
- : mValue(), bDirty(false),
- bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false), bReverted(false),
- bLocalizedCountry(false), bNotify(false), bOverridesGlobal(false) {}
+ : mValue()
+ , bDirty(false)
+ , bGlobal(false)
+ , bImmutable(false)
+ , bDeleted(false)
+ , bExpand(false)
+ , bReverted(false)
+ , bLocalizedCountry(false)
+ , bNotify(false)
+ , bOverridesGlobal(false)
+ {
+ }
/** @internal */
QByteArray mValue;
/**
* Must the entry be written back to disk?
*/
- bool bDirty : 1;
+ bool bDirty : 1;
/**
* Entry should be written to the global config file
*/
- bool bGlobal: 1;
+ bool bGlobal : 1;
/**
* Entry can not be modified.
*/
- bool bImmutable: 1;
+ bool bImmutable : 1;
/**
* Entry has been deleted.
*/
- bool bDeleted: 1;
+ bool bDeleted : 1;
/**
* Whether to apply dollar expansion or not.
*/
- bool bExpand: 1;
+ bool bExpand : 1;
/**
* Entry has been reverted to its default value (from a more global file).
*/
- bool bReverted: 1;
+ bool bReverted : 1;
/**
* Entry is for a localized key. If @c false the value references just language e.g. "de",
* if @c true the value references language and country, e.g. "de_DE".
**/
- bool bLocalizedCountry: 1;
+ bool bLocalizedCountry : 1;
- bool bNotify: 1;
+ bool bNotify : 1;
/**
* Entry will need to be written on a non global file even if it matches default value
*/
- bool bOverridesGlobal: 1;
+ bool bOverridesGlobal : 1;
};
// These operators are used to check whether an entry which is about
// to be written equals the previous value. As such, this intentionally
// omits the dirty/notify flag from the comparison.
-inline bool operator ==(const KEntry &k1, const KEntry &k2)
+inline bool operator==(const KEntry &k1, const KEntry &k2)
{
- return k1.bGlobal == k2.bGlobal && k1.bImmutable == k2.bImmutable
- && k1.bDeleted == k2.bDeleted && k1.bExpand == k2.bExpand
- && k1.mValue == k2.mValue;
+ return k1.bGlobal == k2.bGlobal && k1.bImmutable == k2.bImmutable && k1.bDeleted == k2.bDeleted && k1.bExpand == k2.bExpand && k1.mValue == k2.mValue;
}
-inline bool operator !=(const KEntry &k1, const KEntry &k2)
+inline bool operator!=(const KEntry &k1, const KEntry &k2)
{
return !(k1 == k2);
}
@@ -87,9 +94,12 @@ inline bool operator !=(const KEntry &k1, const KEntry &k2)
*/
struct KEntryKey {
/** Constructor. @internal */
- KEntryKey(const QByteArray &_group = QByteArray(),
- const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false)
- : mGroup(_group), mKey(_key), bLocal(isLocalized), bDefault(isDefault), bRaw(false)
+ KEntryKey(const QByteArray &_group = QByteArray(), const QByteArray &_key = QByteArray(), bool isLocalized = false, bool isDefault = false)
+ : mGroup(_group)
+ , mKey(_key)
+ , bLocal(isLocalized)
+ , bDefault(isDefault)
+ , bRaw(false)
{
;
}
@@ -104,16 +114,16 @@ struct KEntryKey {
/**
* Entry is localised or not
*/
- bool bLocal : 1;
+ bool bLocal : 1;
/**
* Entry indicates if this is a default value.
*/
- bool bDefault: 1;
+ bool bDefault : 1;
/** @internal
* Key is a raw unprocessed key.
* @warning this should only be set during merging, never for normal use.
*/
- bool bRaw: 1;
+ bool bRaw : 1;
};
/**
@@ -121,7 +131,7 @@ struct KEntryKey {
* non-localized, non-localized-default
* @internal
*/
-inline bool operator <(const KEntryKey &k1, const KEntryKey &k2)
+inline bool operator<(const KEntryKey &k1, const KEntryKey &k2)
{
int result = qstrcmp(k1.mGroup, k2.mGroup);
if (result != 0) {
@@ -172,45 +182,38 @@ public:
};
Q_DECLARE_FLAGS(EntryOptions, EntryOption)
- Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(),
- SearchFlags flags = SearchFlags());
+ Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags());
- Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(),
- SearchFlags flags = SearchFlags());
+ Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags());
- ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(),
- SearchFlags flags = SearchFlags()) const;
+ ConstIterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const;
/**
* Returns true if the entry gets dirtied or false in other case
*/
- bool setEntry(const QByteArray &group, const QByteArray &key,
- const QByteArray &value, EntryOptions options);
+ bool setEntry(const QByteArray &group, const QByteArray &key, const QByteArray &value, EntryOptions options);
- void setEntry(const QByteArray &group, const QByteArray &key,
- const QString &value, EntryOptions options)
+ void setEntry(const QByteArray &group, const QByteArray &key, const QString &value, EntryOptions options)
{
setEntry(group, key, value.toUtf8(), options);
}
- QString getEntry(const QByteArray &group, const QByteArray &key,
+ QString getEntry(const QByteArray &group,
+ const QByteArray &key,
const QString &defaultValue = QString(),
SearchFlags flags = SearchFlags(),
bool *expand = nullptr) const;
- bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(),
- SearchFlags flags = SearchFlags()) const;
+ bool hasEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()) const;
bool getEntryOption(const ConstIterator &it, EntryOption option) const;
- bool getEntryOption(const QByteArray &group, const QByteArray &key,
- SearchFlags flags, EntryOption option) const
+ bool getEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option) const
{
return getEntryOption(findEntry(group, key, flags), option);
}
void setEntryOption(Iterator it, EntryOption option, bool bf);
- void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags,
- EntryOption option, bool bf)
+ void setEntryOption(const QByteArray &group, const QByteArray &key, SearchFlags flags, EntryOption option, bool bf)
{
setEntryOption(findEntry(group, key, flags), option, bf);
}
diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp
index d900458f..8fcfafe7 100644
--- a/src/core/kconfiggroup.cpp
+++ b/src/core/kconfiggroup.cpp
@@ -11,41 +11,50 @@
#include "kconfiggroup_p.h"
#include "kconfig.h"
-#include "kconfig_p.h"
#include "kconfig_core_log_settings.h"
-#include "ksharedconfig.h"
+#include "kconfig_p.h"
#include "kconfigdata.h"
+#include "ksharedconfig.h"
#include <QDate>
-#include <QSharedData>
+#include <QDir>
#include <QFile>
#include <QPoint>
#include <QRect>
+#include <QSharedData>
#include <QString>
#include <QTextStream>
-#include <QDir>
#include <QUrl>
-#include <stdlib.h>
#include <math.h>
+#include <stdlib.h>
class KConfigGroupPrivate : public QSharedData
{
public:
KConfigGroupPrivate(KConfig *owner, bool isImmutable, bool isConst, const QByteArray &name)
- : mOwner(owner), mName(name), bImmutable(isImmutable), bConst(isConst)
+ : mOwner(owner)
+ , mName(name)
+ , bImmutable(isImmutable)
+ , bConst(isConst)
{
}
KConfigGroupPrivate(const KSharedConfigPtr &owner, const QByteArray &name)
- : sOwner(owner), mOwner(sOwner.data()), mName(name),
- bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name)), bConst(false)
+ : sOwner(owner)
+ , mOwner(sOwner.data())
+ , mName(name)
+ , bImmutable(name.isEmpty() ? owner->isImmutable() : owner->isGroupImmutable(name))
+ , bConst(false)
{
}
KConfigGroupPrivate(KConfigGroup *parent, bool isImmutable, bool isConst, const QByteArray &name)
- : sOwner(parent->d->sOwner), mOwner(parent->d->mOwner), mName(name),
- bImmutable(isImmutable), bConst(isConst)
+ : sOwner(parent->d->sOwner)
+ , mOwner(parent->d->mOwner)
+ , mName(name)
+ , bImmutable(isImmutable)
+ , bConst(isConst)
{
if (!parent->d->mName.isEmpty()) {
mParent = parent->d;
@@ -53,8 +62,11 @@ public:
}
KConfigGroupPrivate(const KConfigGroupPrivate *other, bool isImmutable, const QByteArray &name)
- : sOwner(other->sOwner), mOwner(other->mOwner), mName(name),
- bImmutable(isImmutable), bConst(other->bConst)
+ : sOwner(other->sOwner)
+ , mOwner(other->mOwner)
+ , mName(name)
+ , bImmutable(isImmutable)
+ , bConst(other->bConst)
{
if (!other->mName.isEmpty()) {
mParent = const_cast<KConfigGroupPrivate *>(other);
@@ -67,8 +79,8 @@ public:
QByteArray mName;
/* bitfield */
- const bool bImmutable: 1; // is this group immutable?
- const bool bConst: 1; // is this group read-only?
+ const bool bImmutable : 1; // is this group immutable?
+ const bool bConst : 1; // is this group read-only?
QByteArray fullName() const
{
@@ -94,10 +106,7 @@ public:
return fullName() + '\x1d' + aGroup;
}
- static QExplicitlySharedDataPointer<KConfigGroupPrivate> create(KConfigBase *master,
- const QByteArray &name,
- bool isImmutable,
- bool isConst)
+ static QExplicitlySharedDataPointer<KConfigGroupPrivate> create(KConfigBase *master, const QByteArray &name, bool isImmutable, bool isConst)
{
QExplicitlySharedDataPointer<KConfigGroupPrivate> data;
if (dynamic_cast<KConfigGroup *>(master)) {
@@ -198,9 +207,7 @@ static QVector<qreal> asRealList(const QByteArray &string)
static QString errString(const char *pKey, const QByteArray &value, const QVariant &aDefault)
{
return QStringLiteral("\"%1\" - conversion of \"%3\" to %2 failed")
- .arg( QString::fromLatin1(pKey),
- QString::fromLatin1(QVariant::typeToName(aDefault.type())),
- QString::fromLatin1(value) );
+ .arg(QString::fromLatin1(pKey), QString::fromLatin1(QVariant::typeToName(aDefault.type())), QString::fromLatin1(value));
}
static QString formatError(int expected, int got)
@@ -249,8 +256,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asIntList(value);
if (list.count() != 2) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(2, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
return aDefault;
}
return QPoint(list.at(0), list.at(1));
@@ -259,8 +265,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asRealList(value);
if (list.count() != 2) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(2, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
return aDefault;
}
return QPointF(list.at(0), list.at(1));
@@ -269,8 +274,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asIntList(value);
if (list.count() != 4) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(4, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count());
return aDefault;
}
const QRect rect(list.at(0), list.at(1), list.at(2), list.at(3));
@@ -284,8 +288,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asRealList(value);
if (list.count() != 4) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(4, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(4, list.count());
return aDefault;
}
const QRectF rect(list.at(0), list.at(1), list.at(2), list.at(3));
@@ -299,8 +302,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asIntList(value);
if (list.count() != 2) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(2, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
return aDefault;
}
const QSize size(list.at(0), list.at(1));
@@ -314,8 +316,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
const auto list = asRealList(value);
if (list.count() != 2) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(2, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(2, list.count());
return aDefault;
}
const QSizeF size(list.at(0), list.at(1));
@@ -328,8 +329,7 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
case QMetaType::QDateTime: {
const auto list = asRealList(value);
if (list.count() < 6) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(6, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(6, list.count());
return aDefault;
}
const QDate date(list.at(0), list.at(1), list.at(2));
@@ -348,11 +348,10 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
case QMetaType::QDate: {
auto list = asIntList(value);
if (list.count() == 6) {
- list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime
+ list = list.mid(0, 3); // don't break config files that stored QDate as QDateTime
}
if (list.count() != 3) {
- qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault)
- << formatError(3, list.count());
+ qCWarning(KCONFIG_CORE_LOG) << errString(pKey, value, aDefault) << formatError(3, list.count());
return aDefault;
}
const QDate date(list.at(0), list.at(1), list.at(2));
@@ -364,10 +363,9 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
}
case QMetaType::QColor:
case QMetaType::QFont:
- qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '"
- << aDefault.typeName()
- << "' but KConfigGui isn't linked! If it is linked to your program, "
- "this is a platform bug. Please inform the KDE developers";
+ qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::readEntry was passed GUI type '" << aDefault.typeName()
+ << "' but KConfigGui isn't linked! If it is linked to your program, "
+ "this is a platform bug. Please inform the KDE developers";
break;
case QMetaType::QUrl:
return QUrl(QString::fromUtf8(value));
@@ -381,12 +379,12 @@ QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &val
}
#ifdef Q_OS_WIN
-# include <QDir>
+#include <QDir>
#endif
static bool cleanHomeDirPath(QString &path, const QString &homeDir)
{
-#ifdef Q_OS_WIN //safer
+#ifdef Q_OS_WIN // safer
if (!QDir::toNativeSeparators(path).startsWith(QDir::toNativeSeparators(homeDir))) {
return false;
}
@@ -406,7 +404,7 @@ static bool cleanHomeDirPath(QString &path, const QString &homeDir)
return false;
}
-static QString translatePath(QString path) // krazy:exclude=passbyvalue
+static QString translatePath(QString path) // krazy:exclude=passbyvalue
{
if (path.isEmpty()) {
return path;
@@ -429,9 +427,7 @@ static QString translatePath(QString path) // krazy:exclude=passbyvalue
const QString homeDir0 = QFile::decodeName(qgetenv("HOME"));
const QString homeDir1 = QDir::homePath();
const QString homeDir2 = QDir(homeDir1).canonicalPath();
- if (cleanHomeDirPath(path, homeDir0) ||
- cleanHomeDirPath(path, homeDir1) ||
- cleanHomeDirPath(path, homeDir2)) {
+ if (cleanHomeDirPath(path, homeDir0) || cleanHomeDirPath(path, homeDir1) || cleanHomeDirPath(path, homeDir2)) {
// qDebug() << "Path was replaced\n";
}
@@ -442,7 +438,8 @@ static QString translatePath(QString path) // krazy:exclude=passbyvalue
return path;
}
-KConfigGroup::KConfigGroup() : d()
+KConfigGroup::KConfigGroup()
+ : d()
{
}
@@ -452,8 +449,7 @@ bool KConfigGroup::isValid() const
}
KConfigGroupGui _kde_internal_KConfigGroupGui;
-static inline bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input,
- QVariant &output)
+static inline bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output)
{
if (_kde_internal_KConfigGroupGui.readEntryGui) {
return _kde_internal_KConfigGroupGui.readEntryGui(data, key, input, output);
@@ -461,8 +457,7 @@ static inline bool readEntryGui(const QByteArray &data, const char *key, const Q
return false;
}
-static inline bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input,
- KConfigGroup::WriteConfigFlags flags)
+static inline bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags)
{
if (_kde_internal_KConfigGroupGui.writeEntryGui) {
return _kde_internal_KConfigGroupGui.writeEntryGui(cg, key, input, flags);
@@ -535,8 +530,7 @@ const KConfigGroup KConfigGroup::groupImpl(const QByteArray &aGroup) const
KConfigGroup newGroup;
- newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup *>(this), isGroupImmutableImpl(aGroup),
- true, aGroup);
+ newGroup.d = new KConfigGroupPrivate(const_cast<KConfigGroup *>(this), isGroupImmutableImpl(aGroup), true, aGroup);
return newGroup;
}
@@ -634,8 +628,7 @@ bool KConfigGroup::isEntryImmutable(const char *key) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::isEntryImmutable", "accessing an invalid group");
- return (isImmutable() ||
- !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults()));
+ return (isImmutable() || !config()->d_func()->canWriteEntry(d->fullName(), key, config()->readDefaults()));
}
bool KConfigGroup::isEntryImmutable(const QString &key) const
@@ -676,8 +669,7 @@ QString KConfigGroup::readEntry(const char *key, const QString &aDefault) const
bool expand = false;
// read value from the entry map
- QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized,
- &expand);
+ QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand);
if (aValue.isNull()) {
aValue = aDefault;
}
@@ -809,8 +801,7 @@ QString KConfigGroup::readPathEntry(const char *key, const QString &aDefault) co
bool expand = false;
- QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized,
- &expand);
+ QString aValue = config()->d_func()->lookupData(d->fullName(), key, KEntryMap::SearchLocalized, &expand);
if (aValue.isNull()) {
aValue = aDefault;
}
@@ -861,8 +852,7 @@ void KConfigGroup::writeEntry(const char *key, const char *value, WriteConfigFla
writeEntry(key, QVariant(QString::fromLatin1(value)), pFlags);
}
-void KConfigGroup::writeEntry(const char *key, const QByteArray &value,
- WriteConfigFlags flags)
+void KConfigGroup::writeEntry(const char *key, const QByteArray &value, WriteConfigFlags flags)
{
Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
@@ -870,8 +860,7 @@ void KConfigGroup::writeEntry(const char *key, const QByteArray &value,
config()->d_func()->putData(d->fullName(), key, value.isNull() ? QByteArray("") : value, flags);
}
-void KConfigGroup::writeEntry(const QString &key, const QByteArray &value,
- WriteConfigFlags pFlags)
+void KConfigGroup::writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags)
{
writeEntry(key.toUtf8().constData(), value, pFlags);
}
@@ -915,14 +904,13 @@ void KConfigGroup::writeEntry(const char *key, const QVariantList &list, WriteCo
writeEntry(key, KConfigGroupPrivate::serializeList(data), flags);
}
-void KConfigGroup::writeEntry(const char *key, const QVariant &value,
- WriteConfigFlags flags)
+void KConfigGroup::writeEntry(const char *key, const QVariant &value, WriteConfigFlags flags)
{
Q_ASSERT_X(isValid(), "KConfigGroup::writeEntry", "accessing an invalid group");
Q_ASSERT_X(!d->bConst, "KConfigGroup::writeEntry", "writing to a read-only group");
if (writeEntryGui(this, key, value, flags)) {
- return; // GUI type that was handled
+ return; // GUI type that was handled
}
QByteArray data;
@@ -948,8 +936,9 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
break;
case QMetaType::QVariantList:
if (!value.canConvert(QMetaType::QStringList))
- qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key << "\" can convert to QString,"
- " information will be lost";
+ qCWarning(KCONFIG_CORE_LOG) << "not all types in \"" << key
+ << "\" can convert to QString,"
+ " information will be lost";
Q_FALLTHROUGH();
case QMetaType::QStringList:
writeEntry(key, value.toList(), flags);
@@ -957,10 +946,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QPoint: {
const QPoint rPoint = value.toPoint();
- const QVariantList list{
- rPoint.x(),
- rPoint.y()
- };
+ const QVariantList list{rPoint.x(), rPoint.y()};
writeEntry(key, list, flags);
return;
@@ -968,10 +954,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QPointF: {
const QPointF point = value.toPointF();
- const QVariantList list{
- point.x(),
- point.y()
- };
+ const QVariantList list{point.x(), point.y()};
writeEntry(key, list, flags);
return;
@@ -979,12 +962,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QRect: {
const QRect rRect = value.toRect();
- const QVariantList list{
- rRect.left(),
- rRect.top(),
- rRect.width(),
- rRect.height()
- };
+ const QVariantList list{rRect.left(), rRect.top(), rRect.width(), rRect.height()};
writeEntry(key, list, flags);
return;
@@ -992,12 +970,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QRectF: {
const QRectF rRectF = value.toRectF();
- const QVariantList list{
- rRectF.left(),
- rRectF.top(),
- rRectF.width(),
- rRectF.height()
- };
+ const QVariantList list{rRectF.left(), rRectF.top(), rRectF.width(), rRectF.height()};
writeEntry(key, list, flags);
return;
@@ -1005,10 +978,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QSize: {
const QSize rSize = value.toSize();
- const QVariantList list{
- rSize.width(),
- rSize.height()
- };
+ const QVariantList list{rSize.width(), rSize.height()};
writeEntry(key, list, flags);
return;
@@ -1016,10 +986,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QSizeF: {
const QSizeF rSizeF = value.toSizeF();
- const QVariantList list{
- rSizeF.width(),
- rSizeF.height()
- };
+ const QVariantList list{rSizeF.width(), rSizeF.height()};
writeEntry(key, list, flags);
return;
@@ -1027,11 +994,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QDate: {
const QDate date = value.toDate();
- const QVariantList list{
- date.year(),
- date.month(),
- date.day()
- };
+ const QVariantList list{date.year(), date.month(), date.day()};
writeEntry(key, list, flags);
return;
@@ -1049,7 +1012,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
time.hour(),
time.minute(),
- time.second() + time.msec()/1000.0,
+ time.second() + time.msec() / 1000.0,
};
writeEntry(key, list, flags);
@@ -1058,10 +1021,9 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value,
case QMetaType::QColor:
case QMetaType::QFont:
- qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '"
- << value.typeName()
- << "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. "
- "Please inform the KDE developers";
+ qCWarning(KCONFIG_CORE_LOG) << "KConfigGroup::writeEntry was passed GUI type '" << value.typeName()
+ << "' but KConfigGui isn't linked! If it is linked to your program, this is a platform bug. "
+ "Please inform the KDE developers";
break;
case QMetaType::QUrl:
data = QUrl(value.toUrl()).toString().toUtf8();
@@ -1260,7 +1222,7 @@ bool KConfigGroup::isGroupImmutableImpl(const QByteArray &b) const
Q_ASSERT_X(isValid(), "KConfigGroup::isGroupImmutableImpl", "accessing an invalid group");
if (!hasGroupImpl(b)) { // group doesn't exist yet
- return d->bImmutable; // child groups are immutable if the parent is immutable.
+ return d->bImmutable; // child groups are immutable if the parent is immutable.
}
return config()->isGroupImmutable(d->fullName(b));
diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h
index 620f04c0..5c125dd2 100644
--- a/src/core/kconfiggroup.h
+++ b/src/core/kconfiggroup.h
@@ -16,8 +16,8 @@
#include <kconfigcore_export.h>
#include <QExplicitlySharedDataPointer>
-#include <QVariant>
#include <QStringList>
+#include <QVariant>
class KConfig;
class KConfigGroupPrivate;
@@ -246,7 +246,7 @@ public:
*
* @see writeEntry(), deleteEntry(), hasKey()
*/
- template <typename T>
+ template<typename T>
T readEntry(const QString &key, const T &aDefault) const
{
return readEntry(key.toUtf8().constData(), aDefault);
@@ -255,7 +255,7 @@ public:
* Overload for readEntry<T>(const QString&, const T&) const
* @param key name of key, encoded in UTF-8
*/
- template <typename T>
+ template<typename T>
T readEntry(const char *key, const T &aDefault) const;
/**
@@ -414,14 +414,12 @@ public:
* @param aDefault a default value returned if the key was not found
* @return the value for this key, or @p aDefault if the key does not exist
*/
- QString readEntryUntranslated(const QString &pKey,
- const QString &aDefault = QString()) const;
+ QString readEntryUntranslated(const QString &pKey, const QString &aDefault = QString()) const;
/**
* Overload for readEntryUntranslated(const QString&, const QString&) const
* @param key name of key, encoded in UTF-8
*/
- QString readEntryUntranslated(const char *key,
- const QString &aDefault = QString()) const;
+ QString readEntryUntranslated(const char *key, const QString &aDefault = QString()) const;
/**
* Writes a value to the configuration object.
@@ -432,34 +430,28 @@ public:
*
* @see readEntry(), writeXdgListEntry(), deleteEntry()
*/
- void writeEntry(const QString &key, const QVariant &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags = Normal);
/**
* Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writeEntry(const char *key, const QVariant &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const char *key, const QVariant &value, WriteConfigFlags pFlags = Normal);
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
- void writeEntry(const QString &key, const QString &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const QString &key, const QString &value, WriteConfigFlags pFlags = Normal);
/**
* Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writeEntry(const char *key, const QString &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const char *key, const QString &value, WriteConfigFlags pFlags = Normal);
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
- void writeEntry(const QString &key, const QByteArray &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const QString &key, const QByteArray &value, WriteConfigFlags pFlags = Normal);
/**
* Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writeEntry(const char *key, const QByteArray &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const char *key, const QByteArray &value, WriteConfigFlags pFlags = Normal);
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
void writeEntry(const QString &key, const char *value, WriteConfigFlags pFlags = Normal);
@@ -473,37 +465,33 @@ public:
* Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- template <typename T>
+ template<typename T>
void writeEntry(const char *key, const T &value, WriteConfigFlags pFlags = Normal);
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
- template <typename T>
+ template<typename T>
void writeEntry(const QString &key, const T &value, WriteConfigFlags pFlags = Normal)
{
writeEntry(key.toUtf8().constData(), value, pFlags);
}
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
- void writeEntry(const QString &key, const QStringList &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const QString &key, const QStringList &value, WriteConfigFlags pFlags = Normal);
/**
* Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writeEntry(const char *key, const QStringList &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal);
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
- void writeEntry(const QString &key, const QVariantList &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const QString &key, const QVariantList &value, WriteConfigFlags pFlags = Normal);
/**
* Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writeEntry(const char *key, const QVariantList &value,
- WriteConfigFlags pFlags = Normal);
+ void writeEntry(const char *key, const QVariantList &value, WriteConfigFlags pFlags = Normal);
/** Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags) */
- template <typename T>
+ template<typename T>
void writeEntry(const QString &key, const QList<T> &value, WriteConfigFlags pFlags = Normal)
{
writeEntry(key.toUtf8().constData(), value, pFlags);
@@ -512,7 +500,7 @@ public:
* Overload for writeEntry(const QString&, const QVariant&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- template <typename T>
+ template<typename T>
void writeEntry(const char *key, const QList<T> &value, WriteConfigFlags pFlags = Normal);
/**
@@ -525,14 +513,12 @@ public:
*
* @see writeEntry(), readXdgListEntry()
*/
- void writeXdgListEntry(const QString &pKey, const QStringList &value,
- WriteConfigFlags pFlags = Normal);
+ void writeXdgListEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal);
/**
* Overload for writeXdgListEntry(const QString&, const QStringList&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writeXdgListEntry(const char *key, const QStringList &value,
- WriteConfigFlags pFlags = Normal);
+ void writeXdgListEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal);
/**
* Writes a file path to the configuration
@@ -547,14 +533,12 @@ public:
*
* @see writeEntry(), readPathEntry()
*/
- void writePathEntry(const QString &pKey, const QString &path,
- WriteConfigFlags pFlags = Normal);
+ void writePathEntry(const QString &pKey, const QString &path, WriteConfigFlags pFlags = Normal);
/**
* Overload for writePathEntry(const QString&, const QString&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writePathEntry(const char *Key, const QString &path,
- WriteConfigFlags pFlags = Normal);
+ void writePathEntry(const char *Key, const QString &path, WriteConfigFlags pFlags = Normal);
/**
* Writes a list of paths to the configuration
@@ -569,14 +553,12 @@ public:
*
* @see writeEntry(), readPathEntry()
*/
- void writePathEntry(const QString &pKey, const QStringList &value,
- WriteConfigFlags pFlags = Normal);
+ void writePathEntry(const QString &pKey, const QStringList &value, WriteConfigFlags pFlags = Normal);
/**
* Overload for writePathEntry(const QString&, const QStringList&, WriteConfigFlags)
* @param key name of key, encoded in UTF-8
*/
- void writePathEntry(const char *key, const QStringList &value,
- WriteConfigFlags pFlags = Normal);
+ void writePathEntry(const char *key, const QStringList &value, WriteConfigFlags pFlags = Normal);
/**
* Deletes the entry specified by @p pKey in the current group
@@ -742,9 +724,7 @@ private:
friend class KServicePrivate; // XXX yeah, ugly^5
};
-#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM) \
- "The Qt MetaObject system does not seem to know about \"" ENUM \
- "\" please use Q_ENUM or Q_FLAG to register it."
+#define KCONFIGGROUP_ENUMERATOR_ERROR(ENUM) "The Qt MetaObject system does not seem to know about \"" ENUM "\" please use Q_ENUM or Q_FLAG to register it."
/**
* To add support for your own enums in KConfig, you can declare them with Q_ENUM()
@@ -754,70 +734,88 @@ private:
* <code>KCONFIGGROUP_DECLARE_ENUM_QOBJECT(MyClass, MyEnum)</code>
*
*/
-#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum) \
- template<> \
- Class::Enum KConfigGroup::readEntry(const char* key, const Class::Enum& def) const\
- { \
- const QMetaObject* M_obj = &Class::staticMetaObject; \
- const int M_index = M_obj->indexOfEnumerator(#Enum); \
- if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \
- const QMetaEnum M_enum = M_obj->enumerator(M_index); \
- const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKey(def)));\
- return static_cast<Class::Enum>(M_enum.keyToValue(M_data.constData())); \
- } \
- inline Class::Enum Q_DECL_DEPRECATED readEntry(const KConfigGroup& group, const char* key, const Class::Enum& def)\
- { return group.readEntry(key, def); } \
- template<> \
- void KConfigGroup::writeEntry(const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags)\
- { \
- const QMetaObject* M_obj = &Class::staticMetaObject; \
- const int M_index = M_obj->indexOfEnumerator(#Enum); \
- if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \
- const QMetaEnum M_enum = M_obj->enumerator(M_index); \
- writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags); \
- } \
- inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup& group, const char* key, const Class::Enum& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
- { group.writeEntry(key, value, flags); }
+#define KCONFIGGROUP_DECLARE_ENUM_QOBJECT(Class, Enum) \
+ template<> \
+ Class::Enum KConfigGroup::readEntry(const char *key, const Class::Enum &def) const \
+ { \
+ const QMetaObject *M_obj = &Class::staticMetaObject; \
+ const int M_index = M_obj->indexOfEnumerator(#Enum); \
+ if (M_index == -1) \
+ qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \
+ const QMetaEnum M_enum = M_obj->enumerator(M_index); \
+ const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKey(def))); \
+ return static_cast<Class::Enum>(M_enum.keyToValue(M_data.constData())); \
+ } \
+ inline Class::Enum Q_DECL_DEPRECATED readEntry(const KConfigGroup &group, const char *key, const Class::Enum &def) \
+ { \
+ return group.readEntry(key, def); \
+ } \
+ template<> \
+ void KConfigGroup::writeEntry(const char *key, const Class::Enum &value, KConfigBase::WriteConfigFlags flags) \
+ { \
+ const QMetaObject *M_obj = &Class::staticMetaObject; \
+ const int M_index = M_obj->indexOfEnumerator(#Enum); \
+ if (M_index == -1) \
+ qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Enum)); \
+ const QMetaEnum M_enum = M_obj->enumerator(M_index); \
+ writeEntry(key, QByteArray(M_enum.valueToKey(value)), flags); \
+ } \
+ inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup &group, \
+ const char *key, \
+ const Class::Enum &value, \
+ KConfigBase::WriteConfigFlags flags = KConfigBase::Normal) \
+ { \
+ group.writeEntry(key, value, flags); \
+ }
/**
* Similar to KCONFIGGROUP_DECLARE_ENUM_QOBJECT but for flags declared with Q_FLAG()
* (where multiple values can be set at the same time)
*/
-#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags) \
- template<> \
- Class::Flags KConfigGroup::readEntry(const char* key, const Class::Flags& def) const\
- { \
- const QMetaObject* M_obj = &Class::staticMetaObject; \
- const int M_index = M_obj->indexOfEnumerator(#Flags); \
- if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \
- const QMetaEnum M_enum = M_obj->enumerator(M_index); \
- const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKeys(def)));\
- return static_cast<Class::Flags>(M_enum.keysToValue(M_data.constData())); \
- } \
- inline Class::Flags Q_DECL_DEPRECATED readEntry(const KConfigGroup& group, const char* key, const Class::Flags& def)\
- { return group.readEntry(key, def);} \
- template<> \
- void KConfigGroup::writeEntry(const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags)\
- { \
- const QMetaObject* M_obj = &Class::staticMetaObject; \
- const int M_index = M_obj->indexOfEnumerator(#Flags); \
- if(M_index == -1) qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \
- const QMetaEnum M_enum = M_obj->enumerator(M_index); \
- writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \
- } \
- inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup& group, const char* key, const Class::Flags& value, KConfigBase::WriteConfigFlags flags = KConfigBase::Normal)\
- { group.writeEntry(key, value, flags); }
+#define KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(Class, Flags) \
+ template<> \
+ Class::Flags KConfigGroup::readEntry(const char *key, const Class::Flags &def) const \
+ { \
+ const QMetaObject *M_obj = &Class::staticMetaObject; \
+ const int M_index = M_obj->indexOfEnumerator(#Flags); \
+ if (M_index == -1) \
+ qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \
+ const QMetaEnum M_enum = M_obj->enumerator(M_index); \
+ const QByteArray M_data = readEntry(key, QByteArray(M_enum.valueToKeys(def))); \
+ return static_cast<Class::Flags>(M_enum.keysToValue(M_data.constData())); \
+ } \
+ inline Class::Flags Q_DECL_DEPRECATED readEntry(const KConfigGroup &group, const char *key, const Class::Flags &def) \
+ { \
+ return group.readEntry(key, def); \
+ } \
+ template<> \
+ void KConfigGroup::writeEntry(const char *key, const Class::Flags &value, KConfigBase::WriteConfigFlags flags) \
+ { \
+ const QMetaObject *M_obj = &Class::staticMetaObject; \
+ const int M_index = M_obj->indexOfEnumerator(#Flags); \
+ if (M_index == -1) \
+ qFatal(KCONFIGGROUP_ENUMERATOR_ERROR(#Flags)); \
+ const QMetaEnum M_enum = M_obj->enumerator(M_index); \
+ writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \
+ } \
+ inline void Q_DECL_DEPRECATED writeEntry(KConfigGroup &group, \
+ const char *key, \
+ const Class::Flags &value, \
+ KConfigBase::WriteConfigFlags flags = KConfigBase::Normal) \
+ { \
+ group.writeEntry(key, value, flags); \
+ }
#include "conversioncheck.h"
-template <typename T>
+template<typename T>
T KConfigGroup::readEntry(const char *key, const T &defaultValue) const
{
ConversionCheck::to_QVariant<T>();
return qvariant_cast<T>(readEntry(key, QVariant::fromValue(defaultValue)));
}
-template <typename T>
+template<typename T>
QList<T> KConfigGroup::readEntry(const char *key, const QList<T> &defaultValue) const
{
ConversionCheck::to_QVariant<T>();
@@ -839,14 +837,14 @@ QList<T> KConfigGroup::readEntry(const char *key, const QList<T> &defaultValue)
return list;
}
-template <typename T>
+template<typename T>
void KConfigGroup::writeEntry(const char *key, const T &value, WriteConfigFlags pFlags)
{
ConversionCheck::to_QVariant<T>();
writeEntry(key, QVariant::fromValue(value), pFlags);
}
-template <typename T>
+template<typename T>
void KConfigGroup::writeEntry(const char *key, const QList<T> &list, WriteConfigFlags pFlags)
{
ConversionCheck::to_QVariant<T>();
diff --git a/src/core/kconfiggroup_p.h b/src/core/kconfiggroup_p.h
index 923387e7..2744c153 100644
--- a/src/core/kconfiggroup_p.h
+++ b/src/core/kconfiggroup_p.h
@@ -8,16 +8,14 @@
#ifndef KCONFIGGROUP_P_H
#define KCONFIGGROUP_P_H
-#include <QVariant>
#include "kconfiggroup.h"
+#include <QVariant>
class KConfigGroup;
struct KConfigGroupGui {
- typedef bool (*kReadEntryGui)(const QByteArray &data, const char *key, const QVariant &input,
- QVariant &output);
- typedef bool (*kWriteEntryGui)(KConfigGroup *, const char *key, const QVariant &input,
- KConfigGroup::WriteConfigFlags flags);
+ typedef bool (*kReadEntryGui)(const QByteArray &data, const char *key, const QVariant &input, QVariant &output);
+ typedef bool (*kWriteEntryGui)(KConfigGroup *, const char *key, const QVariant &input, KConfigGroup::WriteConfigFlags flags);
kReadEntryGui readEntryGui;
kWriteEntryGui writeEntryGui;
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp
index 96cd3763..6271bcd5 100644
--- a/src/core/kconfigini.cpp
+++ b/src/core/kconfigini.cpp
@@ -9,26 +9,26 @@
#include "kconfigini_p.h"
+#include "bufferfragment_p.h"
#include "kconfig.h"
+#include "kconfig_core_log_settings.h"
#include "kconfigbackend_p.h"
-#include "bufferfragment_p.h"
#include "kconfigdata.h"
-#include "kconfig_core_log_settings.h"
-#include <QSaveFile>
-#include <QLockFile>
#include <QDateTime>
+#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
-#include <QDebug>
+#include <QLockFile>
+#include <QSaveFile>
#include <qplatformdefs.h>
#ifndef Q_OS_WIN
#include <unistd.h> // getuid, close
#endif
-#include <sys/types.h> // uid_t
#include <fcntl.h> // open
+#include <sys/types.h> // uid_t
KCONFIGCORE_EXPORT bool kde_kiosk_exception = false; // flag to disable kiosk restrictions
@@ -44,12 +44,12 @@ static QByteArray lookup(const KConfigIniBackend::BufferFragment fragment, QHash
QString KConfigIniBackend::warningProlog(const QFile &file, int line)
{
- return QStringLiteral("KConfigIni: In file %2, line %1: ")
- .arg(line).arg(file.fileName());
+ return QStringLiteral("KConfigIni: In file %2, line %1: ").arg(line).arg(file.fileName());
}
KConfigIniBackend::KConfigIniBackend()
- : KConfigBackend(), lockFile(nullptr)
+ : KConfigBackend()
+ , lockFile(nullptr)
{
}
@@ -57,18 +57,14 @@ KConfigIniBackend::~KConfigIniBackend()
{
}
-KConfigBackend::ParseInfo
-KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entryMap,
- ParseOptions options)
+KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entryMap, ParseOptions options)
{
return parseConfig(currentLocale, entryMap, options, false);
}
// merging==true is the merging that happens at the beginning of writeConfig:
// merge changes in the on-disk file with the changes in the KConfig object.
-KConfigBackend::ParseInfo
-KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entryMap,
- ParseOptions options, bool merging)
+KConfigBackend::ParseInfo KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entryMap, ParseOptions options, bool merging)
{
if (filePath().isEmpty() || !QFile::exists(filePath())) {
return ParseOk;
@@ -137,8 +133,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
}
++end;
}
- if (end + 1 == line.length() && start + 2 == end &&
- line.at(start) == '$' && line.at(start + 1) == 'i') {
+ if (end + 1 == line.length() && start + 2 == end && line.at(start) == '$' && line.at(start + 1) == 'i') {
if (newGroup.isEmpty()) {
fileOptionImmutable = !kde_kiosk_exception;
} else {
@@ -162,14 +157,14 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
}
if (groupOptionImmutable)
- // Do not make the groups immutable until the entries from
- // this file have been added.
+ // Do not make the groups immutable until the entries from
+ // this file have been added.
{
immutableGroups.append(currentGroup);
}
} else {
if (groupSkip && !bDefault) {
- continue; // skip entry
+ continue; // skip entry
}
BufferFragment aKey;
@@ -199,8 +194,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
while ((start = aKey.lastIndexOf('[')) >= 0) {
int end = aKey.indexOf(']', start);
if (end < 0) {
- qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo)
- << "Invalid entry (missing ']')";
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (missing ']')";
goto next_line;
} else if (end > start + 1 && aKey.at(start + 1) == '$') { // found option(s)
int i = start + 2;
@@ -229,8 +223,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
}
} else { // found a locale
if (!locale.isNull()) {
- qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo)
- << "Invalid entry (second locale!?)";
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, lineNo) << "Invalid entry (second locale!?)";
goto next_line;
}
@@ -250,7 +243,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
if (merging) {
entryOptions |= KEntryMap::EntryRawKey;
} else {
- goto next_line; // skip this entry if we're not merging
+ goto next_line; // skip this entry if we're not merging
}
}
}
@@ -295,8 +288,7 @@ KConfigIniBackend::parseConfig(const QByteArray &currentLocale, KEntryMap &entry
return fileOptionImmutable ? ParseImmutable : ParseOk;
}
-void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,
- const KEntryMap &map, bool defaultGroup, bool &firstEntry)
+void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry)
{
QByteArray currentGroup;
bool groupIsImmutable = false;
@@ -306,7 +298,7 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,
// Either process the default group or all others
if ((key.mGroup != "<default>") == defaultGroup) {
- continue; // skip
+ continue; // skip
}
// the only thing we care about groups is, is it immutable?
@@ -366,9 +358,9 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,
}
if (currentEntry.bDeleted) {
if (currentEntry.bImmutable) {
- file.write("[$di]", 5); // Deleted + immutable
+ file.write("[$di]", 5); // Deleted + immutable
} else {
- file.write("[$d]", 4); // Deleted
+ file.write("[$d]", 4); // Deleted
}
} else {
if (currentEntry.bImmutable || currentEntry.bExpand) {
@@ -399,8 +391,7 @@ void KConfigIniBackend::writeEntries(const QByteArray &locale, QIODevice &file,
writeEntries(locale, file, map, false, firstEntry);
}
-bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMap,
- WriteOptions options)
+bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options)
{
Q_ASSERT(!filePath().isEmpty());
@@ -442,10 +433,10 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa
defaultKey.bDefault = true;
if (!entryMap.contains(defaultKey)) {
writeMap.remove(key); // remove the deleted entry if there is no default
- //qDebug() << "Detected as deleted=>removed:" << key.mGroup << key.mKey << "global=" << bGlobal;
+ // qDebug() << "Detected as deleted=>removed:" << key.mGroup << key.mKey << "global=" << bGlobal;
} else {
writeMap[key] = *it; // otherwise write an explicitly deleted entry
- //qDebug() << "Detected as deleted=>[$d]:" << key.mGroup << key.mKey << "global=" << bGlobal;
+ // qDebug() << "Detected as deleted=>[$d]:" << key.mGroup << key.mKey << "global=" << bGlobal;
}
}
it->bDirty = false;
@@ -462,7 +453,7 @@ bool KConfigIniBackend::writeConfig(const QByteArray &locale, KEntryMap &entryMa
QFileInfo fi(filePath());
if (fi.exists()) {
#ifdef Q_OS_WIN
- //TODO: getuid does not exist on windows, use GetSecurityInfo and GetTokenInformation instead
+ // TODO: getuid does not exist on windows, use GetSecurityInfo and GetTokenInformation instead
createNew = false;
#else
if (fi.ownerId() == ::getuid()) {
@@ -574,7 +565,7 @@ void KConfigIniBackend::createEnclosing()
{
const QString file = filePath();
if (file.isEmpty()) {
- return; // nothing to do
+ return; // nothing to do
}
// Create the containing dir, maybe it wasn't there
@@ -639,106 +630,112 @@ bool KConfigIniBackend::isLocked() const
return lockFile && lockFile->isLocked();
}
-namespace {
- // serialize an escaped byte at the end of @param data
- // @param data should have room for 4 bytes
- char* escapeByte(char* data, unsigned char s) {
- static const char nibbleLookup[] = {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
- };
- *data++ = '\\';
- *data++ = 'x';
- *data++ = nibbleLookup[s >> 4];
- *data++ = nibbleLookup[s & 0x0f];
- return data;
- }
+namespace
+{
+// serialize an escaped byte at the end of @param data
+// @param data should have room for 4 bytes
+char *escapeByte(char *data, unsigned char s)
+{
+ static const char nibbleLookup[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+ *data++ = '\\';
+ *data++ = 'x';
+ *data++ = nibbleLookup[s >> 4];
+ *data++ = nibbleLookup[s & 0x0f];
+ return data;
+}
- // Struct that represents a multi-byte UTF-8 character.
- // This struct is used to keep track of bytes that seem to be valid
- // UTF-8.
- struct Utf8Char {
- public:
- unsigned char bytes[4];
- unsigned char count;
- unsigned char charLength;
-
- Utf8Char() {
- clear();
- charLength = 0;
- }
- void clear() {
- count = 0;
- }
- // Add a byte to the UTF8 character.
- // When an additional byte leads to an invalid character, return false.
- bool addByte(unsigned char b) {
- if (count == 0) {
- if (b > 0xc1 && (b & 0xe0) == 0xc0) {
- charLength = 2;
- } else if ((b & 0xf0) == 0xe0) {
- charLength = 3;
- } else if (b < 0xf5 && (b & 0xf8) == 0xf0) {
- charLength = 4;
- } else {
- return false;
+// Struct that represents a multi-byte UTF-8 character.
+// This struct is used to keep track of bytes that seem to be valid
+// UTF-8.
+struct Utf8Char {
+public:
+ unsigned char bytes[4];
+ unsigned char count;
+ unsigned char charLength;
+
+ Utf8Char()
+ {
+ clear();
+ charLength = 0;
+ }
+ void clear()
+ {
+ count = 0;
+ }
+ // Add a byte to the UTF8 character.
+ // When an additional byte leads to an invalid character, return false.
+ bool addByte(unsigned char b)
+ {
+ if (count == 0) {
+ if (b > 0xc1 && (b & 0xe0) == 0xc0) {
+ charLength = 2;
+ } else if ((b & 0xf0) == 0xe0) {
+ charLength = 3;
+ } else if (b < 0xf5 && (b & 0xf8) == 0xf0) {
+ charLength = 4;
+ } else {
+ return false;
+ }
+ bytes[0] = b;
+ count = 1;
+ } else if (count < 4 && (b & 0xc0) == 0x80) {
+ if (count == 1) {
+ if (charLength == 3 && bytes[0] == 0xe0 && b < 0xa0) {
+ return false; // overlong 3 byte sequence
}
- bytes[0] = b;
- count = 1;
- } else if (count < 4 && (b & 0xc0) == 0x80) {
- if (count == 1) {
- if (charLength == 3 && bytes[0] == 0xe0 && b < 0xa0) {
- return false; // overlong 3 byte sequence
+ if (charLength == 4) {
+ if (bytes[0] == 0xf0 && b < 0x90) {
+ return false; // overlong 4 byte sequence
}
- if (charLength == 4) {
- if (bytes[0] == 0xf0 && b < 0x90) {
- return false; // overlong 4 byte sequence
- }
- if (bytes[0] == 0xf4 && b > 0x8f) {
- return false; // Unicode value larger than U+10FFFF
- }
+ if (bytes[0] == 0xf4 && b > 0x8f) {
+ return false; // Unicode value larger than U+10FFFF
}
}
- bytes[count++] = b;
- } else {
- return false;
}
- return true;
- }
- // Return true if Utf8Char contains one valid character.
- bool isComplete() {
- return count > 0 && count == charLength;
+ bytes[count++] = b;
+ } else {
+ return false;
}
- // Add the bytes in this UTF8 character in escaped form to data.
- char* escapeBytes(char* data) {
- for (unsigned char i = 0; i < count; ++i) {
- data = escapeByte(data, bytes[i]);
- }
- clear();
- return data;
+ return true;
+ }
+ // Return true if Utf8Char contains one valid character.
+ bool isComplete()
+ {
+ return count > 0 && count == charLength;
+ }
+ // Add the bytes in this UTF8 character in escaped form to data.
+ char *escapeBytes(char *data)
+ {
+ for (unsigned char i = 0; i < count; ++i) {
+ data = escapeByte(data, bytes[i]);
}
- // Add the bytes of the UTF8 character to a buffer.
- // Only call this if isComplete() returns true.
- char* writeUtf8(char* data) {
- for (unsigned char i = 0; i < count; ++i) {
- *data++ = bytes[i];
- }
- clear();
- return data;
+ clear();
+ return data;
+ }
+ // Add the bytes of the UTF8 character to a buffer.
+ // Only call this if isComplete() returns true.
+ char *writeUtf8(char *data)
+ {
+ for (unsigned char i = 0; i < count; ++i) {
+ *data++ = bytes[i];
}
- // Write the bytes in the UTF8 character literally, or, if the
- // character is not complete, write the escaped bytes.
- // This is useful to handle the state that remains after handling
- // all bytes in a buffer.
- char* write(char* data) {
- if (isComplete()) {
- data = writeUtf8(data);
- } else {
- data = escapeBytes(data);
- }
- return data;
+ clear();
+ return data;
+ }
+ // Write the bytes in the UTF8 character literally, or, if the
+ // character is not complete, write the escaped bytes.
+ // This is useful to handle the state that remains after handling
+ // all bytes in a buffer.
+ char *write(char *data)
+ {
+ if (isComplete()) {
+ data = writeUtf8(data);
+ } else {
+ data = escapeBytes(data);
}
- };
+ return data;
+ }
+};
}
QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, StringType type)
@@ -763,7 +760,7 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin
}
Utf8Char utf8;
- for (; i < l; ++i/*, r++*/) {
+ for (; i < l; ++i /*, r++*/) {
switch (s[i]) {
default:
if (utf8.addByte(s[i])) {
@@ -847,8 +844,8 @@ char KConfigIniBackend::charFromHex(const char *str, const QFile &file, int line
} else {
QByteArray e(str, 2);
e.prepend("\\x");
- qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << "Invalid hex character " << c
- << " in \\x<nn>-type escape sequence \"" << e.constData() << "\".";
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << "Invalid hex character " << c << " in \\x<nn>-type escape sequence \"" << e.constData()
+ << "\".";
return 'x';
}
}
@@ -915,8 +912,7 @@ void KConfigIniBackend::printableToString(BufferFragment *aString, const QFile &
break;
default:
*r = '\\';
- qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line)
- << QStringLiteral("Invalid escape sequence \"\\%1\".").arg(str[i]);
+ qCWarning(KCONFIG_CORE_LOG) << warningProlog(file, line) << QStringLiteral("Invalid escape sequence \"\\%1\".").arg(str[i]);
}
}
}
diff --git a/src/core/kconfigini_p.h b/src/core/kconfigini_p.h
index d760170d..3397857c 100644
--- a/src/core/kconfigini_p.h
+++ b/src/core/kconfigini_p.h
@@ -10,15 +10,15 @@
#ifndef KCONFIGINI_P_H
#define KCONFIGINI_P_H
-#include <kconfigcore_export.h>
#include <kconfigbackend_p.h>
+#include <kconfigcore_export.h>
class QLockFile;
class QIODevice;
class KConfigIniBackend : public KConfigBackend
{
-Q_OBJECT
+ Q_OBJECT
private:
QLockFile *lockFile;
@@ -28,15 +28,9 @@ public:
KConfigIniBackend();
~KConfigIniBackend() override;
- ParseInfo parseConfig(const QByteArray &locale,
- KEntryMap &entryMap,
- ParseOptions options) override;
- ParseInfo parseConfig(const QByteArray &locale,
- KEntryMap &entryMap,
- ParseOptions options,
- bool merging);
- bool writeConfig(const QByteArray &locale, KEntryMap &entryMap,
- WriteOptions options) override;
+ ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options) override;
+ ParseInfo parseConfig(const QByteArray &locale, KEntryMap &entryMap, ParseOptions options, bool merging);
+ bool writeConfig(const QByteArray &locale, KEntryMap &entryMap, WriteOptions options) override;
bool isWritable() const override;
QString nonWritableErrorMessage() const override;
@@ -48,7 +42,6 @@ public:
bool isLocked() const override;
protected:
-
enum StringType {
GroupString = 0,
KeyString = 1,
@@ -62,8 +55,7 @@ protected:
static QString warningProlog(const QFile &file, int line);
void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map);
- void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map,
- bool defaultGroup, bool &firstEntry);
+ void writeEntries(const QByteArray &locale, QIODevice &file, const KEntryMap &map, bool defaultGroup, bool &firstEntry);
};
#endif // KCONFIGINI_P_H
diff --git a/src/core/kconfigwatcher.cpp b/src/core/kconfigwatcher.cpp
index c5aa6205..3da2d535 100644
--- a/src/core/kconfigwatcher.cpp
+++ b/src/core/kconfigwatcher.cpp
@@ -16,17 +16,18 @@
#endif
#include <QDebug>
-#include <QThreadStorage>
#include <QHash>
+#include <QThreadStorage>
-class KConfigWatcherPrivate {
+class KConfigWatcherPrivate
+{
public:
KSharedConfig::Ptr m_config;
};
KConfigWatcher::Ptr KConfigWatcher::create(const KSharedConfig::Ptr &config)
{
- static QThreadStorage<QHash<KSharedConfig*, QWeakPointer<KConfigWatcher>>> watcherList;
+ static QThreadStorage<QHash<KSharedConfig *, QWeakPointer<KConfigWatcher>>> watcherList;
auto c = config.data();
KConfigWatcher::Ptr watcher;
@@ -43,9 +44,9 @@ KConfigWatcher::Ptr KConfigWatcher::create(const KSharedConfig::Ptr &config)
return watcherList.localData().value(c).toStrongRef();
}
-KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config):
- QObject (nullptr),
- d(new KConfigWatcherPrivate)
+KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config)
+ : QObject(nullptr)
+ , d(new KConfigWatcherPrivate)
{
Q_ASSERT(config);
#if KCONFIG_USE_DBUS
@@ -65,13 +66,13 @@ KConfigWatcher::KConfigWatcher(const KSharedConfig::Ptr &config):
watchedPaths << QStringLiteral("/kdeglobals");
}
- for(const QString &path: qAsConst(watchedPaths)) {
+ for (const QString &path : qAsConst(watchedPaths)) {
QDBusConnection::sessionBus().connect(QString(),
path,
QStringLiteral("org.kde.kconfig.notify"),
QStringLiteral("ConfigChanged"),
this,
- SLOT(onConfigChangeNotification(QHash<QString,QByteArrayList>)));
+ SLOT(onConfigChangeNotification(QHash<QString, QByteArrayList>)));
}
#else
qCWarning(KCONFIG_CORE_LOG) << "Use of KConfigWatcher without DBus support. You will not receive updates";
@@ -87,17 +88,16 @@ KSharedConfig::Ptr KConfigWatcher::config() const
void KConfigWatcher::onConfigChangeNotification(const QHash<QString, QByteArrayList> &changes)
{
- //should we ever need it we can determine the file changed with QDbusContext::message().path(), but it doesn't seem too useful
+ // should we ever need it we can determine the file changed with QDbusContext::message().path(), but it doesn't seem too useful
d->m_config->reparseConfiguration();
- for(auto it = changes.constBegin(); it != changes.constEnd(); it++) {
- KConfigGroup group = d->m_config->group(QString());//top level group
- const auto parts = it.key().split(QLatin1Char('\x1d')); //magic char, see KConfig
- for(const QString &groupName: parts) {
+ for (auto it = changes.constBegin(); it != changes.constEnd(); it++) {
+ KConfigGroup group = d->m_config->group(QString()); // top level group
+ const auto parts = it.key().split(QLatin1Char('\x1d')); // magic char, see KConfig
+ for (const QString &groupName : parts) {
group = group.group(groupName);
}
Q_EMIT configChanged(group, it.value());
}
}
-
diff --git a/src/core/kconfigwatcher.h b/src/core/kconfigwatcher.h
index 28576bb4..76418c9b 100644
--- a/src/core/kconfigwatcher.h
+++ b/src/core/kconfigwatcher.h
@@ -10,8 +10,8 @@
#include <QObject>
#include <QSharedPointer>
-#include <KSharedConfig>
#include <KConfigGroup>
+#include <KSharedConfig>
#include <kconfigcore_export.h>
@@ -23,7 +23,7 @@ class KConfigWatcherPrivate;
* Notifies when another client has updated this config file with the Notify flag set.
* @since 5.51
*/
-class KCONFIGCORE_EXPORT KConfigWatcher: public QObject
+class KCONFIGCORE_EXPORT KConfigWatcher : public QObject
{
Q_OBJECT
public:
diff --git a/src/core/kcoreconfigskeleton.cpp b/src/core/kcoreconfigskeleton.cpp
index d5af41e4..669e0ce5 100644
--- a/src/core/kcoreconfigskeleton.cpp
+++ b/src/core/kcoreconfigskeleton.cpp
@@ -18,16 +18,14 @@ static QString obscuredString(const QString &str)
for (int i = 0; i < str.length(); ++i)
// yes, no typo. can't encode ' ' or '!' because
// they're the unicode BOM. stupid scrambling. stupid.
- result += (unicode[ i ].unicode() <= 0x21) ? unicode[ i ]
- : QChar(0x1001F - unicode[ i ].unicode());
+ result += (unicode[i].unicode() <= 0x21) ? unicode[i] : QChar(0x1001F - unicode[i].unicode());
return result;
}
KConfigSkeletonItemPrivate::~KConfigSkeletonItemPrivate() = default;
-KConfigSkeletonItem::KConfigSkeletonItem(const QString &_group,
- const QString &_key)
+KConfigSkeletonItem::KConfigSkeletonItem(const QString &_group, const QString &_key)
: mGroup(_group)
, mKey(_key)
, d_ptr(new KConfigSkeletonItemPrivate)
@@ -179,19 +177,19 @@ void KConfigSkeletonItem::readImmutability(const KConfigGroup &group)
d->mIsImmutable = group.isEntryImmutable(mKey);
}
-void KConfigSkeletonItem::setIsDefaultImpl(const std::function<bool ()> &impl)
+void KConfigSkeletonItem::setIsDefaultImpl(const std::function<bool()> &impl)
{
Q_D(KConfigSkeletonItem);
d->mIsDefaultImpl = impl;
}
-void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function<bool ()> &impl)
+void KConfigSkeletonItem::setIsSaveNeededImpl(const std::function<bool()> &impl)
{
Q_D(KConfigSkeletonItem);
d->mIsSaveNeededImpl = impl;
}
-void KConfigSkeletonItem::setGetDefaultImpl(const std::function<QVariant ()> &impl)
+void KConfigSkeletonItem::setGetDefaultImpl(const std::function<QVariant()> &impl)
{
Q_D(KConfigSkeletonItem);
d->mGetDefaultImpl = impl;
@@ -276,18 +274,15 @@ void KPropertySkeletonItem::swapDefault()
}
}
-void KPropertySkeletonItem::setNotifyFunction(const std::function<void ()> &impl)
+void KPropertySkeletonItem::setNotifyFunction(const std::function<void()> &impl)
{
Q_D(KPropertySkeletonItem);
d->mNotifyFunction = impl;
}
-KCoreConfigSkeleton::ItemString::ItemString(const QString &_group, const QString &_key,
- QString &reference,
- const QString &defaultValue,
- Type type)
- : KConfigSkeletonGenericItem<QString>(_group, _key, reference, defaultValue),
- mType(type)
+KCoreConfigSkeleton::ItemString::ItemString(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue, Type type)
+ : KConfigSkeletonGenericItem<QString>(_group, _key, reference, defaultValue)
+ , mType(type)
{
}
@@ -341,23 +336,17 @@ QVariant KCoreConfigSkeleton::ItemString::property() const
return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemPassword::ItemPassword(const QString &_group, const QString &_key,
- QString &reference,
- const QString &defaultValue)
+KCoreConfigSkeleton::ItemPassword::ItemPassword(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue)
: ItemString(_group, _key, reference, defaultValue, Password)
{
}
-KCoreConfigSkeleton::ItemPath::ItemPath(const QString &_group, const QString &_key,
- QString &reference,
- const QString &defaultValue)
+KCoreConfigSkeleton::ItemPath::ItemPath(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue)
: ItemString(_group, _key, reference, defaultValue, Path)
{
}
-KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key,
- QUrl &reference,
- const QUrl &defaultValue)
+KCoreConfigSkeleton::ItemUrl::ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue)
: KConfigSkeletonGenericItem<QUrl>(_group, _key, reference, defaultValue)
{
}
@@ -400,10 +389,7 @@ QVariant KCoreConfigSkeleton::ItemUrl::property() const
return QVariant::fromValue<QUrl>(mReference);
}
-KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group,
- const QString &_key,
- QVariant &reference,
- const QVariant &defaultValue)
+KCoreConfigSkeleton::ItemProperty::ItemProperty(const QString &_group, const QString &_key, QVariant &reference, const QVariant &defaultValue)
: KConfigSkeletonGenericItem<QVariant>(_group, _key, reference, defaultValue)
{
}
@@ -424,7 +410,7 @@ void KCoreConfigSkeleton::ItemProperty::setProperty(const QVariant &p)
bool KCoreConfigSkeleton::ItemProperty::isEqual(const QVariant &v) const
{
- //this might cause problems if the QVariants are not of default types
+ // this might cause problems if the QVariants are not of default types
return mReference == v;
}
@@ -433,8 +419,7 @@ QVariant KCoreConfigSkeleton::ItemProperty::property() const
return mReference;
}
-KCoreConfigSkeleton::ItemBool::ItemBool(const QString &_group, const QString &_key,
- bool &reference, bool defaultValue)
+KCoreConfigSkeleton::ItemBool::ItemBool(const QString &_group, const QString &_key, bool &reference, bool defaultValue)
: KConfigSkeletonGenericItem<bool>(_group, _key, reference, defaultValue)
{
}
@@ -463,10 +448,10 @@ QVariant KCoreConfigSkeleton::ItemBool::property() const
return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemInt::ItemInt(const QString &_group, const QString &_key,
- qint32 &reference, qint32 defaultValue)
+KCoreConfigSkeleton::ItemInt::ItemInt(const QString &_group, const QString &_key, qint32 &reference, qint32 defaultValue)
: KConfigSkeletonGenericItem<qint32>(_group, _key, reference, defaultValue)
- , mHasMin(false), mHasMax(false)
+ , mHasMin(false)
+ , mHasMax(false)
{
}
@@ -528,10 +513,10 @@ void KCoreConfigSkeleton::ItemInt::setMaxValue(qint32 v)
mMax = v;
}
-KCoreConfigSkeleton::ItemLongLong::ItemLongLong(const QString &_group, const QString &_key,
- qint64 &reference, qint64 defaultValue)
+KCoreConfigSkeleton::ItemLongLong::ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, qint64 defaultValue)
: KConfigSkeletonGenericItem<qint64>(_group, _key, reference, defaultValue)
- , mHasMin(false), mHasMax(false)
+ , mHasMin(false)
+ , mHasMax(false)
{
}
@@ -606,11 +591,9 @@ void KCoreConfigSkeleton::ItemEnum::setValueForChoice(const QString &name, const
d_ptr->mValues.insert(name, value);
}
-KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key,
- qint32 &reference,
- const QList<Choice> &choices,
- qint32 defaultValue)
- : ItemInt(_group, _key, reference, defaultValue), mChoices(choices)
+KCoreConfigSkeleton::ItemEnum::ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList<Choice> &choices, qint32 defaultValue)
+ : ItemInt(_group, _key, reference, defaultValue)
+ , mChoices(choices)
{
}
@@ -623,8 +606,7 @@ void KCoreConfigSkeleton::ItemEnum::readConfig(KConfig *config)
int i = 0;
mReference = -1;
QString tmp = cg.readEntry(mKey, QString()).toLower();
- for (QList<Choice>::ConstIterator it = mChoices.constBegin();
- it != mChoices.constEnd(); ++it, ++i) {
+ for (QList<Choice>::ConstIterator it = mChoices.constBegin(); it != mChoices.constEnd(); ++it, ++i) {
QString choiceName = (*it).name;
if (valueForChoice(choiceName).toLower() == tmp) {
mReference = i;
@@ -665,11 +647,10 @@ QList<KCoreConfigSkeleton::ItemEnum::Choice> KCoreConfigSkeleton::ItemEnum::choi
return mChoices;
}
-KCoreConfigSkeleton::ItemUInt::ItemUInt(const QString &_group, const QString &_key,
- quint32 &reference,
- quint32 defaultValue)
+KCoreConfigSkeleton::ItemUInt::ItemUInt(const QString &_group, const QString &_key, quint32 &reference, quint32 defaultValue)
: KConfigSkeletonGenericItem<quint32>(_group, _key, reference, defaultValue)
- , mHasMin(false), mHasMax(false)
+ , mHasMin(false)
+ , mHasMax(false)
{
}
@@ -731,10 +712,10 @@ void KCoreConfigSkeleton::ItemUInt::setMaxValue(quint32 v)
mMax = v;
}
-KCoreConfigSkeleton::ItemULongLong::ItemULongLong(const QString &_group, const QString &_key,
- quint64 &reference, quint64 defaultValue)
+KCoreConfigSkeleton::ItemULongLong::ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, quint64 defaultValue)
: KConfigSkeletonGenericItem<quint64>(_group, _key, reference, defaultValue)
- , mHasMin(false), mHasMax(false)
+ , mHasMin(false)
+ , mHasMax(false)
{
}
@@ -796,10 +777,10 @@ void KCoreConfigSkeleton::ItemULongLong::setMaxValue(quint64 v)
mMax = v;
}
-KCoreConfigSkeleton::ItemDouble::ItemDouble(const QString &_group, const QString &_key,
- double &reference, double defaultValue)
+KCoreConfigSkeleton::ItemDouble::ItemDouble(const QString &_group, const QString &_key, double &reference, double defaultValue)
: KConfigSkeletonGenericItem<double>(_group, _key, reference, defaultValue)
- , mHasMin(false), mHasMax(false)
+ , mHasMin(false)
+ , mHasMax(false)
{
}
@@ -861,9 +842,7 @@ void KCoreConfigSkeleton::ItemDouble::setMaxValue(double v)
mMax = v;
}
-KCoreConfigSkeleton::ItemRect::ItemRect(const QString &_group, const QString &_key,
- QRect &reference,
- const QRect &defaultValue)
+KCoreConfigSkeleton::ItemRect::ItemRect(const QString &_group, const QString &_key, QRect &reference, const QRect &defaultValue)
: KConfigSkeletonGenericItem<QRect>(_group, _key, reference, defaultValue)
{
}
@@ -892,9 +871,7 @@ QVariant KCoreConfigSkeleton::ItemRect::property() const
return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemPoint::ItemPoint(const QString &_group, const QString &_key,
- QPoint &reference,
- const QPoint &defaultValue)
+KCoreConfigSkeleton::ItemPoint::ItemPoint(const QString &_group, const QString &_key, QPoint &reference, const QPoint &defaultValue)
: KConfigSkeletonGenericItem<QPoint>(_group, _key, reference, defaultValue)
{
}
@@ -923,9 +900,7 @@ QVariant KCoreConfigSkeleton::ItemPoint::property() const
return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemSize::ItemSize(const QString &_group, const QString &_key,
- QSize &reference,
- const QSize &defaultValue)
+KCoreConfigSkeleton::ItemSize::ItemSize(const QString &_group, const QString &_key, QSize &reference, const QSize &defaultValue)
: KConfigSkeletonGenericItem<QSize>(_group, _key, reference, defaultValue)
{
}
@@ -954,9 +929,7 @@ QVariant KCoreConfigSkeleton::ItemSize::property() const
return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemDateTime::ItemDateTime(const QString &_group, const QString &_key,
- QDateTime &reference,
- const QDateTime &defaultValue)
+KCoreConfigSkeleton::ItemDateTime::ItemDateTime(const QString &_group, const QString &_key, QDateTime &reference, const QDateTime &defaultValue)
: KConfigSkeletonGenericItem<QDateTime>(_group, _key, reference, defaultValue)
{
}
@@ -985,9 +958,7 @@ QVariant KCoreConfigSkeleton::ItemDateTime::property() const
return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemStringList::ItemStringList(const QString &_group, const QString &_key,
- QStringList &reference,
- const QStringList &defaultValue)
+KCoreConfigSkeleton::ItemStringList::ItemStringList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue)
: KConfigSkeletonGenericItem<QStringList>(_group, _key, reference, defaultValue)
{
}
@@ -1020,9 +991,7 @@ QVariant KCoreConfigSkeleton::ItemStringList::property() const
return QVariant(mReference);
}
-KCoreConfigSkeleton::ItemPathList::ItemPathList(const QString &_group, const QString &_key,
- QStringList &reference,
- const QStringList &defaultValue)
+KCoreConfigSkeleton::ItemPathList::ItemPathList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue)
: ItemStringList(_group, _key, reference, defaultValue)
{
}
@@ -1054,10 +1023,8 @@ void KCoreConfigSkeleton::ItemPathList::writeConfig(KConfig *config)
}
}
-KCoreConfigSkeleton::ItemUrlList::ItemUrlList(const QString &_group, const QString &_key,
- QList<QUrl> &reference,
- const QList<QUrl> &defaultValue)
- : KConfigSkeletonGenericItem<QList<QUrl> >(_group, _key, reference, defaultValue)
+KCoreConfigSkeleton::ItemUrlList::ItemUrlList(const QString &_group, const QString &_key, QList<QUrl> &reference, const QList<QUrl> &defaultValue)
+ : KConfigSkeletonGenericItem<QList<QUrl>>(_group, _key, reference, defaultValue)
{
}
@@ -1101,23 +1068,21 @@ void KCoreConfigSkeleton::ItemUrlList::writeConfig(KConfig *config)
void KCoreConfigSkeleton::ItemUrlList::setProperty(const QVariant &p)
{
- mReference = qvariant_cast<QList<QUrl> >(p);
+ mReference = qvariant_cast<QList<QUrl>>(p);
}
bool KCoreConfigSkeleton::ItemUrlList::isEqual(const QVariant &v) const
{
- return mReference == qvariant_cast<QList<QUrl> >(v);
+ return mReference == qvariant_cast<QList<QUrl>>(v);
}
QVariant KCoreConfigSkeleton::ItemUrlList::property() const
{
- return QVariant::fromValue<QList<QUrl> >(mReference);
+ return QVariant::fromValue<QList<QUrl>>(mReference);
}
-KCoreConfigSkeleton::ItemIntList::ItemIntList(const QString &_group, const QString &_key,
- QList<int> &reference,
- const QList<int> &defaultValue)
- : KConfigSkeletonGenericItem<QList<int> >(_group, _key, reference, defaultValue)
+KCoreConfigSkeleton::ItemIntList::ItemIntList(const QString &_group, const QString &_key, QList<int> &reference, const QList<int> &defaultValue)
+ : KConfigSkeletonGenericItem<QList<int>>(_group, _key, reference, defaultValue)
{
}
@@ -1136,35 +1101,35 @@ void KCoreConfigSkeleton::ItemIntList::readConfig(KConfig *config)
void KCoreConfigSkeleton::ItemIntList::setProperty(const QVariant &p)
{
- mReference = qvariant_cast< QList<int> >(p);
+ mReference = qvariant_cast<QList<int>>(p);
}
bool KCoreConfigSkeleton::ItemIntList::isEqual(const QVariant &v) const
{
- return mReference == qvariant_cast< QList<int> >(v);
+ return mReference == qvariant_cast<QList<int>>(v);
}
QVariant KCoreConfigSkeleton::ItemIntList::property() const
{
- return QVariant::fromValue< QList<int> >(mReference);
+ return QVariant::fromValue<QList<int>>(mReference);
}
-//static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; }
+// static int kCoreConfigSkeletionDebugArea() { static int s_area = KDebug::registerArea("kdecore (KConfigSkeleton)"); return s_area; }
KCoreConfigSkeleton::KCoreConfigSkeleton(const QString &configname, QObject *parent)
- : QObject(parent),
- d(new KCoreConfigSkeletonPrivate)
+ : QObject(parent)
+ , d(new KCoreConfigSkeletonPrivate)
{
- //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
+ // qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
d->mConfig = KSharedConfig::openConfig(configname, KConfig::FullConfig);
}
KCoreConfigSkeleton::KCoreConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent)
- : QObject(parent),
- d(new KCoreConfigSkeletonPrivate)
+ : QObject(parent)
+ , d(new KCoreConfigSkeletonPrivate)
{
- //qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
+ // qDebug() << "Creating KCoreConfigSkeleton (" << (void *)this << ")";
d->mConfig = std::move(pConfig);
}
@@ -1271,7 +1236,7 @@ bool KCoreConfigSkeleton::isSaveNeeded() const
bool KCoreConfigSkeleton::save()
{
- //qDebug();
+ // qDebug();
KConfigSkeletonItem::List::ConstIterator it;
for (it = d->mItems.constBegin(); it != d->mItems.constEnd(); ++it) {
(*it)->writeConfig(d->mConfig.data());
@@ -1330,8 +1295,7 @@ bool KCoreConfigSkeleton::usrWriteConfig()
void KCoreConfigSkeleton::addItem(KConfigSkeletonItem *item, const QString &name)
{
if (d->mItems.contains(item)) {
- if (item->name() == name ||
- (name.isEmpty() && item->name() == item->key())) {
+ if (item->name() == name || (name.isEmpty() && item->name() == item->key())) {
// nothing to do -> it is already in our collection
// and the name isn't changing
return;
@@ -1366,185 +1330,149 @@ void KCoreConfigSkeleton::clearItems()
qDeleteAll(items);
}
-KCoreConfigSkeleton::ItemString *KCoreConfigSkeleton::addItemString(const QString &name, QString &reference,
- const QString &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemString *KCoreConfigSkeleton::addItemString(const QString &name, QString &reference, const QString &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemString *item;
- item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key,
- reference, defaultValue,
- KCoreConfigSkeleton::ItemString::Normal);
+ item = new KCoreConfigSkeleton::ItemString(d->mCurrentGroup, key.isEmpty() ? name : key, reference, defaultValue, KCoreConfigSkeleton::ItemString::Normal);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemPassword *KCoreConfigSkeleton::addItemPassword(const QString &name, QString &reference,
- const QString &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemPassword *
+KCoreConfigSkeleton::addItemPassword(const QString &name, QString &reference, const QString &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemPassword *item;
- item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemPassword(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemPath *KCoreConfigSkeleton::addItemPath(const QString &name, QString &reference,
- const QString &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemPath *KCoreConfigSkeleton::addItemPath(const QString &name, QString &reference, const QString &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemPath *item;
- item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemPath(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemProperty *KCoreConfigSkeleton::addItemProperty(const QString &name, QVariant &reference,
- const QVariant &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemProperty *
+KCoreConfigSkeleton::addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemProperty *item;
- item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemProperty(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemBool *KCoreConfigSkeleton::addItemBool(const QString &name, bool &reference,
- bool defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemBool *KCoreConfigSkeleton::addItemBool(const QString &name, bool &reference, bool defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemBool *item;
- item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemBool(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemInt *KCoreConfigSkeleton::addItemInt(const QString &name, qint32 &reference,
- qint32 defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemInt *KCoreConfigSkeleton::addItemInt(const QString &name, qint32 &reference, qint32 defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemInt *item;
- item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemInt(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemUInt *KCoreConfigSkeleton::addItemUInt(const QString &name, quint32 &reference,
- quint32 defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemUInt *KCoreConfigSkeleton::addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemUInt *item;
- item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemUInt(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemLongLong(const QString &name, qint64 &reference,
- qint64 defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemLongLong *item;
- item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemLongLong(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
-KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemInt64(
- const QString &name,
- qint64 &reference,
- qint64 defaultValue,
- const QString &key)
+KCoreConfigSkeleton::ItemLongLong *KCoreConfigSkeleton::addItemInt64(const QString &name, qint64 &reference, qint64 defaultValue, const QString &key)
{
return addItemLongLong(name, reference, defaultValue, key);
}
#endif
-KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemULongLong(const QString &name, quint64 &reference,
- quint64 defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemULongLong *item;
- item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemULongLong(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
-KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemUInt64(
- const QString &name,
- quint64 &reference,
- quint64 defaultValue,
- const QString &key)
+KCoreConfigSkeleton::ItemULongLong *KCoreConfigSkeleton::addItemUInt64(const QString &name, quint64 &reference, quint64 defaultValue, const QString &key)
{
return addItemULongLong(name, reference, defaultValue, key);
}
#endif
-KCoreConfigSkeleton::ItemDouble *KCoreConfigSkeleton::addItemDouble(const QString &name, double &reference,
- double defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemDouble *KCoreConfigSkeleton::addItemDouble(const QString &name, double &reference, double defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemDouble *item;
- item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemDouble(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemRect *KCoreConfigSkeleton::addItemRect(const QString &name, QRect &reference,
- const QRect &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemRect *KCoreConfigSkeleton::addItemRect(const QString &name, QRect &reference, const QRect &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemRect *item;
- item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemRect(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemPoint *KCoreConfigSkeleton::addItemPoint(const QString &name, QPoint &reference,
- const QPoint &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemPoint *KCoreConfigSkeleton::addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemPoint *item;
- item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemPoint(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemSize *KCoreConfigSkeleton::addItemSize(const QString &name, QSize &reference,
- const QSize &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemSize *KCoreConfigSkeleton::addItemSize(const QString &name, QSize &reference, const QSize &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemSize *item;
- item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemSize(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemDateTime *KCoreConfigSkeleton::addItemDateTime(const QString &name, QDateTime &reference,
- const QDateTime &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemDateTime *
+KCoreConfigSkeleton::addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemDateTime *item;
- item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemDateTime(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemStringList *KCoreConfigSkeleton::addItemStringList(const QString &name, QStringList &reference,
- const QStringList &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemStringList *
+KCoreConfigSkeleton::addItemStringList(const QString &name, QStringList &reference, const QStringList &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemStringList *item;
- item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemStringList(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KCoreConfigSkeleton::ItemIntList *KCoreConfigSkeleton::addItemIntList(const QString &name, QList<int> &reference,
- const QList<int> &defaultValue, const QString &key)
+KCoreConfigSkeleton::ItemIntList *
+KCoreConfigSkeleton::addItemIntList(const QString &name, QList<int> &reference, const QList<int> &defaultValue, const QString &key)
{
KCoreConfigSkeleton::ItemIntList *item;
- item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KCoreConfigSkeleton::ItemIntList(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
@@ -1560,25 +1488,36 @@ KConfigSkeletonItem *KCoreConfigSkeleton::findItem(const QString &name) const
return d->mItemDict.value(name);
}
-KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem* item, QObject* object,
- KConfigCompilerSignallingItem::NotifyFunction targetFunction, quint64 userData)
- : KConfigSkeletonItem(item->group(), item->key()), mItem(item), mTargetFunction(targetFunction),
- mObject(object), mUserData(userData)
+KConfigCompilerSignallingItem::KConfigCompilerSignallingItem(KConfigSkeletonItem *item,
+ QObject *object,
+ KConfigCompilerSignallingItem::NotifyFunction targetFunction,
+ quint64 userData)
+ : KConfigSkeletonItem(item->group(), item->key())
+ , mItem(item)
+ , mTargetFunction(targetFunction)
+ , mObject(object)
+ , mUserData(userData)
{
Q_ASSERT(mTargetFunction);
Q_ASSERT(mItem);
Q_ASSERT(mObject);
- setIsDefaultImpl([this] { return mItem->isDefault(); });
- setIsSaveNeededImpl([this] { return mItem->isSaveNeeded(); });
- setGetDefaultImpl([this] {return mItem->getDefault(); });
+ setIsDefaultImpl([this] {
+ return mItem->isDefault();
+ });
+ setIsSaveNeededImpl([this] {
+ return mItem->isSaveNeeded();
+ });
+ setGetDefaultImpl([this] {
+ return mItem->getDefault();
+ });
}
KConfigCompilerSignallingItem::~KConfigCompilerSignallingItem()
{
}
-bool KConfigCompilerSignallingItem::isEqual(const QVariant& p) const
+bool KConfigCompilerSignallingItem::isEqual(const QVariant &p) const
{
return mItem->isEqual(p);
}
@@ -1588,11 +1527,11 @@ QVariant KConfigCompilerSignallingItem::property() const
return mItem->property();
}
-void KConfigCompilerSignallingItem::readConfig(KConfig* c)
+void KConfigCompilerSignallingItem::readConfig(KConfig *c)
{
QVariant oldValue = mItem->property();
mItem->readConfig(c);
- //readConfig() changes mIsImmutable, update it here as well
+ // readConfig() changes mIsImmutable, update it here as well
KConfigGroup cg = configGroup(c);
readImmutability(cg);
if (!mItem->isEqual(oldValue)) {
@@ -1600,15 +1539,15 @@ void KConfigCompilerSignallingItem::readConfig(KConfig* c)
}
}
-void KConfigCompilerSignallingItem::readDefault(KConfig* c)
+void KConfigCompilerSignallingItem::readDefault(KConfig *c)
{
mItem->readDefault(c);
- //readDefault() changes mIsImmutable, update it here as well
+ // readDefault() changes mIsImmutable, update it here as well
KConfigGroup cg = configGroup(c);
readImmutability(cg);
}
-void KConfigCompilerSignallingItem::writeConfig(KConfig* c)
+void KConfigCompilerSignallingItem::writeConfig(KConfig *c)
{
mItem->writeConfig(c);
}
@@ -1622,7 +1561,7 @@ void KConfigCompilerSignallingItem::setDefault()
}
}
-void KConfigCompilerSignallingItem::setProperty(const QVariant& p)
+void KConfigCompilerSignallingItem::setProperty(const QVariant &p)
{
if (!mItem->isEqual(p)) {
mItem->setProperty(p);
diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h
index e7b814e8..aafc417c 100644
--- a/src/core/kcoreconfigskeleton.h
+++ b/src/core/kcoreconfigskeleton.h
@@ -12,15 +12,15 @@
#include <kconfigcore_export.h>
-#include <ksharedconfig.h>
#include <kconfiggroup.h>
+#include <ksharedconfig.h>
#include <QDate>
#include <QHash>
#include <QRect>
#include <QStringList>
-#include <QVariant>
#include <QUrl>
+#include <QVariant>
class KCoreConfigSkeletonPrivate;
@@ -42,9 +42,9 @@ class KCONFIGCORE_EXPORT KConfigSkeletonItem
{
Q_DECLARE_PRIVATE(KConfigSkeletonItem)
public:
- typedef QList < KConfigSkeletonItem * >List;
- typedef QHash < QString, KConfigSkeletonItem * > Dict;
- typedef QHash < QString, KConfigSkeletonItem * >::Iterator DictIterator;
+ typedef QList<KConfigSkeletonItem *> List;
+ typedef QHash<QString, KConfigSkeletonItem *> Dict;
+ typedef QHash<QString, KConfigSkeletonItem *>::Iterator DictIterator;
/**
* Constructor.
@@ -310,29 +310,35 @@ public:
* Set a notify function, it will be invoked when the value of the property changes.
* @since 5.68
*/
- void setNotifyFunction(const std::function<void ()> &impl);
+ void setNotifyFunction(const std::function<void()> &impl);
};
-
/**
* \class KConfigSkeletonGenericItem kcoreconfigskeleton.h <KConfigSkeletonGenericItem>
*/
-template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem
+template<typename T>
+class KConfigSkeletonGenericItem : public KConfigSkeletonItem
{
public:
/** @copydoc KConfigSkeletonItem(const QString&, const QString&)
@param reference The initial value to hold in the item
@param defaultValue The default value for the item
*/
- KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference,
- T defaultValue)
- : KConfigSkeletonItem(_group, _key), mReference(reference),
- mDefault(defaultValue), mLoadedValue(defaultValue)
+ KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, T defaultValue)
+ : KConfigSkeletonItem(_group, _key)
+ , mReference(reference)
+ , mDefault(defaultValue)
+ , mLoadedValue(defaultValue)
{
- setIsDefaultImpl([this] { return mReference == mDefault; });
- setIsSaveNeededImpl([this] { return mReference != mLoadedValue; });
- setGetDefaultImpl([this] { return QVariant::fromValue(mDefault); });
-
+ setIsDefaultImpl([this] {
+ return mReference == mDefault;
+ });
+ setIsSaveNeededImpl([this] {
+ return mReference != mLoadedValue;
+ });
+ setGetDefaultImpl([this] {
+ return QVariant::fromValue(mDefault);
+ });
}
/**
@@ -407,7 +413,7 @@ public:
}
protected:
- T &mReference; ///< Stores the value for this item
+ T &mReference; ///< Stores the value for this item
T mDefault; ///< The default value for this item
T mLoadedValue;
};
@@ -428,17 +434,16 @@ protected:
class KCONFIGCORE_EXPORT KConfigCompilerSignallingItem : public KConfigSkeletonItem
{
public:
- typedef void (QObject::* NotifyFunction)(quint64 arg);
- /**
- * Constructor.
- *
- * @param item the KConfigSkeletonItem to wrap
- * @param targetFunction the method to invoke whenever the value of @p item changes
- * @param object The object on which the method is invoked.
- * @param userData This data will be passed to @p targetFunction on every property change
- */
- KConfigCompilerSignallingItem(KConfigSkeletonItem *item, QObject* object,
- NotifyFunction targetFunction, quint64 userData);
+ typedef void (QObject::*NotifyFunction)(quint64 arg);
+ /**
+ * Constructor.
+ *
+ * @param item the KConfigSkeletonItem to wrap
+ * @param targetFunction the method to invoke whenever the value of @p item changes
+ * @param object The object on which the method is invoked.
+ * @param userData This data will be passed to @p targetFunction on every property change
+ */
+ KConfigCompilerSignallingItem(KConfigSkeletonItem *item, QObject *object, NotifyFunction targetFunction, quint64 userData);
~KConfigCompilerSignallingItem() override;
void readConfig(KConfig *) override;
@@ -466,14 +471,14 @@ private:
// call the pointer to member function using the strange ->* operator
(mObject->*mTargetFunction)(mUserData);
}
+
private:
QScopedPointer<KConfigSkeletonItem> mItem;
NotifyFunction mTargetFunction;
- QObject* mObject;
+ QObject *mObject;
quint64 mUserData;
};
-
/**
* \class KCoreConfigSkeleton kcoreconfigskeleton.h <KCoreConfigSkeleton>
*
@@ -540,7 +545,7 @@ public:
/**
* Class for handling a string preferences item.
*/
- class KCONFIGCORE_EXPORT ItemString: public KConfigSkeletonGenericItem < QString >
+ class KCONFIGCORE_EXPORT ItemString : public KConfigSkeletonGenericItem<QString>
{
public:
enum Type {
@@ -565,9 +570,10 @@ public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem
@param type The type of string held by the item
*/
- ItemString(const QString &_group, const QString &_key,
+ ItemString(const QString &_group,
+ const QString &_key,
QString &reference,
- const QString &defaultValue = QLatin1String(""), // NOT QString() !!
+ const QString &defaultValue = QLatin1String(""), // NOT QString() !!
Type type = Normal);
/** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */
@@ -592,39 +598,33 @@ public:
/**
* Class for handling a password preferences item.
*/
- class KCONFIGCORE_EXPORT ItemPassword: public ItemString
+ class KCONFIGCORE_EXPORT ItemPassword : public ItemString
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemPassword(const QString &_group, const QString &_key,
- QString &reference,
- const QString &defaultValue = QLatin1String("")); // NOT QString() !!
+ ItemPassword(const QString &_group, const QString &_key, QString &reference,
+ const QString &defaultValue = QLatin1String("")); // NOT QString() !!
};
/**
* Class for handling a path preferences item.
*/
- class KCONFIGCORE_EXPORT ItemPath: public ItemString
+ class KCONFIGCORE_EXPORT ItemPath : public ItemString
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemPath(const QString &_group, const QString &_key,
- QString &reference,
- const QString &defaultValue = QString());
+ ItemPath(const QString &_group, const QString &_key, QString &reference, const QString &defaultValue = QString());
};
/**
* Class for handling a url preferences item.
*/
- class KCONFIGCORE_EXPORT ItemUrl: public KConfigSkeletonGenericItem < QUrl >
+ class KCONFIGCORE_EXPORT ItemUrl : public KConfigSkeletonGenericItem<QUrl>
{
public:
-
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem
*/
- ItemUrl(const QString &_group, const QString &_key,
- QUrl &reference,
- const QUrl &defaultValue = QUrl());
+ ItemUrl(const QString &_group, const QString &_key, QUrl &reference, const QUrl &defaultValue = QUrl());
/** @copydoc KConfigSkeletonItem::writeConfig(KConfig*) */
void writeConfig(KConfig *config) override;
@@ -645,12 +645,11 @@ public:
/**
* Class for handling a QVariant preferences item.
*/
- class KCONFIGCORE_EXPORT ItemProperty: public KConfigSkeletonGenericItem < QVariant >
+ class KCONFIGCORE_EXPORT ItemProperty : public KConfigSkeletonGenericItem<QVariant>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemProperty(const QString &_group, const QString &_key,
- QVariant &reference, const QVariant &defaultValue = QVariant());
+ ItemProperty(const QString &_group, const QString &_key, QVariant &reference, const QVariant &defaultValue = QVariant());
void readConfig(KConfig *config) override;
void setProperty(const QVariant &p) override;
@@ -665,12 +664,11 @@ public:
/**
* Class for handling a bool preferences item.
*/
- class KCONFIGCORE_EXPORT ItemBool: public KConfigSkeletonGenericItem < bool >
+ class KCONFIGCORE_EXPORT ItemBool : public KConfigSkeletonGenericItem<bool>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemBool(const QString &_group, const QString &_key, bool &reference,
- bool defaultValue = true);
+ ItemBool(const QString &_group, const QString &_key, bool &reference, bool defaultValue = true);
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -688,12 +686,11 @@ public:
/**
* Class for handling a 32-bit integer preferences item.
*/
- class KCONFIGCORE_EXPORT ItemInt: public KConfigSkeletonGenericItem < qint32 >
+ class KCONFIGCORE_EXPORT ItemInt : public KConfigSkeletonGenericItem<qint32>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemInt(const QString &_group, const QString &_key, qint32 &reference,
- qint32 defaultValue = 0);
+ ItemInt(const QString &_group, const QString &_key, qint32 &reference, qint32 defaultValue = 0);
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -733,12 +730,11 @@ public:
/**
* Class for handling a 64-bit integer preferences item.
*/
- class KCONFIGCORE_EXPORT ItemLongLong: public KConfigSkeletonGenericItem < qint64 >
+ class KCONFIGCORE_EXPORT ItemLongLong : public KConfigSkeletonGenericItem<qint64>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemLongLong(const QString &_group, const QString &_key, qint64 &reference,
- qint64 defaultValue = 0);
+ ItemLongLong(const QString &_group, const QString &_key, qint64 &reference, qint64 defaultValue = 0);
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -777,7 +773,7 @@ public:
/**
* Class for handling enums.
*/
- class KCONFIGCORE_EXPORT ItemEnum: public ItemInt
+ class KCONFIGCORE_EXPORT ItemEnum : public ItemInt
{
public:
struct Choice {
@@ -790,8 +786,7 @@ public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem
@param choices The list of enums that can be stored in this item
*/
- ItemEnum(const QString &_group, const QString &_key, qint32 &reference,
- const QList<Choice> &choices, qint32 defaultValue = 0);
+ ItemEnum(const QString &_group, const QString &_key, qint32 &reference, const QList<Choice> &choices, qint32 defaultValue = 0);
QList<Choice> choices() const;
@@ -823,12 +818,11 @@ public:
/**
* Class for handling an unsigned 32-bit integer preferences item.
*/
- class KCONFIGCORE_EXPORT ItemUInt: public KConfigSkeletonGenericItem < quint32 >
+ class KCONFIGCORE_EXPORT ItemUInt : public KConfigSkeletonGenericItem<quint32>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemUInt(const QString &_group, const QString &_key,
- quint32 &reference, quint32 defaultValue = 0);
+ ItemUInt(const QString &_group, const QString &_key, quint32 &reference, quint32 defaultValue = 0);
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -864,12 +858,11 @@ public:
/**
* Class for handling unsigned 64-bit integer preferences item.
*/
- class KCONFIGCORE_EXPORT ItemULongLong: public KConfigSkeletonGenericItem < quint64 >
+ class KCONFIGCORE_EXPORT ItemULongLong : public KConfigSkeletonGenericItem<quint64>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemULongLong(const QString &_group, const QString &_key, quint64 &reference,
- quint64 defaultValue = 0);
+ ItemULongLong(const QString &_group, const QString &_key, quint64 &reference, quint64 defaultValue = 0);
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -908,12 +901,11 @@ public:
/**
* Class for handling a floating point preference item.
*/
- class KCONFIGCORE_EXPORT ItemDouble: public KConfigSkeletonGenericItem < double >
+ class KCONFIGCORE_EXPORT ItemDouble : public KConfigSkeletonGenericItem<double>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemDouble(const QString &_group, const QString &_key,
- double &reference, double defaultValue = 0);
+ ItemDouble(const QString &_group, const QString &_key, double &reference, double defaultValue = 0);
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -949,12 +941,11 @@ public:
/**
* Class for handling a QRect preferences item.
*/
- class KCONFIGCORE_EXPORT ItemRect: public KConfigSkeletonGenericItem < QRect >
+ class KCONFIGCORE_EXPORT ItemRect : public KConfigSkeletonGenericItem<QRect>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemRect(const QString &_group, const QString &_key, QRect &reference,
- const QRect &defaultValue = QRect());
+ ItemRect(const QString &_group, const QString &_key, QRect &reference, const QRect &defaultValue = QRect());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -972,12 +963,11 @@ public:
/**
* Class for handling a QPoint preferences item.
*/
- class KCONFIGCORE_EXPORT ItemPoint: public KConfigSkeletonGenericItem < QPoint >
+ class KCONFIGCORE_EXPORT ItemPoint : public KConfigSkeletonGenericItem<QPoint>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemPoint(const QString &_group, const QString &_key, QPoint &reference,
- const QPoint &defaultValue = QPoint());
+ ItemPoint(const QString &_group, const QString &_key, QPoint &reference, const QPoint &defaultValue = QPoint());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -995,12 +985,11 @@ public:
/**
* Class for handling a QSize preferences item.
*/
- class KCONFIGCORE_EXPORT ItemSize: public KConfigSkeletonGenericItem < QSize >
+ class KCONFIGCORE_EXPORT ItemSize : public KConfigSkeletonGenericItem<QSize>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemSize(const QString &_group, const QString &_key, QSize &reference,
- const QSize &defaultValue = QSize());
+ ItemSize(const QString &_group, const QString &_key, QSize &reference, const QSize &defaultValue = QSize());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -1018,13 +1007,11 @@ public:
/**
* Class for handling a QDateTime preferences item.
*/
- class KCONFIGCORE_EXPORT ItemDateTime: public KConfigSkeletonGenericItem < QDateTime >
+ class KCONFIGCORE_EXPORT ItemDateTime : public KConfigSkeletonGenericItem<QDateTime>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemDateTime(const QString &_group, const QString &_key,
- QDateTime &reference,
- const QDateTime &defaultValue = QDateTime());
+ ItemDateTime(const QString &_group, const QString &_key, QDateTime &reference, const QDateTime &defaultValue = QDateTime());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -1042,13 +1029,11 @@ public:
/**
* Class for handling a string list preferences item.
*/
- class KCONFIGCORE_EXPORT ItemStringList: public KConfigSkeletonGenericItem < QStringList >
+ class KCONFIGCORE_EXPORT ItemStringList : public KConfigSkeletonGenericItem<QStringList>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemStringList(const QString &_group, const QString &_key,
- QStringList &reference,
- const QStringList &defaultValue = QStringList());
+ ItemStringList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue = QStringList());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -1066,13 +1051,11 @@ public:
/**
* Class for handling a path list preferences item.
*/
- class KCONFIGCORE_EXPORT ItemPathList: public ItemStringList
+ class KCONFIGCORE_EXPORT ItemPathList : public ItemStringList
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemPathList(const QString &_group, const QString &_key,
- QStringList &reference,
- const QStringList &defaultValue = QStringList());
+ ItemPathList(const QString &_group, const QString &_key, QStringList &reference, const QStringList &defaultValue = QStringList());
/** @copydoc KConfigSkeletonItem::readConfig */
void readConfig(KConfig *config) override;
@@ -1083,13 +1066,11 @@ public:
/**
* Class for handling a url list preferences item.
*/
- class KCONFIGCORE_EXPORT ItemUrlList: public KConfigSkeletonGenericItem < QList<QUrl> >
+ class KCONFIGCORE_EXPORT ItemUrlList : public KConfigSkeletonGenericItem<QList<QUrl>>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemUrlList(const QString &_group, const QString &_key,
- QList<QUrl> &reference,
- const QList<QUrl> &defaultValue = QList<QUrl>());
+ ItemUrlList(const QString &_group, const QString &_key, QList<QUrl> &reference, const QList<QUrl> &defaultValue = QList<QUrl>());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -1110,13 +1091,11 @@ public:
/**
* Class for handling an integer list preferences item.
*/
- class KCONFIGCORE_EXPORT ItemIntList: public KConfigSkeletonGenericItem < QList < int > >
+ class KCONFIGCORE_EXPORT ItemIntList : public KConfigSkeletonGenericItem<QList<int>>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemIntList(const QString &_group, const QString &_key,
- QList < int > &reference,
- const QList < int > &defaultValue = QList < int >());
+ ItemIntList(const QString &_group, const QString &_key, QList<int> &reference, const QList<int> &defaultValue = QList<int>());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -1246,8 +1225,9 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemString *addItemString(const QString &name, QString &reference,
- const QString &defaultValue = QLatin1String(""), // NOT QString() !!
+ ItemString *addItemString(const QString &name,
+ QString &reference,
+ const QString &defaultValue = QLatin1String(""), // NOT QString() !!
const QString &key = QString());
/**
@@ -1263,9 +1243,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemPassword *addItemPassword(const QString &name, QString &reference,
- const QString &defaultValue = QLatin1String(""),
- const QString &key = QString());
+ ItemPassword *addItemPassword(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString());
/**
* Register a path item of type QString. The string value is interpreted
@@ -1280,9 +1258,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemPath *addItemPath(const QString &name, QString &reference,
- const QString &defaultValue = QLatin1String(""),
- const QString &key = QString());
+ ItemPath *addItemPath(const QString &name, QString &reference, const QString &defaultValue = QLatin1String(""), const QString &key = QString());
/**
* Register a property item of type QVariant. Note that only the following
@@ -1297,9 +1273,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemProperty *addItemProperty(const QString &name, QVariant &reference,
- const QVariant &defaultValue = QVariant(),
- const QString &key = QString());
+ ItemProperty *addItemProperty(const QString &name, QVariant &reference, const QVariant &defaultValue = QVariant(), const QString &key = QString());
/**
* Register an item of type bool.
*
@@ -1311,9 +1285,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemBool *addItemBool(const QString &name, bool &reference,
- bool defaultValue = false,
- const QString &key = QString());
+ ItemBool *addItemBool(const QString &name, bool &reference, bool defaultValue = false, const QString &key = QString());
/**
* Register an item of type qint32.
@@ -1326,8 +1298,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0,
- const QString &key = QString());
+ ItemInt *addItemInt(const QString &name, qint32 &reference, qint32 defaultValue = 0, const QString &key = QString());
/**
* Register an item of type quint32.
@@ -1340,9 +1311,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemUInt *addItemUInt(const QString &name, quint32 &reference,
- quint32 defaultValue = 0,
- const QString &key = QString());
+ ItemUInt *addItemUInt(const QString &name, quint32 &reference, quint32 defaultValue = 0, const QString &key = QString());
/**
* Register an item of type qint64.
@@ -1355,18 +1324,14 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemLongLong *addItemLongLong(const QString &name, qint64 &reference,
- qint64 defaultValue = 0,
- const QString &key = QString());
+ ItemLongLong *addItemLongLong(const QString &name, qint64 &reference, qint64 defaultValue = 0, const QString &key = QString());
#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
/**
* @deprecated Since 5.0, use addItemLongLong().
*/
KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemLongLong(...)")
- ItemLongLong *addItemInt64(const QString &name, qint64 &reference,
- qint64 defaultValue = 0,
- const QString &key = QString());
+ ItemLongLong *addItemInt64(const QString &name, qint64 &reference, qint64 defaultValue = 0, const QString &key = QString());
#endif
/**
@@ -1380,18 +1345,14 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemULongLong *addItemULongLong(const QString &name, quint64 &reference,
- quint64 defaultValue = 0,
- const QString &key = QString());
+ ItemULongLong *addItemULongLong(const QString &name, quint64 &reference, quint64 defaultValue = 0, const QString &key = QString());
#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
/**
* @deprecated Since 5.0, use addItemULongLong().
*/
KCONFIGCORE_DEPRECATED_VERSION(5, 0, "Use KCoreConfigSkeleton::addItemULongLong(...)")
- ItemULongLong *addItemUInt64(const QString &name, quint64 &reference,
- quint64 defaultValue = 0,
- const QString &key = QString());
+ ItemULongLong *addItemUInt64(const QString &name, quint64 &reference, quint64 defaultValue = 0, const QString &key = QString());
#endif
/**
@@ -1405,9 +1366,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemDouble *addItemDouble(const QString &name, double &reference,
- double defaultValue = 0.0,
- const QString &key = QString());
+ ItemDouble *addItemDouble(const QString &name, double &reference, double defaultValue = 0.0, const QString &key = QString());
/**
* Register an item of type QRect.
@@ -1420,9 +1379,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemRect *addItemRect(const QString &name, QRect &reference,
- const QRect &defaultValue = QRect(),
- const QString &key = QString());
+ ItemRect *addItemRect(const QString &name, QRect &reference, const QRect &defaultValue = QRect(), const QString &key = QString());
/**
* Register an item of type QPoint.
@@ -1435,9 +1392,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemPoint *addItemPoint(const QString &name, QPoint &reference,
- const QPoint &defaultValue = QPoint(),
- const QString &key = QString());
+ ItemPoint *addItemPoint(const QString &name, QPoint &reference, const QPoint &defaultValue = QPoint(), const QString &key = QString());
/**
* Register an item of type QSize.
@@ -1450,9 +1405,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemSize *addItemSize(const QString &name, QSize &reference,
- const QSize &defaultValue = QSize(),
- const QString &key = QString());
+ ItemSize *addItemSize(const QString &name, QSize &reference, const QSize &defaultValue = QSize(), const QString &key = QString());
/**
* Register an item of type QDateTime.
@@ -1465,9 +1418,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference,
- const QDateTime &defaultValue = QDateTime(),
- const QString &key = QString());
+ ItemDateTime *addItemDateTime(const QString &name, QDateTime &reference, const QDateTime &defaultValue = QDateTime(), const QString &key = QString());
/**
* Register an item of type QStringList.
@@ -1480,9 +1431,8 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemStringList *addItemStringList(const QString &name, QStringList &reference,
- const QStringList &defaultValue = QStringList(),
- const QString &key = QString());
+ ItemStringList *
+ addItemStringList(const QString &name, QStringList &reference, const QStringList &defaultValue = QStringList(), const QString &key = QString());
/**
* Register an item of type QList<int>.
@@ -1495,10 +1445,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemIntList *addItemIntList(const QString &name, QList < int > &reference,
- const QList < int > &defaultValue =
- QList < int >(),
- const QString &key = QString());
+ ItemIntList *addItemIntList(const QString &name, QList<int> &reference, const QList<int> &defaultValue = QList<int>(), const QString &key = QString());
/**
* Return the @ref KConfig object used for reading and writing the settings.
@@ -1623,7 +1570,7 @@ protected:
virtual bool usrSave();
#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
- /**
+ /**
* @deprecated since 5.0, override usrRead instead. This method is still called from usrRead
* for compatibility.
*/
@@ -1632,7 +1579,7 @@ protected:
#endif
#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 0)
- /**
+ /**
* @deprecated since 5.0, override usrSave instead. This method is still called from usrSave
* for compatibility.
*/
@@ -1643,7 +1590,6 @@ protected:
private:
KCoreConfigSkeletonPrivate *const d;
friend class KConfigSkeleton;
-
};
#endif
diff --git a/src/core/kcoreconfigskeleton_p.h b/src/core/kcoreconfigskeleton_p.h
index 006bd45f..d854cc43 100644
--- a/src/core/kcoreconfigskeleton_p.h
+++ b/src/core/kcoreconfigskeleton_p.h
@@ -15,8 +15,10 @@ class KCoreConfigSkeletonPrivate
{
public:
KCoreConfigSkeletonPrivate()
- : mCurrentGroup(QStringLiteral("No Group")), mUseDefaults(false)
- {}
+ : mCurrentGroup(QStringLiteral("No Group"))
+ , mUseDefaults(false)
+ {
+ }
~KCoreConfigSkeletonPrivate()
{
KConfigSkeletonItem::List::ConstIterator it;
@@ -40,7 +42,8 @@ public:
KConfigSkeletonItemPrivate()
: mIsImmutable(true)
, mWriteFlags(KConfigBase::Normal)
- {}
+ {
+ }
virtual ~KConfigSkeletonItemPrivate();
bool mIsImmutable; ///< Indicates this item is immutable
KConfigBase::WriteConfigFlags mWriteFlags; ///< The flags to pass to calls of writeEntry() and revertToDefault()
@@ -79,5 +82,4 @@ public:
std::function<void()> mNotifyFunction;
};
-
#endif
diff --git a/src/core/kdesktopfile.cpp b/src/core/kdesktopfile.cpp
index 0dccd2d2..d5029ffe 100644
--- a/src/core/kdesktopfile.cpp
+++ b/src/core/kdesktopfile.cpp
@@ -14,14 +14,14 @@
#include <QDir>
#include <QFileInfo>
-#include <QUrl>
#include <QStandardPaths>
+#include <QUrl>
#include "kauthorized.h"
+#include "kconfig_core_log_settings.h"
#include "kconfig_p.h"
#include "kconfiggroup.h"
#include "kconfigini_p.h"
-#include "kconfig_core_log_settings.h"
class KDesktopFilePrivate : public KConfigPrivate
{
@@ -71,9 +71,8 @@ QString KDesktopFile::locateLocal(const QString &path)
// Relative to config? (e.g. for autostart)
const QStringList lstGenericConfigLocation = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
// Iterate from the last item since some items may be subfolders of others.
- for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin();
- constIterator != lstGenericConfigLocation.crend();
- ++constIterator) {
+ for (QStringList::const_reverse_iterator constIterator = lstGenericConfigLocation.crbegin(); constIterator != lstGenericConfigLocation.crend();
+ ++constIterator) {
const QString &dir = (*constIterator);
if (path.startsWith(dir + plus)) {
relativePath = path.mid(dir.length() + 1);
@@ -102,16 +101,16 @@ bool KDesktopFile::isDesktopFile(const QString &path)
bool KDesktopFile::isAuthorizedDesktopFile(const QString &path)
{
if (path.isEmpty()) {
- return false; // Empty paths are not ok.
+ return false; // Empty paths are not ok.
}
if (QDir::isRelativePath(path)) {
- return true; // Relative paths are ok.
+ return true; // Relative paths are ok.
}
const QString realPath = QFileInfo(path).canonicalFilePath();
if (realPath.isEmpty()) {
- return false; // File doesn't exist.
+ return false; // File doesn't exist.
}
#ifndef Q_OS_WIN
@@ -284,9 +283,7 @@ bool KDesktopFile::tryExec() const
const QStringList list = d->desktopGroup.readEntry("X-KDE-AuthorizeAction", QStringList());
if (!list.isEmpty()) {
- for (QStringList::ConstIterator it = list.begin();
- it != list.end();
- ++it) {
+ for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
if (!KAuthorized::authorize((*it).trimmed())) {
return false;
}
@@ -314,24 +311,23 @@ bool KDesktopFile::tryExec() const
/**
* @return the filename as passed to the constructor.
*/
-//QString KDesktopFile::fileName() const { return backEnd->fileName(); }
+// QString KDesktopFile::fileName() const { return backEnd->fileName(); }
/**
* @return the resource type as passed to the constructor.
*/
-//QString
-//KDesktopFile::resource() const { return backEnd->resource(); }
+// QString
+// KDesktopFile::resource() const { return backEnd->resource(); }
#if KCONFIGCORE_BUILD_DEPRECATED_SINCE(5, 42)
-QStringList
-KDesktopFile::sortOrder() const
+QStringList KDesktopFile::sortOrder() const
{
Q_D(const KDesktopFile);
return d->desktopGroup.readXdgListEntry("SortOrder");
}
#endif
-//void KDesktopFile::virtual_hook( int id, void* data )
+// void KDesktopFile::virtual_hook( int id, void* data )
//{ KConfig::virtual_hook( id, data ); }
QString KDesktopFile::readDocPath() const
@@ -344,7 +340,7 @@ KDesktopFile *KDesktopFile::copyTo(const QString &file) const
{
KDesktopFile *config = new KDesktopFile(QString());
this->KConfig::copyTo(file, config);
-// config->setDesktopGroup();
+ // config->setDesktopGroup();
return config;
}
diff --git a/src/core/kdesktopfile.h b/src/core/kdesktopfile.h
index 4d817181..c98bf1bb 100644
--- a/src/core/kdesktopfile.h
+++ b/src/core/kdesktopfile.h
@@ -241,9 +241,8 @@ protected:
/** Virtual hook, used to add new "virtual" functions while maintaining
binary compatibility. Unused in this class.
*/
-// virtual void virtual_hook( int id, void* data );
+ // virtual void virtual_hook( int id, void* data );
private:
-
Q_DISABLE_COPY(KDesktopFile)
Q_DECLARE_PRIVATE(KDesktopFile)
diff --git a/src/core/kemailsettings.cpp b/src/core/kemailsettings.cpp
index ed4255b5..cfebe2a8 100644
--- a/src/core/kemailsettings.cpp
+++ b/src/core/kemailsettings.cpp
@@ -12,7 +12,10 @@
class KEMailSettingsPrivate
{
public:
- KEMailSettingsPrivate() : m_pConfig(nullptr) {}
+ KEMailSettingsPrivate()
+ : m_pConfig(nullptr)
+ {
+ }
~KEMailSettingsPrivate()
{
delete m_pConfig;
@@ -97,7 +100,7 @@ QString KEMailSettings::getSetting(KEMailSettings::Setting s) const
};
return QString();
}
-void KEMailSettings::setSetting(KEMailSettings::Setting s, const QString &v)
+void KEMailSettings::setSetting(KEMailSettings::Setting s, const QString &v)
{
KConfigGroup cg(p->m_pConfig, QLatin1String("PROFILE_") + p->m_sCurrentProfile);
switch (s) {
@@ -191,7 +194,6 @@ void KEMailSettings::setDefault(const QString &s)
p->m_pConfig->group("Defaults").writeEntry("Profile", s);
p->m_pConfig->sync();
p->m_sDefaultProfile = s;
-
}
void KEMailSettings::setProfile(const QString &s)
diff --git a/src/core/kemailsettings.h b/src/core/kemailsettings.h
index 30f9942c..eb701f8c 100644
--- a/src/core/kemailsettings.h
+++ b/src/core/kemailsettings.h
@@ -15,29 +15,29 @@
class KEMailSettingsPrivate;
/**
- * \class KEMailSettings kemailsettings.h <KEMailSettings>
- *
- * This is just a small class to facilitate accessing e-mail settings in
- * a sane way, and allowing any program to manage multiple e-mail
- * profiles effortlessly
- *
- * The default profile is automatically selected in the constructor.
- *
- * @author Alex Zepeda zipzippy@sonic.net
- **/
+ * \class KEMailSettings kemailsettings.h <KEMailSettings>
+ *
+ * This is just a small class to facilitate accessing e-mail settings in
+ * a sane way, and allowing any program to manage multiple e-mail
+ * profiles effortlessly
+ *
+ * The default profile is automatically selected in the constructor.
+ *
+ * @author Alex Zepeda zipzippy@sonic.net
+ **/
class KCONFIGCORE_EXPORT KEMailSettings
{
Q_DECLARE_TR_FUNCTIONS(KEMailSettings)
public:
/**
- * The list of settings that I thought of when I wrote this
- * class. Any extra settings thought of later can be accessed
- * easily with getExtendedSetting and setExtendedSetting.
- * @see getSetting()
- * @see setSetting()
- * @see getExtendedSetting()
- * @see setExtendedSetting()
- **/
+ * The list of settings that I thought of when I wrote this
+ * class. Any extra settings thought of later can be accessed
+ * easily with getExtendedSetting and setExtendedSetting.
+ * @see getSetting()
+ * @see setSetting()
+ * @see getExtendedSetting()
+ * @see setExtendedSetting()
+ **/
enum Setting {
ClientProgram,
ClientTerminal,
@@ -86,8 +86,8 @@ public:
};
/**
- * The various extensions allowed.
- **/
+ * The various extensions allowed.
+ **/
enum Extension {
POP3,
SMTP,
@@ -95,40 +95,40 @@ public:
};
/**
- * Default constructor, just sets things up and sets the default profile
- * as the current profile
- **/
+ * Default constructor, just sets things up and sets the default profile
+ * as the current profile
+ **/
KEMailSettings();
KEMailSettings(const KEMailSettings &) = delete;
- KEMailSettings& operator=(const KEMailSettings &) = delete;
+ KEMailSettings &operator=(const KEMailSettings &) = delete;
/**
- * Default destructor, nothing to see here.
- **/
+ * Default destructor, nothing to see here.
+ **/
~KEMailSettings();
/**
- * List of profiles available.
- * @return the list of profiles
- **/
+ * List of profiles available.
+ * @return the list of profiles
+ **/
QStringList profiles() const;
#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
/**
- * Returns the name of the current profile.
- * @returns what profile we're currently using
- * @deprecated Since 5.0
- **/
+ * Returns the name of the current profile.
+ * @returns what profile we're currently using
+ * @deprecated Since 5.0
+ **/
KCONFIGCORE_DEPRECATED_VERSION(5, 0, "API planned to be changed")
QString currentProfileName() const;
// see https://git.reviewboard.kde.org/r/111910/
#endif
/**
- * Change the current profile.
- * @param s the name of the new profile
- **/
+ * Change the current profile.
+ * @param s the name of the new profile
+ **/
void setProfile(const QString &s);
/**
@@ -138,25 +138,25 @@ public:
QString defaultProfileName() const;
/**
- * Sets a new default.
- * @param def the new default
- **/
+ * Sets a new default.
+ * @param def the new default
+ **/
void setDefault(const QString &def);
/**
- * Get one of the predefined "basic" settings.
- * @param s the setting to get
- * @return the value of the setting, or QString() if not
- * set
- **/
+ * Get one of the predefined "basic" settings.
+ * @param s the setting to get
+ * @return the value of the setting, or QString() if not
+ * set
+ **/
QString getSetting(KEMailSettings::Setting s) const;
/**
- * Set one of the predefined "basic" settings.
- * @param s the setting to set
- * @param v the new value of the setting, or QString() to
- * unset
- **/
+ * Set one of the predefined "basic" settings.
+ * @param s the setting to set
+ * @param v the new value of the setting, or QString() to
+ * unset
+ **/
void setSetting(KEMailSettings::Setting s, const QString &v);
private:
diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp
index cc6adeb9..98aa4c5e 100644
--- a/src/core/ksharedconfig.cpp
+++ b/src/core/ksharedconfig.cpp
@@ -7,9 +7,9 @@
*/
#include "ksharedconfig.h"
+#include "kconfig_p.h"
#include "kconfigbackend_p.h"
#include "kconfiggroup.h"
-#include "kconfig_p.h"
#include <QCoreApplication>
#include <QThread>
#include <QThreadStorage>
@@ -40,8 +40,8 @@ public:
};
static QThreadStorage<GlobalSharedConfigList *> s_storage;
-template <typename T>
-T * perThreadGlobalStatic()
+template<typename T>
+T *perThreadGlobalStatic()
{
if (!s_storage.hasLocalData()) {
s_storage.setLocalData(new T);
@@ -50,7 +50,10 @@ T * perThreadGlobalStatic()
}
// Q_GLOBAL_STATIC(GlobalSharedConfigList, globalSharedConfigList), but per thread:
-static GlobalSharedConfigList *globalSharedConfigList() { return perThreadGlobalStatic<GlobalSharedConfigList>(); }
+static GlobalSharedConfigList *globalSharedConfigList()
+{
+ return perThreadGlobalStatic<GlobalSharedConfigList>();
+}
void _k_globalMainConfigSync()
{
@@ -60,9 +63,7 @@ void _k_globalMainConfigSync()
}
}
-KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName,
- OpenFlags flags,
- QStandardPaths::StandardLocation resType)
+KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName, OpenFlags flags, QStandardPaths::StandardLocation resType)
{
QString fileName(_fileName);
GlobalSharedConfigList *list = globalSharedConfigList();
@@ -78,11 +79,9 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName,
}
for (auto *cfg : qAsConst(*list)) {
- if (cfg->name() == fileName &&
- cfg->d_ptr->openFlags == flags &&
- cfg->locationType() == resType
-// cfg->backend()->type() == backend
- ) {
+ if (cfg->name() == fileName && cfg->d_ptr->openFlags == flags && cfg->locationType() == resType
+ // cfg->backend()->type() == backend
+ ) {
return KSharedConfigPtr(cfg);
}
}
@@ -121,9 +120,7 @@ KSharedConfig::Ptr KSharedConfig::openStateConfig(const QString &_fileName)
return openConfig(fileName, SimpleConfig, QStandardPaths::AppDataLocation);
}
-KSharedConfig::KSharedConfig(const QString &fileName,
- OpenFlags flags,
- QStandardPaths::StandardLocation resType)
+KSharedConfig::KSharedConfig(const QString &fileName, OpenFlags flags, QStandardPaths::StandardLocation resType)
: KConfig(fileName, flags, resType)
{
globalSharedConfigList()->append(this);
diff --git a/src/core/ksharedconfig.h b/src/core/ksharedconfig.h
index be01401c..e23d17c6 100644
--- a/src/core/ksharedconfig.h
+++ b/src/core/ksharedconfig.h
@@ -9,8 +9,8 @@
#ifndef KSHAREDCONFIG_H
#define KSHAREDCONFIG_H
-#include <kconfig.h>
#include <QExplicitlySharedDataPointer>
+#include <kconfig.h>
/**
* \class KSharedConfig ksharedconfig.h <KSharedConfig>
@@ -28,7 +28,7 @@
* using reparseConfiguration after a manual change notification, just like you have
* to do between processes.
*/
-class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData //krazy:exclude=dpointer (only for refcounting)
+class KCONFIGCORE_EXPORT KSharedConfig : public KConfig, public QSharedData // krazy:exclude=dpointer (only for refcounting)
{
public:
typedef QExplicitlySharedDataPointer<KSharedConfig> Ptr;
@@ -58,9 +58,8 @@ public:
*
* @sa KConfig
*/
- static KSharedConfig::Ptr openConfig(const QString &fileName = QString(),
- OpenFlags mode = FullConfig,
- QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
+ static KSharedConfig::Ptr
+ openConfig(const QString &fileName = QString(), OpenFlags mode = FullConfig, QStandardPaths::StandardLocation type = QStandardPaths::GenericConfigLocation);
/**
* Creates a KSharedConfig object to manipulate a configuration file suitable
@@ -91,9 +90,7 @@ private:
KConfigGroup groupImpl(const QByteArray &aGroup) override;
const KConfigGroup groupImpl(const QByteArray &aGroup) const override;
- KSharedConfig(const QString &file, OpenFlags mode,
- QStandardPaths::StandardLocation resourceType);
-
+ KSharedConfig(const QString &file, OpenFlags mode, QStandardPaths::StandardLocation resourceType);
};
typedef KSharedConfig::Ptr KSharedConfigPtr;
diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp
index 96b042af..5fbdbfad 100644
--- a/src/gui/kconfiggroupgui.cpp
+++ b/src/gui/kconfiggroupgui.cpp
@@ -21,14 +21,11 @@
* @returns true if something was handled (even if output was set to clear or default)
* or false if nothing was handled (e.g., Core type)
*/
-static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input,
- QVariant &output)
+static bool readEntryGui(const QByteArray &data, const char *key, const QVariant &input, QVariant &output)
{
const auto errString = [&]() {
return QStringLiteral("\"%1\" - conversion from \"%3\" to %2 failed")
- .arg(QLatin1String(key),
- QLatin1String(QVariant::typeToName(input.type())),
- QLatin1String(data.constData()) );
+ .arg(QLatin1String(key), QLatin1String(QVariant::typeToName(input.type())), QLatin1String(data.constData()));
};
// set in case of failure
@@ -37,7 +34,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant
switch (static_cast<QMetaType::Type>(input.type())) {
case QMetaType::QColor: {
if (data.isEmpty() || data == "invalid") {
- output = QColor(); // return what was stored
+ output = QColor(); // return what was stored
return true;
} else if (data.at(0) == '#') {
QColor col;
@@ -59,7 +56,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant
if (count != 3 && count != 4) {
const QString formatError = QStringLiteral(" (wrong format: expected '%1' items, read '%2')");
qCritical() << qPrintable(errString()) << qPrintable(formatError.arg(QStringLiteral("3' or '4")).arg(count));
- return true; // return default
+ return true; // return default
}
int temp[4];
@@ -72,9 +69,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant
return true; // return default
}
if (j < 0 || j > 255) {
- static const char *const components[] = {
- "red", "green", "blue", "alpha"
- };
+ static const char *const components[] = {"red", "green", "blue", "alpha"};
const QString boundsError = QStringLiteral(" (bounds error: %1 component %2)");
qCritical() << qPrintable(errString())
<< qPrintable(boundsError.arg(QLatin1String(components[i])).arg(j < 0 ? QStringLiteral("< 0") : QStringLiteral("> 255")));
@@ -114,13 +109,13 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant
case QMetaType::QCursor:
case QMetaType::QSizePolicy:
case QMetaType::QPen:
- // we may want to handle these in the future
+ // we may want to handle these in the future
default:
break;
}
- return false; // not handled
+ return false; // not handled
}
/**
@@ -129,8 +124,7 @@ static bool readEntryGui(const QByteArray &data, const char *key, const QVariant
* @returns true if something was handled (even if an empty value was written)
* or false if nothing was handled (e.g., Core type)
*/
-static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop,
- KConfigGroup::WriteConfigFlags pFlags)
+static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &prop, KConfigGroup::WriteConfigFlags pFlags)
{
switch (static_cast<QMetaType::Type>(prop.type())) {
case QMetaType::QColor: {
@@ -161,10 +155,8 @@ static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &pro
// https://bugreports.qt.io/browse/QTBUG-63792
// https://bugs.kde.org/show_bug.cgi?id=378523
if (f.weight() == QFont::Normal
- && (f.styleName() == QLatin1String("Regular")
- || f.styleName() == QLatin1String("Normal")
- || f.styleName() == QLatin1String("Book")
- || f.styleName() == QLatin1String("Roman"))) {
+ && (f.styleName() == QLatin1String("Regular") || f.styleName() == QLatin1String("Normal") || f.styleName() == QLatin1String("Book")
+ || f.styleName() == QLatin1String("Roman"))) {
f.setStyleName(QString());
}
cg->writeEntry(key, f.toString().toUtf8(), pFlags);
@@ -194,7 +186,7 @@ static int initKConfigGroupGui()
{
_kde_internal_KConfigGroupGui.readEntryGui = readEntryGui;
_kde_internal_KConfigGroupGui.writeEntryGui = writeEntryGui;
- return 42; // because 42 is nicer than 1 or 0
+ return 42; // because 42 is nicer than 1 or 0
}
#ifdef Q_CONSTRUCTOR_FUNCTION
diff --git a/src/gui/kconfiggui.cpp b/src/gui/kconfiggui.cpp
index 1daeec45..938fbd93 100644
--- a/src/gui/kconfiggui.cpp
+++ b/src/gui/kconfiggui.cpp
@@ -13,9 +13,7 @@
static QString configName(const QString &id, const QString &key)
{
- return(QLatin1String("session/") + QGuiApplication::applicationName() +
- QLatin1Char('_') + id +
- QLatin1Char('_') + key);
+ return (QLatin1String("session/") + QGuiApplication::applicationName() + QLatin1Char('_') + id + QLatin1Char('_') + key);
}
static KConfig *s_sessionConfig = nullptr;
@@ -28,9 +26,7 @@ KConfig *KConfigGui::sessionConfig()
if (!hasSessionConfig() && qApp->isSessionRestored()) {
// create the default instance specific config object
// from applications' -session command line parameter
- s_sessionConfig = new KConfig(configName(qApp->sessionId(),
- qApp->sessionKey()),
- KConfig::SimpleConfig);
+ s_sessionConfig = new KConfig(configName(qApp->sessionId(), qApp->sessionKey()), KConfig::SimpleConfig);
}
return s_sessionConfig;
@@ -44,8 +40,7 @@ void KConfigGui::setSessionConfig(const QString &id, const QString &key)
}
// create a new instance specific config object from supplied id & key
- s_sessionConfig = new KConfig(configName(id, key),
- KConfig::SimpleConfig);
+ s_sessionConfig = new KConfig(configName(id, key), KConfig::SimpleConfig);
}
bool KConfigGui::hasSessionConfig()
diff --git a/src/gui/kconfigloader.cpp b/src/gui/kconfigloader.cpp
index 538a38ff..bc1751f4 100644
--- a/src/gui/kconfigloader.cpp
+++ b/src/gui/kconfigloader.cpp
@@ -27,8 +27,8 @@ void ConfigLoaderPrivate::parse(KConfigLoader *loader, QIODevice *xml)
}
ConfigLoaderHandler::ConfigLoaderHandler(KConfigLoader *config, ConfigLoaderPrivate *d)
- : m_config(config),
- d(d)
+ : m_config(config)
+ , d(d)
{
resetState();
}
@@ -86,7 +86,7 @@ bool ConfigLoaderHandler::startElement(const QStringRef &localName, const QXmlSt
for (const auto &attr : attrs) {
const QStringRef name = attr.name();
if (name.compare(QLatin1String("name"), Qt::CaseInsensitive) == 0) {
- //qDebug() << "set group to" << attrs.value(i);
+ // qDebug() << "set group to" << attrs.value(i);
group = attr.value().toString();
}
}
@@ -137,7 +137,7 @@ bool ConfigLoaderHandler::characters(const QStringRef &ch)
bool ConfigLoaderHandler::endElement(const QStringRef &localName)
{
-// qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName;
+ // qDebug() << "ConfigLoaderHandler::endElement(" << localName << qName;
const QStringRef tag = localName;
if (tag.compare(QLatin1String("entry"), Qt::CaseInsensitive) == 0) {
addItem();
@@ -189,22 +189,16 @@ void ConfigLoaderHandler::addItem()
} else if (m_type == QLatin1String("color")) {
item = m_config->addItemColor(m_name, *d->newColor(), QColor(m_default), m_key);
} else if (m_type == QLatin1String("datetime")) {
- item = m_config->addItemDateTime(m_name, *d->newDateTime(),
- QDateTime::fromString(m_default), m_key);
+ item = m_config->addItemDateTime(m_name, *d->newDateTime(), QDateTime::fromString(m_default), m_key);
} else if (m_type == QLatin1String("enum")) {
m_key = (m_key.isEmpty()) ? m_name : m_key;
- KConfigSkeleton::ItemEnum *enumItem =
- new KConfigSkeleton::ItemEnum(m_config->currentGroup(),
- m_key, *d->newInt(),
- m_enumChoices,
- m_default.toUInt());
+ KConfigSkeleton::ItemEnum *enumItem = new KConfigSkeleton::ItemEnum(m_config->currentGroup(), m_key, *d->newInt(), m_enumChoices, m_default.toUInt());
m_config->addItem(enumItem, m_name);
item = enumItem;
} else if (m_type == QLatin1String("font")) {
item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key);
} else if (m_type == QLatin1String("int")) {
- KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(),
- m_default.toInt(), m_key);
+ KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), m_default.toInt(), m_key);
if (m_haveMin) {
intItem->setMinValue(m_min);
@@ -222,13 +216,11 @@ void ConfigLoaderHandler::addItem()
} else if (m_type == QLatin1String("string")) {
item = m_config->addItemString(m_name, *d->newString(), m_default, m_key);
} else if (m_type == QLatin1String("stringlist")) {
- //FIXME: the split() is naive and will break on lists with ,'s in them
- //empty parts are not wanted in this case
- item = m_config->addItemStringList(m_name, *d->newStringList(),
- m_default.split(QLatin1Char(','), Qt::SkipEmptyParts), m_key);
+ // FIXME: the split() is naive and will break on lists with ,'s in them
+ // empty parts are not wanted in this case
+ item = m_config->addItemStringList(m_name, *d->newStringList(), m_default.split(QLatin1Char(','), Qt::SkipEmptyParts), m_key);
} else if (m_type == QLatin1String("uint")) {
- KConfigSkeleton::ItemUInt *uintItem =
- m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key);
+ KConfigSkeleton::ItemUInt *uintItem = m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key);
if (m_haveMin) {
uintItem->setMinValue(m_min);
}
@@ -238,15 +230,11 @@ void ConfigLoaderHandler::addItem()
item = uintItem;
} else if (m_type == QLatin1String("url")) {
m_key = (m_key.isEmpty()) ? m_name : m_key;
- KConfigSkeleton::ItemUrl *urlItem =
- new KConfigSkeleton::ItemUrl(m_config->currentGroup(),
- m_key, *d->newUrl(),
- QUrl::fromUserInput(m_default));
+ KConfigSkeleton::ItemUrl *urlItem = new KConfigSkeleton::ItemUrl(m_config->currentGroup(), m_key, *d->newUrl(), QUrl::fromUserInput(m_default));
m_config->addItem(urlItem, m_name);
item = urlItem;
} else if (m_type == QLatin1String("double")) {
- KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name,
- *d->newDouble(), m_default.toDouble(), m_key);
+ KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name, *d->newDouble(), m_default.toDouble(), m_key);
if (m_haveMin) {
doubleItem->setMinValue(m_min);
}
@@ -262,8 +250,7 @@ void ConfigLoaderHandler::addItem()
}
item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key);
} else if (m_type == QLatin1String("longlong")) {
- KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name,
- *d->newLongLong(), m_default.toLongLong(), m_key);
+ KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name, *d->newLongLong(), m_default.toLongLong(), m_key);
if (m_haveMin) {
longlongItem->setMinValue(m_min);
}
@@ -288,8 +275,7 @@ void ConfigLoaderHandler::addItem()
QRect defaultRect;
const QStringList tmpList = m_default.split(QLatin1Char(','));
if (tmpList.size() >= 4) {
- defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(),
- tmpList[2].toInt(), tmpList[3].toInt());
+ defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), tmpList[2].toInt(), tmpList[3].toInt());
}
item = m_config->addItemRect(m_name, *d->newRect(), defaultRect, m_key);
} else if (m_type == QLatin1String("size")) {
@@ -301,8 +287,7 @@ void ConfigLoaderHandler::addItem()
}
item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key);
} else if (m_type == QLatin1String("ulonglong")) {
- KConfigSkeleton::ItemULongLong *ulonglongItem =
- m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key);
+ KConfigSkeleton::ItemULongLong *ulonglongItem = m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key);
if (m_haveMin) {
ulonglongItem->setMinValue(m_min);
}
@@ -345,25 +330,25 @@ void ConfigLoaderHandler::resetState()
}
KConfigLoader::KConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent)
- : KConfigSkeleton(configFile, parent),
- d(new ConfigLoaderPrivate)
+ : KConfigSkeleton(configFile, parent)
+ , d(new ConfigLoaderPrivate)
{
d->parse(this, xml);
}
KConfigLoader::KConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent)
- : KConfigSkeleton(std::move(config), parent),
- d(new ConfigLoaderPrivate)
+ : KConfigSkeleton(std::move(config), parent)
+ , d(new ConfigLoaderPrivate)
{
d->parse(this, xml);
}
-//FIXME: obviously this is broken and should be using the group as the root,
+// FIXME: obviously this is broken and should be using the group as the root,
// but KConfigSkeleton does not currently support this. it will eventually though,
// at which point this can be addressed properly
KConfigLoader::KConfigLoader(const KConfigGroup &config, QIODevice *xml, QObject *parent)
- : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags(), config.config()->locationType()), parent),
- d(new ConfigLoaderPrivate)
+ : KConfigSkeleton(KSharedConfig::openConfig(config.config()->name(), config.config()->openFlags(), config.config()->locationType()), parent)
+ , d(new ConfigLoaderPrivate)
{
KConfigGroup group = config.parent();
d->baseGroup = config.name();
@@ -418,7 +403,7 @@ bool KConfigLoader::usrSave()
{
if (d->saveDefaults) {
const auto listItems = items();
- for (const auto& item : listItems) {
+ for (const auto &item : listItems) {
config()->group(item->group()).writeEntry(item->key(), "");
}
}
diff --git a/src/gui/kconfigloader.h b/src/gui/kconfigloader.h
index 2e97ccd8..e40b68cb 100644
--- a/src/gui/kconfigloader.h
+++ b/src/gui/kconfigloader.h
@@ -166,4 +166,4 @@ private:
ConfigLoaderPrivate *const d;
};
-#endif //multiple inclusion guard
+#endif // multiple inclusion guard
diff --git a/src/gui/kconfigloaderhandler_p.h b/src/gui/kconfigloaderhandler_p.h
index cf9b7081..bc199e0e 100644
--- a/src/gui/kconfigloaderhandler_p.h
+++ b/src/gui/kconfigloaderhandler_p.h
@@ -44,4 +44,3 @@ private:
};
#endif
-
diff --git a/src/gui/kconfigskeleton.cpp b/src/gui/kconfigskeleton.cpp
index 031c7fbb..c3881c3b 100644
--- a/src/gui/kconfigskeleton.cpp
+++ b/src/gui/kconfigskeleton.cpp
@@ -20,9 +20,7 @@ KConfigSkeleton::KConfigSkeleton(KSharedConfig::Ptr pConfig, QObject *parent)
{
}
-KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key,
- QColor &reference,
- const QColor &defaultValue)
+KConfigSkeleton::ItemColor::ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue)
: KConfigSkeletonGenericItem<QColor>(_group, _key, reference, defaultValue)
{
}
@@ -51,9 +49,7 @@ QVariant KConfigSkeleton::ItemColor::property() const
return QVariant(mReference);
}
-KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key,
- QFont &reference,
- const QFont &defaultValue)
+KConfigSkeleton::ItemFont::ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue)
: KConfigSkeletonGenericItem<QFont>(_group, _key, reference, defaultValue)
{
}
@@ -82,23 +78,18 @@ QVariant KConfigSkeleton::ItemFont::property() const
return QVariant(mReference);
}
-KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference,
- const QColor &defaultValue, const QString &key)
+KConfigSkeleton::ItemColor *KConfigSkeleton::addItemColor(const QString &name, QColor &reference, const QColor &defaultValue, const QString &key)
{
KConfigSkeleton::ItemColor *item;
- item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KConfigSkeleton::ItemColor(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference,
- const QFont &defaultValue, const QString &key)
+KConfigSkeleton::ItemFont *KConfigSkeleton::addItemFont(const QString &name, QFont &reference, const QFont &defaultValue, const QString &key)
{
KConfigSkeleton::ItemFont *item;
- item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key,
- reference, defaultValue);
+ item = new KConfigSkeleton::ItemFont(d->mCurrentGroup, key.isNull() ? name : key, reference, defaultValue);
addItem(item, name);
return item;
}
-
diff --git a/src/gui/kconfigskeleton.h b/src/gui/kconfigskeleton.h
index 8e88e8d8..3f0aec87 100644
--- a/src/gui/kconfigskeleton.h
+++ b/src/gui/kconfigskeleton.h
@@ -32,13 +32,11 @@ public:
/**
* Class for handling a color preferences item.
*/
- class KCONFIGGUI_EXPORT ItemColor: public KConfigSkeletonGenericItem < QColor >
+ class KCONFIGGUI_EXPORT ItemColor : public KConfigSkeletonGenericItem<QColor>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemColor(const QString &_group, const QString &_key,
- QColor &reference,
- const QColor &defaultValue = QColor(128, 128, 128));
+ ItemColor(const QString &_group, const QString &_key, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128));
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -56,12 +54,11 @@ public:
/**
* Class for handling a font preferences item.
*/
- class KCONFIGGUI_EXPORT ItemFont: public KConfigSkeletonGenericItem < QFont >
+ class KCONFIGGUI_EXPORT ItemFont : public KConfigSkeletonGenericItem<QFont>
{
public:
/** @copydoc KConfigSkeletonGenericItem::KConfigSkeletonGenericItem */
- ItemFont(const QString &_group, const QString &_key, QFont &reference,
- const QFont &defaultValue = QFont());
+ ItemFont(const QString &_group, const QString &_key, QFont &reference, const QFont &defaultValue = QFont());
/** @copydoc KConfigSkeletonItem::readConfig(KConfig*) */
void readConfig(KConfig *config) override;
@@ -103,9 +100,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemColor *addItemColor(const QString &name, QColor &reference,
- const QColor &defaultValue = QColor(128, 128, 128),
- const QString &key = QString());
+ ItemColor *addItemColor(const QString &name, QColor &reference, const QColor &defaultValue = QColor(128, 128, 128), const QString &key = QString());
/**
* Register an item of type QFont.
@@ -118,10 +113,7 @@ public:
* @param key Key used in config file. If key is null, name is used as key.
* @return The created item
*/
- ItemFont *addItemFont(const QString &name, QFont &reference,
- const QFont &defaultValue = QFont(),
- const QString &key = QString());
-
+ ItemFont *addItemFont(const QString &name, QFont &reference, const QFont &defaultValue = QFont(), const QString &key = QString());
};
#endif
diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp
index c55d71c3..ac8431df 100644
--- a/src/gui/kstandardshortcut.cpp
+++ b/src/gui/kstandardshortcut.cpp
@@ -19,7 +19,6 @@
namespace KStandardShortcut
{
-
struct KStandardShortcutInfo {
//! The standard shortcut id. @see StandardShortcut
StandardShortcut id;
@@ -32,7 +31,10 @@ struct KStandardShortcutInfo {
const char *name;
//! Localized label for user-visible display, including translation context.
- struct { const char *text; const char *context; } description;
+ struct {
+ const char *text;
+ const char *context;
+ } description;
//! The keys for this shortcut
int cutDefault, cutDefault2;
@@ -47,11 +49,11 @@ struct KStandardShortcutInfo {
Category category;
};
-#define CTRL(x) Qt::CTRL|Qt::Key_##x
-#define SHIFT(x) Qt::SHIFT|Qt::Key_##x
-#define CTRLSHIFT(x) Qt::CTRL|Qt::SHIFT|Qt::Key_##x
-#define ALT(x) Qt::ALT|Qt::Key_##x
-#define ALTSHIFT(x) Qt::ALT|Qt::SHIFT|Qt::Key_##x
+#define CTRL(x) Qt::CTRL | Qt::Key_##x
+#define SHIFT(x) Qt::SHIFT | Qt::Key_##x
+#define CTRLSHIFT(x) Qt::CTRL | Qt::SHIFT | Qt::Key_##x
+#define ALT(x) Qt::ALT | Qt::Key_##x
+#define ALTSHIFT(x) Qt::ALT | Qt::SHIFT | Qt::Key_##x
/** Array of predefined KStandardShortcutInfo objects, which cover all
the "standard" accelerators. Each enum value from StandardShortcut
@@ -60,129 +62,351 @@ struct KStandardShortcutInfo {
// STUFF WILL BREAK IF YOU DON'T READ THIS!!!
// Read the comments of the big enum in kstandardshortcut.h before you change anything!
static KStandardShortcutInfo g_infoStandardShortcut[] = {
-//Group File,
- { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory },
- { Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList<QKeySequence>(), false, Category::File },
- { New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList<QKeySequence>(), false, Category::File },
- { Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false, Category::File },
- { Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList<QKeySequence>(), false, Category::File },
- { Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList<QKeySequence>(), false, Category::File },
- { Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList<QKeySequence>(), false, Category::Navigation },
-
-//Group Edit
- { Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList<QKeySequence>(), false, Category::Edit },
- { Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList<QKeySequence>(), false, Category::Edit },
+ // Group File,
+ {AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory},
+ {Open, "Open", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open", "@action"), CTRL(O), 0, QList<QKeySequence>(), false, Category::File},
+ {New, "New", QT_TRANSLATE_NOOP3("KStandardShortcut", "New", "@action"), CTRL(N), 0, QList<QKeySequence>(), false, Category::File},
+ {Close, "Close", QT_TRANSLATE_NOOP3("KStandardShortcut", "Close", "@action"), CTRL(W), CTRL(Escape), QList<QKeySequence>(), false, Category::File},
+ {Save, "Save", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save", "@action"), CTRL(S), 0, QList<QKeySequence>(), false, Category::File},
+ {Print, "Print", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print", "@action"), CTRL(P), 0, QList<QKeySequence>(), false, Category::File},
+ {Quit, "Quit", QT_TRANSLATE_NOOP3("KStandardShortcut", "Quit", "@action"), CTRL(Q), 0, QList<QKeySequence>(), false, Category::Navigation},
+
+ // Group Edit
+ {Undo, "Undo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Undo", "@action"), CTRL(Z), 0, QList<QKeySequence>(), false, Category::Edit},
+ {Redo, "Redo", QT_TRANSLATE_NOOP3("KStandardShortcut", "Redo", "@action"), CTRLSHIFT(Z), 0, QList<QKeySequence>(), false, Category::Edit},
// Both "Cut" and "Delete" use Shift+Delete, but this is okay; see
// https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0
- { Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList<QKeySequence>(), false, Category::Edit },
- { Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList<QKeySequence>(), false, Category::Edit},
- { Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList<QKeySequence>(), false, Category::Edit },
- { PasteSelection, "Paste Selection", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"), CTRLSHIFT(Insert), 0, QList<QKeySequence>(), false, Category::Edit },
-
- { SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList<QKeySequence>(), false, Category::Edit },
- { Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList<QKeySequence>(), false, Category::Edit },
- { DeleteWordBack, "DeleteWordBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"), CTRL(Backspace), 0, QList<QKeySequence>(), false, Category::Edit },
- { DeleteWordForward, "DeleteWordForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"), CTRL(Delete), 0, QList<QKeySequence>(), false, Category::Edit },
-
- { Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList<QKeySequence>(), false, Category::Edit },
- { FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList<QKeySequence>(), false, Category::Edit },
- { FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList<QKeySequence>(), false, Category::Edit },
- { Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList<QKeySequence>(), false, Category::Edit },
-
-//Group Navigation
- { Home, "Home", QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"), ALT(Home), Qt::Key_HomePage, QList<QKeySequence>(), false, Category::Navigation },
- { Begin, "Begin", QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"), CTRL(Home), 0, QList<QKeySequence>(), false, Category::Navigation },
- { End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList<QKeySequence>(), false, Category::Navigation },
- { Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList<QKeySequence>(), false, Category::Navigation },
- { Next, "Next", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"), Qt::Key_PageDown, 0, QList<QKeySequence>(), false, Category::Navigation },
-
- { Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList<QKeySequence>(), false, Category::Navigation },
- { Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList<QKeySequence>(), false, Category::Navigation },
- { Forward, "Forward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"), ALT(Right), Qt::Key_Forward, QList<QKeySequence>(), false, Category::Navigation },
- { Reload, "Reload", QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"), Qt::Key_F5, Qt::Key_Refresh, QList<QKeySequence>(), false, Category::Navigation },
-
- { BeginningOfLine, "BeginningOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"), Qt::Key_Home, 0, QList<QKeySequence>(), false, Category::Navigation },
- { EndOfLine, "EndOfLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"), Qt::Key_End, 0, QList<QKeySequence>(), false, Category::Navigation },
- { GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList<QKeySequence>(), false, Category::Navigation },
- { BackwardWord, "BackwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"), CTRL(Left), 0, QList<QKeySequence>(), false, Category::Navigation },
- { ForwardWord, "ForwardWord", QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"), CTRL(Right), 0, QList<QKeySequence>(), false, Category::Navigation },
-
- { AddBookmark, "AddBookmark", QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"), CTRL(B), 0, QList<QKeySequence>(), false, Category::Navigation },
- { ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList<QKeySequence>(), false, Category::View },
- { ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList<QKeySequence>(), false, Category::View },
- { FullScreen, "FullScreen", QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"), CTRLSHIFT(F), 0, QList<QKeySequence>(), false, Category::View },
-
- { ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList<QKeySequence>(), false, Category::View },
- { TabNext, "Activate Next Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"), CTRL(PageDown), CTRL(BracketRight), QList<QKeySequence>(), false, Category::Navigation },
- { TabPrev, "Activate Previous Tab", QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"), CTRL(PageUp), CTRL(BracketLeft), QList<QKeySequence>(), false, Category::Navigation },
-
- //Group Help
- { Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList<QKeySequence>(), false, Category::Help },
- { WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList<QKeySequence>(), false, Category::Help },
-
-//Group TextCompletion
- { TextCompletion, "TextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"), CTRL(E), 0, QList<QKeySequence>(), false, Category::Edit },
- { PrevCompletion, "PrevCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"), CTRL(Up), 0, QList<QKeySequence>(), false, Category::Edit },
- { NextCompletion, "NextCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"), CTRL(Down), 0, QList<QKeySequence>(), false, Category::Edit },
- { SubstringCompletion, "SubstringCompletion", QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"), CTRL(T), 0, QList<QKeySequence>(), false, Category::Edit },
-
- { RotateUp, "RotateUp", QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"), Qt::Key_Up, 0, QList<QKeySequence>(), false, Category::Navigation },
- { RotateDown, "RotateDown", QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"), Qt::Key_Down, 0, QList<QKeySequence>(), false, Category::Navigation },
-
- { OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File },
- { SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList<QKeySequence>(), false, Category::File },
- { Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit },
- { PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File },
- { Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help },
- { Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit },
- { ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList<QKeySequence>(), false, Category::View },
- { FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View },
- { FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View },
- { FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View },
- { Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View },
- { Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation },
- { GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation },
- { DocumentBack, "DocumentBack", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"), ALTSHIFT(Left), 0, QList<QKeySequence>(), false, Category::Navigation },
- { DocumentForward, "DocumentForward", QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"), ALTSHIFT(Right), 0, QList<QKeySequence>(), false, Category::Navigation },
- { EditBookmarks, "EditBookmarks", QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation },
- { Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit },
- { ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View },
- { ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View },
+ {Cut, "Cut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Cut", "@action"), CTRL(X), SHIFT(Delete), QList<QKeySequence>(), false, Category::Edit},
+ {Copy, "Copy", QT_TRANSLATE_NOOP3("KStandardShortcut", "Copy", "@action"), CTRL(C), CTRL(Insert), QList<QKeySequence>(), false, Category::Edit},
+ {Paste, "Paste", QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste", "@action"), CTRL(V), SHIFT(Insert), QList<QKeySequence>(), false, Category::Edit},
+ {PasteSelection,
+ "Paste Selection",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Paste Selection", "@action"),
+ CTRLSHIFT(Insert),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Edit},
+
+ {SelectAll, "SelectAll", QT_TRANSLATE_NOOP3("KStandardShortcut", "Select All", "@action"), CTRL(A), 0, QList<QKeySequence>(), false, Category::Edit},
+ {Deselect, "Deselect", QT_TRANSLATE_NOOP3("KStandardShortcut", "Deselect", "@action"), CTRLSHIFT(A), 0, QList<QKeySequence>(), false, Category::Edit},
+ {DeleteWordBack,
+ "DeleteWordBack",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Backwards", "@action"),
+ CTRL(Backspace),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Edit},
+ {DeleteWordForward,
+ "DeleteWordForward",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete Word Forward", "@action"),
+ CTRL(Delete),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Edit},
+
+ {Find, "Find", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find", "@action"), CTRL(F), 0, QList<QKeySequence>(), false, Category::Edit},
+ {FindNext, "FindNext", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Next", "@action"), Qt::Key_F3, 0, QList<QKeySequence>(), false, Category::Edit},
+ {FindPrev, "FindPrev", QT_TRANSLATE_NOOP3("KStandardShortcut", "Find Prev", "@action"), SHIFT(F3), 0, QList<QKeySequence>(), false, Category::Edit},
+ {Replace, "Replace", QT_TRANSLATE_NOOP3("KStandardShortcut", "Replace", "@action"), CTRL(R), 0, QList<QKeySequence>(), false, Category::Edit},
+
+ // Group Navigation
+ {Home,
+ "Home",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Home", "@action Go to main page"),
+ ALT(Home),
+ Qt::Key_HomePage,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {Begin,
+ "Begin",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Begin", "@action Beginning of document"),
+ CTRL(Home),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {End, "End", QT_TRANSLATE_NOOP3("KStandardShortcut", "End", "@action End of document"), CTRL(End), 0, QList<QKeySequence>(), false, Category::Navigation},
+ {Prior, "Prior", QT_TRANSLATE_NOOP3("KStandardShortcut", "Prior", "@action"), Qt::Key_PageUp, 0, QList<QKeySequence>(), false, Category::Navigation},
+ {Next,
+ "Next",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Next", "@action Opposite to Prior"),
+ Qt::Key_PageDown,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+
+ {Up, "Up", QT_TRANSLATE_NOOP3("KStandardShortcut", "Up", "@action"), ALT(Up), 0, QList<QKeySequence>(), false, Category::Navigation},
+ {Back, "Back", QT_TRANSLATE_NOOP3("KStandardShortcut", "Back", "@action"), ALT(Left), Qt::Key_Back, QList<QKeySequence>(), false, Category::Navigation},
+ {Forward,
+ "Forward",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward", "@action"),
+ ALT(Right),
+ Qt::Key_Forward,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {Reload,
+ "Reload",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Reload", "@action"),
+ Qt::Key_F5,
+ Qt::Key_Refresh,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+
+ {BeginningOfLine,
+ "BeginningOfLine",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Beginning of Line", "@action"),
+ Qt::Key_Home,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {EndOfLine,
+ "EndOfLine",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "End of Line", "@action"),
+ Qt::Key_End,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {GotoLine, "GotoLine", QT_TRANSLATE_NOOP3("KStandardShortcut", "Go to Line", "@action"), CTRL(G), 0, QList<QKeySequence>(), false, Category::Navigation},
+ {BackwardWord,
+ "BackwardWord",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Backward Word", "@action"),
+ CTRL(Left),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {ForwardWord,
+ "ForwardWord",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Forward Word", "@action"),
+ CTRL(Right),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+
+ {AddBookmark,
+ "AddBookmark",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Add Bookmark", "@action"),
+ CTRL(B),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {ZoomIn, "ZoomIn", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom In", "@action"), CTRL(Plus), CTRL(Equal), QList<QKeySequence>(), false, Category::View},
+ {ZoomOut, "ZoomOut", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom Out", "@action"), CTRL(Minus), 0, QList<QKeySequence>(), false, Category::View},
+ {FullScreen,
+ "FullScreen",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Full Screen Mode", "@action"),
+ CTRLSHIFT(F),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::View},
+
+ {ShowMenubar, "ShowMenubar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Menu Bar", "@action"), CTRL(M), 0, QList<QKeySequence>(), false, Category::View},
+ {TabNext,
+ "Activate Next Tab",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Next Tab", "@action"),
+ CTRL(PageDown),
+ CTRL(BracketRight),
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {TabPrev,
+ "Activate Previous Tab",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Activate Previous Tab", "@action"),
+ CTRL(PageUp),
+ CTRL(BracketLeft),
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+
+ // Group Help
+ {Help, "Help", QT_TRANSLATE_NOOP3("KStandardShortcut", "Help", "@action"), Qt::Key_F1, 0, QList<QKeySequence>(), false, Category::Help},
+ {WhatsThis, "WhatsThis", QT_TRANSLATE_NOOP3("KStandardShortcut", "What's This", "@action"), SHIFT(F1), 0, QList<QKeySequence>(), false, Category::Help},
+
+ // Group TextCompletion
+ {TextCompletion,
+ "TextCompletion",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Text Completion", "@action"),
+ CTRL(E),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Edit},
+ {PrevCompletion,
+ "PrevCompletion",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Completion Match", "@action"),
+ CTRL(Up),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Edit},
+ {NextCompletion,
+ "NextCompletion",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Completion Match", "@action"),
+ CTRL(Down),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Edit},
+ {SubstringCompletion,
+ "SubstringCompletion",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Substring Completion", "@action"),
+ CTRL(T),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Edit},
+
+ {RotateUp,
+ "RotateUp",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Previous Item in List", "@action"),
+ Qt::Key_Up,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {RotateDown,
+ "RotateDown",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Next Item in List", "@action"),
+ Qt::Key_Down,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+
+ {OpenRecent, "OpenRecent", QT_TRANSLATE_NOOP3("KStandardShortcut", "Open Recent", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File},
+ {SaveAs, "SaveAs", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save As", "@action"), CTRLSHIFT(S), 0, QList<QKeySequence>(), false, Category::File},
+ {Revert, "Revert", QT_TRANSLATE_NOOP3("KStandardShortcut", "Revert", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit},
+ {PrintPreview, "PrintPreview", QT_TRANSLATE_NOOP3("KStandardShortcut", "Print Preview", "@action"), 0, 0, QList<QKeySequence>(), false, Category::File},
+ {Mail, "Mail", QT_TRANSLATE_NOOP3("KStandardShortcut", "Mail", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help},
+ {Clear, "Clear", QT_TRANSLATE_NOOP3("KStandardShortcut", "Clear", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit},
+ {ActualSize, "ActualSize", QT_TRANSLATE_NOOP3("KStandardShortcut", "Actual Size", "@action"), CTRL(0), 0, QList<QKeySequence>(), false, Category::View},
+ {FitToPage, "FitToPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View},
+ {FitToWidth, "FitToWidth", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Width", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View},
+ {FitToHeight, "FitToHeight", QT_TRANSLATE_NOOP3("KStandardShortcut", "Fit To Height", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View},
+ {Zoom, "Zoom", QT_TRANSLATE_NOOP3("KStandardShortcut", "Zoom", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View},
+ {Goto, "Goto", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation},
+ {GotoPage, "GotoPage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Goto Page", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Navigation},
+ {DocumentBack,
+ "DocumentBack",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Back", "@action"),
+ ALTSHIFT(Left),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {DocumentForward,
+ "DocumentForward",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Document Forward", "@action"),
+ ALTSHIFT(Right),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {EditBookmarks,
+ "EditBookmarks",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Edit Bookmarks", "@action"),
+ 0,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Navigation},
+ {Spelling, "Spelling", QT_TRANSLATE_NOOP3("KStandardShortcut", "Spelling", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Edit},
+ {ShowToolbar, "ShowToolbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Toolbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View},
+ {ShowStatusbar, "ShowStatusbar", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show Statusbar", "@action"), 0, 0, QList<QKeySequence>(), false, Category::View},
#if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 39)
- { SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings },
+ {SaveOptions, "SaveOptions", QT_TRANSLATE_NOOP3("KStandardShortcut", "Save Options", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings},
#else
// dummy entry
- { SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory },
+ {SaveOptions_DEPRECATED_DO_NOT_USE, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory},
#endif
- { KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings },
- { Preferences, "Preferences", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"), CTRLSHIFT(Comma), 0, QList<QKeySequence>(), false, Category::Settings },
- { ConfigureToolbars, "ConfigureToolbars", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings },
- { ConfigureNotifications, "ConfigureNotifications", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings },
- { TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help },
- { ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help },
- { SwitchApplicationLanguage, "SwitchApplicationLanguage", QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings },
- { AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help },
- { AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help },
+ {KeyBindings, "KeyBindings", QT_TRANSLATE_NOOP3("KStandardShortcut", "Key Bindings", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Settings},
+ {Preferences,
+ "Preferences",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Application", "@action"),
+ CTRLSHIFT(Comma),
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Settings},
+ {ConfigureToolbars,
+ "ConfigureToolbars",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Toolbars", "@action"),
+ 0,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Settings},
+ {ConfigureNotifications,
+ "ConfigureNotifications",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Notifications", "@action"),
+ 0,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Settings},
+ {TipofDay, "TipofDay", QT_TRANSLATE_NOOP3("KStandardShortcut", "Tip Of Day", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help},
+ {ReportBug, "ReportBug", QT_TRANSLATE_NOOP3("KStandardShortcut", "Report Bug", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help},
+ {SwitchApplicationLanguage,
+ "SwitchApplicationLanguage",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Configure Language...", "@action"),
+ 0,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::Settings},
+ {AboutApp, "AboutApp", QT_TRANSLATE_NOOP3("KStandardShortcut", "About Application", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help},
+ {AboutKDE, "AboutKDE", QT_TRANSLATE_NOOP3("KStandardShortcut", "About KDE", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help},
// Both "Cut" and "Delete" use Shift+Delete, but this is okay; see
// https://commits.kde.org/kxmlgui/8eabbf6725386e716b7536c71a9181dfe5d959f0
- { DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList<QKeySequence>(), false, Category::File },
- { RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList<QKeySequence>(), false, Category::File },
- { MoveToTrash, "MoveToTrash", QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"), Qt::Key_Delete, 0, QList<QKeySequence>(), false, Category::File },
- { Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help },
- { ShowHideHiddenFiles, "ShowHideHiddenFiles", QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"), CTRL(H), ALT(Period), QList<QKeySequence>(), false, Category::View },
- { CreateFolder, "CreateFolder", QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"), Qt::Key_F10, 0, QList<QKeySequence>(), false, Category::File },
-
- //dummy entry to catch simple off-by-one errors. Insert new entries before this line.
- { AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory }
-};
+ {DeleteFile, "DeleteFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Delete", "@action"), SHIFT(Delete), 0, QList<QKeySequence>(), false, Category::File},
+ {RenameFile, "RenameFile", QT_TRANSLATE_NOOP3("KStandardShortcut", "Rename", "@action"), Qt::Key_F2, 0, QList<QKeySequence>(), false, Category::File},
+ {MoveToTrash,
+ "MoveToTrash",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Move to Trash", "@action"),
+ Qt::Key_Delete,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::File},
+ {Donate, "Donate", QT_TRANSLATE_NOOP3("KStandardShortcut", "Donate", "@action"), 0, 0, QList<QKeySequence>(), false, Category::Help},
+ {ShowHideHiddenFiles,
+ "ShowHideHiddenFiles",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Show/Hide Hidden Files", "@action"),
+ CTRL(H),
+ ALT(Period),
+ QList<QKeySequence>(),
+ false,
+ Category::View},
+ {CreateFolder,
+ "CreateFolder",
+ QT_TRANSLATE_NOOP3("KStandardShortcut", "Create Folder", "@action"),
+ Qt::Key_F10,
+ 0,
+ QList<QKeySequence>(),
+ false,
+ Category::File},
+
+ // dummy entry to catch simple off-by-one errors. Insert new entries before this line.
+ {AccelNone, nullptr, {nullptr, nullptr}, 0, 0, QList<QKeySequence>(), false, Category::InvalidCategory}};
/** Search for the KStandardShortcutInfo object associated with the given @p id.
Return a dummy entry with no name and an empty shortcut if @p id is invalid.
*/
static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id)
{
- if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) ||
- id < 0) {
+ if (id >= static_cast<int>(sizeof(g_infoStandardShortcut) / sizeof(KStandardShortcutInfo)) || id < 0) {
qWarning() << "KStandardShortcut: id not found!";
return &g_infoStandardShortcut[AccelNone];
} else {
@@ -190,7 +414,6 @@ static KStandardShortcutInfo *guardedStandardShortcutInfo(StandardShortcut id)
}
}
-
// Sanitize the list for duplicates. For some reason some
// people have kdeglobals entries like
// Close=Ctrl+W; Ctrl+Esc; Ctrl+W; Ctrl+Esc;
@@ -278,18 +501,16 @@ QString name(StandardShortcut id)
QString label(StandardShortcut id)
{
KStandardShortcutInfo *info = guardedStandardShortcutInfo(id);
- return QCoreApplication::translate("KStandardShortcut",
- info->description.text,
- info->description.context);
+ return QCoreApplication::translate("KStandardShortcut", info->description.text, info->description.context);
}
// TODO: Add psWhatsThis entry to KStandardShortcutInfo
QString whatsThis(StandardShortcut /*id*/)
{
-// KStandardShortcutInfo* info = guardedStandardShortcutInfo( id );
-// if( info && info->whatsThis )
-// return i18n(info->whatsThis);
-// else
+ // KStandardShortcutInfo* info = guardedStandardShortcutInfo( id );
+ // if( info && info->whatsThis )
+ // return i18n(info->whatsThis);
+ // else
return QString();
}
@@ -326,7 +547,6 @@ StandardShortcut find(const QKeySequence &seq)
return AccelNone;
}
-
#if KCONFIGGUI_BUILD_DEPRECATED_SINCE(5, 71)
StandardShortcut find(const char *keyName)
{
@@ -342,7 +562,6 @@ StandardShortcut find(const char *keyName)
StandardShortcut findByName(const QString &name)
{
-
for (const KStandardShortcutInfo &shortcutInfo : g_infoStandardShortcut) {
if (QString::fromLatin1(shortcutInfo.name) == name) {
return shortcutInfo.id;
diff --git a/src/gui/kstandardshortcut.h b/src/gui/kstandardshortcut.h
index 3757a593..6ffbeed6 100644
--- a/src/gui/kstandardshortcut.h
+++ b/src/gui/kstandardshortcut.h
@@ -9,8 +9,8 @@
#ifndef KSTANDARDSHORTCUT_H
#define KSTANDARDSHORTCUT_H
-#include <QString>
#include <QKeySequence>
+#include <QString>
#include <kconfiggui_export.h>
@@ -42,8 +42,8 @@ namespace KStandardShortcut
* Defines the identifier of all standard accelerators.
*/
enum StandardShortcut {
- //C++ requires that the value of an enum symbol be one more than the previous one.
- //This means that everything will be well-ordered from here on.
+ // C++ requires that the value of an enum symbol be one more than the previous one.
+ // This means that everything will be well-ordered from here on.
AccelNone = 0,
// File menu
Open, ///< Open file.
diff --git a/src/gui/kwindowconfig.cpp b/src/gui/kwindowconfig.cpp
index 4f3ac73a..a7697782 100644
--- a/src/gui/kwindowconfig.cpp
+++ b/src/gui/kwindowconfig.cpp
@@ -37,7 +37,7 @@ static QString allConnectedScreens()
static QString configFileString(const QRect &desk, const QString &key)
{
// We include resolution data to also save data on a per-resolution basis
- const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height());
+ const QString returnString = QStringLiteral("%1 %2 %3x%4").arg(allConnectedScreens()).arg(key).arg(desk.width()).arg(desk.height());
return returnString;
}
@@ -67,7 +67,6 @@ static QString windowYPositionString(const QRect &desk)
return configFileString(desk, QStringLiteral("YPosition"));
}
-
void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options)
{
// QWindow::screen() shouldn't return null, but it sometimes does due to bugs.
@@ -97,7 +96,6 @@ void KWindowConfig::saveWindowSize(const QWindow *window, KConfigGroup &config,
} else {
config.writeEntry(screenMaximizedString(desk), isMaximized, options);
}
-
}
void KWindowConfig::restoreWindowSize(QWindow *window, const KConfigGroup &config)
diff --git a/src/gui/kwindowconfig.h b/src/gui/kwindowconfig.h
index 4bb56e12..3c18c0a7 100644
--- a/src/gui/kwindowconfig.h
+++ b/src/gui/kwindowconfig.h
@@ -54,7 +54,7 @@ KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &confi
* @param config The config group to read from.
* @since 5.0.
*/
-KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config);
+KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config);
/**
* Saves the window's position either to the global or application config file.
@@ -81,6 +81,6 @@ KCONFIGGUI_EXPORT void saveWindowPosition(const QWindow *window, KConfigGroup &c
* @param config The config group to read from.
* @since 5.74
*/
-KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config);
+KCONFIGGUI_EXPORT void restoreWindowPosition(QWindow *window, const KConfigGroup &config);
}
#endif // KWINDOWCONFIG_H
diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp
index c2552c23..defe0b80 100644
--- a/src/kconf_update/kconf_update.cpp
+++ b/src/kconf_update/kconf_update.cpp
@@ -7,15 +7,15 @@
#include <config-kconf.h> // CMAKE_INSTALL_PREFIX
+#include <QCoreApplication>
#include <QDate>
+#include <QDebug>
+#include <QDir>
#include <QFile>
+#include <QProcess>
+#include <QTemporaryFile>
#include <QTextStream>
#include <QUrl>
-#include <QTemporaryFile>
-#include <QCoreApplication>
-#include <QDir>
-#include <QProcess>
-#include <QDebug>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QTextCodec>
@@ -24,17 +24,16 @@
#include <kconfig.h>
#include <kconfiggroup.h>
-#include <QStandardPaths>
-#include <QCommandLineParser>
#include <QCommandLineOption>
+#include <QCommandLineParser>
+#include <QStandardPaths>
#include "kconf_update_debug.h"
#include "kconfigutils.h"
// Convenience wrapper around qCDebug to prefix the output with metadata of
// the file.
-#define qCDebugFile(CATEGORY) \
- qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': "
+#define qCDebugFile(CATEGORY) qCDebug(CATEGORY) << m_currentFilename << ':' << m_lineCount << ":'" << m_line << "': "
class KonfUpdate
{
@@ -43,7 +42,7 @@ public:
~KonfUpdate();
KonfUpdate(const KonfUpdate &) = delete;
- KonfUpdate& operator=(const KonfUpdate &) = delete;
+ KonfUpdate &operator=(const KonfUpdate &) = delete;
QStringList findUpdateFiles(bool dirtyOnly);
@@ -65,8 +64,7 @@ public:
void gotScriptArguments(const QString &_arguments);
void resetOptions();
- void copyGroup(const KConfigBase *cfg1, const QString &group1,
- KConfigBase *cfg2, const QString &group2);
+ void copyGroup(const KConfigBase *cfg1, const QString &group1, KConfigBase *cfg2, const QString &group2);
void copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2);
void copyOrMoveKey(const QStringList &srcGroupPath, const QString &srcKey, const QStringList &dstGroupPath, const QString &dstKey);
void copyOrMoveGroup(const QStringList &srcGroupPath, const QStringList &dstGroupPath);
@@ -104,9 +102,14 @@ protected:
};
KonfUpdate::KonfUpdate(QCommandLineParser *parser)
- : m_oldConfig1(nullptr), m_oldConfig2(nullptr), m_newConfig(nullptr),
- m_bCopy(false), m_bOverwrite(false), m_textStream(nullptr),
- m_file(nullptr), m_lineCount(-1)
+ : m_oldConfig1(nullptr)
+ , m_oldConfig2(nullptr)
+ , m_newConfig(nullptr)
+ , m_bCopy(false)
+ , m_bOverwrite(false)
+ , m_textStream(nullptr)
+ , m_file(nullptr)
+ , m_lineCount(-1)
{
bool updateAll = false;
@@ -125,8 +128,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)
QLoggingCategory::setFilterRules(QLatin1String("%1.debug=true").arg(QLatin1String{KCONF_UPDATE_LOG().categoryName()}));
qDebug() << "Automatically enabled the debug logging category" << KCONF_UPDATE_LOG().categoryName();
if (!KCONF_UPDATE_LOG().isDebugEnabled()) {
- qWarning("The debug logging category %s needs to be enabled manually to get debug output",
- KCONF_UPDATE_LOG().categoryName());
+ qWarning("The debug logging category %s needs to be enabled manually to get debug output", KCONF_UPDATE_LOG().categoryName());
}
}
@@ -159,7 +161,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)
updateAll = true;
}
- for (const QString& file : qAsConst(updateFiles)) {
+ for (const QString &file : qAsConst(updateFiles)) {
updateFile(file);
}
@@ -167,9 +169,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)
cg.writeEntry("updateInfoAdded", true);
updateFiles = findUpdateFiles(false);
- for (QStringList::ConstIterator it = updateFiles.constBegin();
- it != updateFiles.constEnd();
- ++it) {
+ for (QStringList::ConstIterator it = updateFiles.constBegin(); it != updateFiles.constEnd(); ++it) {
checkFile(*it);
}
updateFiles.clear();
@@ -199,9 +199,7 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly)
KConfigGroup cg(m_config, fileName);
const QDateTime ctime = QDateTime::fromSecsSinceEpoch(cg.readEntry("ctime", 0u));
const QDateTime mtime = QDateTime::fromSecsSinceEpoch(cg.readEntry("mtime", 0u));
- if (!dirtyOnly ||
- (ctime.isValid() && ctime != info.birthTime()) ||
- mtime != info.lastModified()) {
+ if (!dirtyOnly || (ctime.isValid() && ctime != info.birthTime()) || mtime != info.lastModified()) {
result.append(file);
}
}
@@ -243,9 +241,7 @@ bool KonfUpdate::checkFile(const QString &filename)
}
if (line.startsWith(QLatin1String("Id="))) {
if (!foundVersion) {
- qCDebug(KCONF_UPDATE_LOG,
- "Missing 'Version=5', file '%s' will be skipped.",
- qUtf8Printable(filename));
+ qCDebug(KCONF_UPDATE_LOG, "Missing 'Version=5', file '%s' will be skipped.", qUtf8Printable(filename));
return true;
}
id = m_currentFilename + QLatin1Char{':'} + line.mid(3);
@@ -267,7 +263,7 @@ void KonfUpdate::checkGotFile(const QString &_file, const QString &id)
file = _file.mid(i + 1).trimmed();
}
-// qDebug("File %s, id %s", file.toLatin1().constData(), id.toLatin1().constData());
+ // qDebug("File %s, id %s", file.toLatin1().constData(), id.toLatin1().constData());
KConfig cfg(file, KConfig::SimpleConfig);
KConfigGroup cg = cfg.group("$Version");
@@ -334,9 +330,7 @@ bool KonfUpdate::updateFile(const QString &filename)
}
if (m_line.startsWith(QLatin1String("Id="))) {
if (!foundVersion) {
- qCDebug(KCONF_UPDATE_LOG,
- "Missing 'Version=5', file '%s' will be skipped.",
- qUtf8Printable(filename));
+ qCDebug(KCONF_UPDATE_LOG, "Missing 'Version=5', file '%s' will be skipped.", qUtf8Printable(filename));
break;
}
gotId(m_line.mid(3));
@@ -416,7 +410,7 @@ void KonfUpdate::gotId(const QString &_id)
KConfigGroup cg(m_config, m_currentFilename);
QStringList ids = cg.readEntry("done", QStringList());
if (ids.contains(_id) && !m_bUseConfigInfo) {
- //qDebug("Id '%s' was already in done-list", _id.toLatin1().constData());
+ // qDebug("Id '%s' was already in done-list", _id.toLatin1().constData());
m_skip = true;
return;
}
@@ -523,8 +517,8 @@ void KonfUpdate::gotFile(const QString &_file)
m_skipFile = false;
if (!m_oldFile.isEmpty()) { // if File= is specified, it doesn't exist, is empty or contains only kconf_update's [$Version] group, skip
if (m_oldConfig1 != nullptr
- && (m_oldConfig1->groupList().isEmpty()
- || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) {
+ && (m_oldConfig1->groupList().isEmpty()
+ || (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().at(0) == QLatin1String("$Version")))) {
qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": File" << m_oldFile << "does not exist or empty, skipping";
m_skipFile = true;
}
@@ -621,9 +615,7 @@ void KonfUpdate::copyOrMoveKey(const QStringList &srcGroupPath, const QString &s
}
// Delete old entry
- if (m_oldConfig2 == m_newConfig
- && srcGroupPath == dstGroupPath
- && srcKey == dstKey) {
+ if (m_oldConfig2 == m_newConfig && srcGroupPath == dstGroupPath && srcKey == dstKey) {
return; // Don't delete!
}
KConfigGroup srcCg2 = KConfigUtils::openGroup(m_oldConfig2, srcGroupPath);
@@ -695,8 +687,7 @@ void KonfUpdate::gotAllGroups()
}
const QStringList allGroups = m_oldConfig1->groupList();
- for (QStringList::ConstIterator it = allGroups.begin();
- it != allGroups.end(); ++it) {
+ for (QStringList::ConstIterator it = allGroups.begin(); it != allGroups.end(); ++it) {
m_oldGroup = QStringList() << *it;
m_newGroup = m_oldGroup;
gotAllKeys();
@@ -706,9 +697,7 @@ void KonfUpdate::gotAllGroups()
void KonfUpdate::gotOptions(const QString &_options)
{
const QStringList options = _options.split(QLatin1Char{','});
- for (QStringList::ConstIterator it = options.begin();
- it != options.end();
- ++it) {
+ for (QStringList::ConstIterator it = options.begin(); it != options.end(); ++it) {
if ((*it).toLower().trimmed() == QLatin1String("copy")) {
m_bCopy = true;
}
@@ -719,8 +708,7 @@ void KonfUpdate::gotOptions(const QString &_options)
}
}
-void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1,
- KConfigBase *cfg2, const QString &group2)
+void KonfUpdate::copyGroup(const KConfigBase *cfg1, const QString &group1, KConfigBase *cfg2, const QString &group2)
{
KConfigGroup cg2 = cfg2->group(group2);
copyGroup(cfg1->group(group1), cg2);
@@ -730,8 +718,7 @@ void KonfUpdate::copyGroup(const KConfigGroup &cg1, KConfigGroup &cg2)
{
// Copy keys
QMap<QString, QString> list = cg1.entryMap();
- for (QMap<QString, QString>::ConstIterator it = list.constBegin();
- it != list.constEnd(); ++it) {
+ for (QMap<QString, QString>::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it) {
if (m_bOverwrite || !cg2.hasKey(it.key())) {
cg2.writeEntry(it.key(), it.value());
}
@@ -822,7 +809,7 @@ void KonfUpdate::gotScript(const QString &_script)
proc.setStandardOutputFile(scriptOut.fileName());
if (m_oldConfig1) {
if (m_bDebugOutput) {
- //scriptIn.setAutoRemove(false);
+ // scriptIn.setAutoRemove(false);
qCDebug(KCONF_UPDATE_LOG) << "Script input stored in" << scriptIn.fileName();
}
KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig);
@@ -830,9 +817,7 @@ void KonfUpdate::gotScript(const QString &_script)
if (m_oldGroup.isEmpty()) {
// Write all entries to tmpFile;
const QStringList grpList = m_oldConfig1->groupList();
- for (QStringList::ConstIterator it = grpList.begin();
- it != grpList.end();
- ++it) {
+ for (QStringList::ConstIterator it = grpList.begin(); it != grpList.end(); ++it) {
copyGroup(m_oldConfig1, *it, &cfg, *it);
}
} else {
@@ -883,7 +868,7 @@ void KonfUpdate::gotScript(const QString &_script)
}
if (m_bDebugOutput) {
- //scriptOut.setAutoRemove(false);
+ // scriptOut.setAutoRemove(false);
qCDebug(KCONF_UPDATE_LOG) << "Script output stored in" << scriptOut.fileName();
QFile output(scriptOut.fileName());
if (output.open(QIODevice::ReadOnly)) {
@@ -966,9 +951,15 @@ int main(int argc, char **argv)
parser.setApplicationDescription(QCoreApplication::translate("main", "KDE Tool for updating user configuration files"));
parser.addHelpOption();
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("debug"), QCoreApplication::translate("main", "Keep output results from scripts")));
- parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("testmode"), QCoreApplication::translate("main", "For unit tests only: use test directories to stay away from the user's real files")));
- parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("check"), QCoreApplication::translate("main", "Check whether config file itself requires updating"), QStringLiteral("update-file")));
- parser.addPositionalArgument(QStringLiteral("files"), QCoreApplication::translate("main", "File(s) to read update instructions from"), QStringLiteral("[files...]"));
+ parser.addOption(
+ QCommandLineOption(QStringList() << QStringLiteral("testmode"),
+ QCoreApplication::translate("main", "For unit tests only: use test directories to stay away from the user's real files")));
+ parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("check"),
+ QCoreApplication::translate("main", "Check whether config file itself requires updating"),
+ QStringLiteral("update-file")));
+ parser.addPositionalArgument(QStringLiteral("files"),
+ QCoreApplication::translate("main", "File(s) to read update instructions from"),
+ QStringLiteral("[files...]"));
// TODO aboutData.addAuthor(ki18n("Waldo Bastian"), KLocalizedString(), "bastian@kde.org");
diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp
index 56e5cba7..49d5ac3c 100644
--- a/src/kconf_update/kconfigutils.cpp
+++ b/src/kconf_update/kconfigutils.cpp
@@ -13,7 +13,6 @@
namespace KConfigUtils
{
-
bool hasGroup(KConfig *config, const QStringList &lst)
{
KConfigGroup group = openGroup(config, lst);
diff --git a/src/kconf_update/kconfigutils.h b/src/kconf_update/kconfigutils.h
index 5b07c4fe..9a74d412 100644
--- a/src/kconf_update/kconfigutils.h
+++ b/src/kconf_update/kconfigutils.h
@@ -18,7 +18,6 @@ class KConfigGroup;
namespace KConfigUtils
{
-
bool hasGroup(KConfig *, const QStringList &);
KConfigGroup openGroup(KConfig *, const QStringList &);
diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp
index 3f308cbb..27a96488 100644
--- a/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp
+++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.cpp
@@ -13,21 +13,24 @@
#include "KConfigCodeGeneratorBase.h"
-#include <QLatin1Char>
#include <QFileInfo>
+#include <QLatin1Char>
-#include <ostream>
#include <QDebug>
+#include <ostream>
#include <iostream>
-KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(
- const QString &inputFile,
- const QString &baseDir,
- const QString &fileName,
- const KConfigParameters &parameters,
- ParseResult &parseResult)
- : parseResult(parseResult), m_inputFile(inputFile), m_baseDir(baseDir), m_fileName(fileName), m_cfg(parameters)
+KConfigCodeGeneratorBase::KConfigCodeGeneratorBase(const QString &inputFile,
+ const QString &baseDir,
+ const QString &fileName,
+ const KConfigParameters &parameters,
+ ParseResult &parseResult)
+ : parseResult(parseResult)
+ , m_inputFile(inputFile)
+ , m_baseDir(baseDir)
+ , m_fileName(fileName)
+ , m_cfg(parameters)
{
m_file.setFileName(m_fileName);
if (!m_file.open(QIODevice::WriteOnly)) {
@@ -54,7 +57,7 @@ void KConfigCodeGeneratorBase::save()
m_file.close();
}
-//TODO: Remove this weird logic and adapt the testcases
+// TODO: Remove this weird logic and adapt the testcases
void KConfigCodeGeneratorBase::indent()
{
if (m_indentLevel >= 4) {
@@ -102,7 +105,8 @@ void KConfigCodeGeneratorBase::endScope(ScopeFinalizer finalizer)
void KConfigCodeGeneratorBase::start()
{
const QString m_fileName = QFileInfo(m_inputFile).fileName();
- m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg" << ".\n";
+ m_stream << "// This file is generated by kconfig_compiler_kf5 from " << m_fileName << ".kcfg"
+ << ".\n";
m_stream << "// All changes you do to this file will be lost.\n";
}
@@ -214,7 +218,6 @@ void KConfigCodeGeneratorBase::createIfSetLogic(const CfgEntry *e, const QString
void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e)
{
-
// HACK: Don't open '{' manually, use startScope / endScope to automatically handle whitespace indentation.
if (!e->min.isEmpty()) {
if (e->min != QLatin1String("0") || !isUnsigned(e->type)) { // skip writing "if uint<0" (#187579)
@@ -254,8 +257,7 @@ void KConfigCodeGeneratorBase::memberMutatorBody(const CfgEntry *e)
if (signal.modify) {
m_stream << whitespace() << " Q_EMIT " << m_this << signal.name << "();\n";
} else {
- m_stream << whitespace() << " " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg)
- << " |= " << signalEnumName(signal.name) << ";\n";
+ m_stream << whitespace() << " " << m_this << varPath(QStringLiteral("settingsChanged"), m_cfg) << " |= " << signalEnumName(signal.name) << ";\n";
}
}
if (hasBody) {
diff --git a/src/kconfig_compiler/KConfigCodeGeneratorBase.h b/src/kconfig_compiler/KConfigCodeGeneratorBase.h
index e9d2a955..4a100518 100644
--- a/src/kconfig_compiler/KConfigCodeGeneratorBase.h
+++ b/src/kconfig_compiler/KConfigCodeGeneratorBase.h
@@ -14,28 +14,31 @@
#ifndef KCONFIGCODEGENERATORBASE_H
#define KCONFIGCODEGENERATORBASE_H
+#include <QFile>
#include <QString>
#include <QTextStream>
-#include <QFile>
#include <QVector>
-#include "KConfigParameters.h"
#include "KConfigCommonStructs.h"
+#include "KConfigParameters.h"
class CfgEntry;
struct ParseResult;
/* This class manages the base of writing a C - Based code */
-class KConfigCodeGeneratorBase {
+class KConfigCodeGeneratorBase
+{
public:
- enum ScopeFinalizer {None, Semicolon,};
-
- KConfigCodeGeneratorBase(
- const QString &inputFileName, // The kcfg file
- const QString &baseDir, // where we should store the generated file
- const QString &fileName, // the name of the generated file
- const KConfigParameters &parameters, // parameters passed to the generator
- ParseResult &parseResult // The pre processed configuration entries
+ enum ScopeFinalizer {
+ None,
+ Semicolon,
+ };
+
+ KConfigCodeGeneratorBase(const QString &inputFileName, // The kcfg file
+ const QString &baseDir, // where we should store the generated file
+ const QString &fileName, // the name of the generated file
+ const KConfigParameters &parameters, // parameters passed to the generator
+ ParseResult &parseResult // The pre processed configuration entries
);
virtual ~KConfigCodeGeneratorBase();
@@ -87,32 +90,53 @@ protected:
/* reduce the number of spaces for the indentation level */
void unindent();
- QString inputFile() const { return m_inputFile; }
- QString fileName() const { return m_fileName; }
- QString baseDir() const { return m_baseDir; }
- QString This() const { return m_this; }
- QString Const() const { return m_const; }
- KConfigParameters cfg() const { return m_cfg; }
+ QString inputFile() const
+ {
+ return m_inputFile;
+ }
+ QString fileName() const
+ {
+ return m_fileName;
+ }
+ QString baseDir() const
+ {
+ return m_baseDir;
+ }
+ QString This() const
+ {
+ return m_this;
+ }
+ QString Const() const
+ {
+ return m_const;
+ }
+ KConfigParameters cfg() const
+ {
+ return m_cfg;
+ }
// Can't be const.
- QTextStream& stream() { return m_stream; }
+ QTextStream &stream()
+ {
+ return m_stream;
+ }
// HACK: This needs to be accesible because the HeaderGenerator actually modifies
// it while running. Considering that this is a the result of the xml Parse, and not
// the result of generating code, I consider this to be quite wrong - but moving the
// changes away from the header generator only created more problems and I have to
// investigate more.
- ParseResult &parseResult; // the result of the parsed kcfg file
+ ParseResult &parseResult; // the result of the parsed kcfg file
private:
QString m_inputFile; // the base file name, input file is based on this.
- QString m_baseDir; // Where we are going to save the file
- QString m_fileName; // The file name
+ QString m_baseDir; // Where we are going to save the file
+ QString m_fileName; // The file name
KConfigParameters m_cfg; // The parameters passed via the kcfgc file
- QTextStream m_stream; // the stream that operates in the file to write data.
- QFile m_file; // The file handler.
+ QTextStream m_stream; // the stream that operates in the file to write data.
+ QFile m_file; // The file handler.
// Special access to `this->` and `const` thru the code.
QString m_this;
diff --git a/src/kconfig_compiler/KConfigCommonStructs.h b/src/kconfig_compiler/KConfigCommonStructs.h
index 8ed1d22f..43e981cb 100644
--- a/src/kconfig_compiler/KConfigCommonStructs.h
+++ b/src/kconfig_compiler/KConfigCommonStructs.h
@@ -14,20 +14,18 @@
#ifndef KCONFIGCOMMONSTRUCTS_H
#define KCONFIGCOMMONSTRUCTS_H
+#include <QList>
#include <QString>
#include <QVector>
-#include <QList>
#include "KConfigParameters.h"
-struct Param
-{
+struct Param {
QString name;
QString type;
};
-struct Signal
-{
+struct Signal {
QString name;
QString label;
QList<Param> arguments;
@@ -53,9 +51,13 @@ public:
class Choices
{
public:
- Choices() {}
+ Choices()
+ {
+ }
Choices(const QList<Choice> &d, const QString &n, const QString &p)
- : prefix(p), choices(d), mName(n)
+ : prefix(p)
+ , choices(d)
+ , mName(n)
{
int i = n.indexOf(QLatin1String("::"));
if (i >= 0) {
@@ -76,6 +78,7 @@ public:
{
return !mExternalQual.isEmpty();
}
+
private:
QString mName;
QString mExternalQual;
@@ -161,33 +164,18 @@ QString filenameOnly(const QString &path);
QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg);
-QString translatedString(
- const KConfigParameters &cfg,
- const QString &string,
- const QString &context = QString(),
- const QString &param = QString(),
- const QString &paramValue = QString());
+QString translatedString(const KConfigParameters &cfg,
+ const QString &string,
+ const QString &context = QString(),
+ const QString &param = QString(),
+ const QString &paramValue = QString());
// TODO: Sanitize those functions.
-QString newItem(
- const CfgEntry *entry,
- const QString &key,
- const QString &defaultValue,
- const KConfigParameters &cfg,
- const QString &param = QString());
-
-QString newInnerItem(
- const CfgEntry *entry,
- const QString &key,
- const QString &defaultValue,
- const KConfigParameters &cfg,
- const QString &param = QString());
-
-QString userTextsFunctions(
- const CfgEntry *e,
- const KConfigParameters &cfg,
- QString itemVarStr = QString(),
- const QString &i = QString());
+QString newItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString &param = QString());
+
+QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString &param = QString());
+
+QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QString itemVarStr = QString(), const QString &i = QString());
QString paramString(const QString &s, const CfgEntry *e, int i);
QString paramString(const QString &group, const QList<Param> &parameters);
diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.cpp b/src/kconfig_compiler/KConfigHeaderGenerator.cpp
index 7829ab67..d2c7e6cf 100644
--- a/src/kconfig_compiler/KConfigHeaderGenerator.cpp
+++ b/src/kconfig_compiler/KConfigHeaderGenerator.cpp
@@ -13,15 +13,11 @@
#include "KConfigHeaderGenerator.h"
-#include <QTextStream>
#include <QDebug>
+#include <QTextStream>
#include <iostream>
-KConfigHeaderGenerator::KConfigHeaderGenerator(
- const QString &inputFile,
- const QString &baseDir,
- const KConfigParameters &cfg,
- ParseResult &result)
+KConfigHeaderGenerator::KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &cfg, ParseResult &result)
: KConfigCodeGeneratorBase(inputFile, baseDir, baseDir + cfg.baseName + QLatin1Char('.') + cfg.headerExtension, cfg, result)
{
}
@@ -78,9 +74,7 @@ void KConfigHeaderGenerator::doClassDefinition()
}
// Member variables
- if (!cfg().memberVariables.isEmpty()
- && cfg().memberVariables != QLatin1String("private")
- && cfg().memberVariables != QLatin1String("dpointer")) {
+ if (!cfg().memberVariables.isEmpty() && cfg().memberVariables != QLatin1String("private") && cfg().memberVariables != QLatin1String("dpointer")) {
stream() << " " << cfg().memberVariables << ":\n";
}
@@ -212,7 +206,7 @@ void KConfigHeaderGenerator::implementEnums()
implementChoiceEnums(entry, choices);
implementValueEnums(entry, values);
}
- stream() << '\n';
+ stream() << '\n';
}
void KConfigHeaderGenerator::createSignals()
@@ -239,19 +233,15 @@ void KConfigHeaderGenerator::createSignals()
// a last comma, as it's valid c++.
for (int i = 0, end = parseResult.signalList.size(); i < end; i++) {
auto signal = parseResult.signalList.at(i);
- stream() << whitespace() << " " << signalEnumName(signal.name) << " = 0x"
- << Qt::hex
- << val;
- if (i != end-1) {
+ stream() << whitespace() << " " << signalEnumName(signal.name) << " = 0x" << Qt::hex << val;
+ if (i != end - 1) {
stream() << ",\n";
}
val <<= 1;
}
stream() << '\n';
- stream() << whitespace() << "};"
- << Qt::dec
- << "\n\n";
+ stream() << whitespace() << "};" << Qt::dec << "\n\n";
stream() << " Q_SIGNALS:";
for (const Signal &signal : qAsConst(parseResult.signalList)) {
@@ -364,7 +354,7 @@ void KConfigHeaderGenerator::createForwardDeclarations()
}
}
-void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString& returnType)
+void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QString &returnType)
{
if (!cfg().generateProperties) {
return;
@@ -377,8 +367,8 @@ void KConfigHeaderGenerator::createProperties(const CfgEntry *entry, const QStri
stream() << " WRITE " << setFunction(entry->name);
stream() << " NOTIFY " << signal;
- //If we have the modified signal, we'll also need
- //the changed signal as well
+ // If we have the modified signal, we'll also need
+ // the changed signal as well
Signal s;
s.name = signal;
s.modify = true;
@@ -417,12 +407,10 @@ void KConfigHeaderGenerator::createSetters(const CfgEntry *entry)
stream() << whitespace() << "void " << setFunction(entry->name) << "( ";
if (!entry->param.isEmpty()) {
- stream() <<cppType(entry->paramType) << " i, ";
+ stream() << cppType(entry->paramType) << " i, ";
}
- stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum")
- ? enumType(entry, cfg().globalEnums)
- : param(entry->type));
+ stream() << (cfg().useEnumTypes && entry->type == QLatin1String("Enum") ? enumType(entry, cfg().globalEnums) : param(entry->type));
stream() << " v )";
@@ -481,7 +469,7 @@ void KConfigHeaderGenerator::createImmutableGetters(const CfgEntry *entry)
stream() << whitespace() << "";
stream() << "bool " << immutableFunction(entry->name) << "(";
if (!entry->param.isEmpty()) {
- stream() << " " << cppType(entry->paramType)<< " i ";
+ stream() << " " << cppType(entry->paramType) << " i ";
}
stream() << ")" << Const();
// function body inline only if not using dpointer
@@ -506,11 +494,9 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt
return;
}
stream() << whitespace() << "/**\n";
- stream() << whitespace() << " Get Item object corresponding to " << entry->name << "()"
- << '\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() << "Item" << itemType(entry->type) << " *" << getFunction(entry->name) << "Item(";
if (!entry->param.isEmpty()) {
stream() << " " << cppType(entry->paramType) << " i ";
}
@@ -530,7 +516,7 @@ void KConfigHeaderGenerator::createItemAcessors(const CfgEntry *entry, const QSt
void KConfigHeaderGenerator::createDefaultValueMember(const CfgEntry *entry)
{
// Default value Accessor
- if (! ((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) {
+ if (!((cfg().allDefaultGetters || cfg().defaultGetters.contains(entry->name)) && !entry->defaultValue.isEmpty())) {
return;
}
stream() << whitespace() << "/**\n";
diff --git a/src/kconfig_compiler/KConfigHeaderGenerator.h b/src/kconfig_compiler/KConfigHeaderGenerator.h
index b93a47db..4c2e4561 100644
--- a/src/kconfig_compiler/KConfigHeaderGenerator.h
+++ b/src/kconfig_compiler/KConfigHeaderGenerator.h
@@ -17,23 +17,20 @@
#include "KConfigCodeGeneratorBase.h"
#include "KConfigCommonStructs.h"
-#include <QString>
#include <QList>
+#include <QString>
class KConfigParameters;
class CfgEntry;
class QTextStream;
struct ParseResult;
-class KConfigHeaderGenerator : public KConfigCodeGeneratorBase {
+class KConfigHeaderGenerator : public KConfigCodeGeneratorBase
+{
public:
- KConfigHeaderGenerator(
- const QString &inputFile,
- const QString &baseDir,
- const KConfigParameters &parameters,
- ParseResult &parseResult);
+ KConfigHeaderGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &parameters, ParseResult &parseResult);
- void start() override;
+ void start() override;
private:
void startHeaderGuards();
diff --git a/src/kconfig_compiler/KConfigParameters.h b/src/kconfig_compiler/KConfigParameters.h
index f8619b2a..153b68dd 100644
--- a/src/kconfig_compiler/KConfigParameters.h
+++ b/src/kconfig_compiler/KConfigParameters.h
@@ -33,14 +33,14 @@ public:
};
// These are read from the .kcfgc configuration file
- QString nameSpace; // The namespace for the class to be generated
- QString className; // The class name to be generated
- QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton)
+ QString nameSpace; // The namespace for the class to be generated
+ QString className; // The class name to be generated
+ QString inherits; // The class the generated class inherits (if empty, from KConfigSkeleton)
QString visibility;
bool parentInConstructor; // The class has the optional parent parameter in its constructor
bool forceStringFilename;
- bool singleton; // The class will be a singleton
- bool staticAccessors; // provide or not static accessors
+ bool singleton; // The class will be a singleton
+ bool staticAccessors; // provide or not static accessors
bool customAddons;
QString memberVariables;
QStringList headerIncludes;
diff --git a/src/kconfig_compiler/KConfigSourceGenerator.cpp b/src/kconfig_compiler/KConfigSourceGenerator.cpp
index 663a138f..ce6378cd 100644
--- a/src/kconfig_compiler/KConfigSourceGenerator.cpp
+++ b/src/kconfig_compiler/KConfigSourceGenerator.cpp
@@ -50,7 +50,7 @@ void KConfigSourceGenerator::createHeaders()
// TODO: Make addQuotes return a string instead of replacing it inplace.
addQuotes(headerName);
- addHeaders({ headerName });
+ addHeaders({headerName});
stream() << '\n';
addHeaders(cfg().sourceIncludes);
@@ -108,11 +108,10 @@ void KConfigSourceGenerator::createPrivateDPointerImplementation()
// Create Items.
for (const auto *entry : qAsConst(parseResult.entries)) {
- const QString declType = entry->signalList.isEmpty()
- ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type))
- : QStringLiteral("KConfigCompilerSignallingItem");
+ const QString declType = entry->signalList.isEmpty() ? QString(cfg().inherits + QStringLiteral("::Item") + itemType(entry->type))
+ : QStringLiteral("KConfigCompilerSignallingItem");
- stream() << " " << declType << " *" << itemVar( entry, cfg() );
+ stream() << " " << declType << " *" << itemVar(entry, cfg());
if (!entry->param.isEmpty()) {
stream() << QStringLiteral("[%1]").arg(entry->paramMax + 1);
}
@@ -163,7 +162,7 @@ void KConfigSourceGenerator::createSingletonImplementation()
stream() << "}\n\n";
if (parseResult.cfgFileNameArg) {
- auto instance = [this] (const QString &type, const QString &arg, bool isString) {
+ auto instance = [this](const QString &type, const QString &arg, bool isString) {
stream() << "void " << cfg().className << "::instance(" << type << " " << arg << ")\n";
stream() << "{\n";
stream() << " if (s_global" << cfg().className << "()->q) {\n";
@@ -215,8 +214,7 @@ void KConfigSourceGenerator::createConstructorParameterList()
stream() << (parseResult.parameters.isEmpty() ? "" : ",");
}
- for (QList<Param>::ConstIterator it = parseResult.parameters.constBegin();
- it != parseResult.parameters.constEnd(); ++it) {
+ for (QList<Param>::ConstIterator it = parseResult.parameters.constBegin(); it != parseResult.parameters.constEnd(); ++it) {
if (it != parseResult.parameters.constBegin()) {
stream() << ",";
}
@@ -229,7 +227,6 @@ void KConfigSourceGenerator::createConstructorParameterList()
}
stream() << " QObject *parent";
}
-
}
void KConfigSourceGenerator::createParentConstructorCall()
@@ -239,7 +236,7 @@ void KConfigSourceGenerator::createParentConstructorCall()
stream() << " QStringLiteral( \"" << parseResult.cfgFileName << "\" ";
}
if (parseResult.cfgFileNameArg) {
- if (! cfg().forceStringFilename) {
+ if (!cfg().forceStringFilename) {
stream() << " std::move( config ) ";
} else {
stream() << " config ";
@@ -275,19 +272,13 @@ void KConfigSourceGenerator::createEnums(const CfgEntry *entry)
stream() << " choice.name = QStringLiteral(\"" << choice.name << "\");\n";
if (cfg().setUserTexts) {
if (!choice.label.isEmpty()) {
- stream() << " choice.label = "
- << translatedString(cfg(), choice.label, choice.context)
- << ";\n";
+ stream() << " choice.label = " << translatedString(cfg(), choice.label, choice.context) << ";\n";
}
if (!choice.toolTip.isEmpty()) {
- stream() << " choice.toolTip = "
- << translatedString(cfg(), choice.toolTip, choice.context)
- << ";\n";
+ stream() << " choice.toolTip = " << translatedString(cfg(), choice.toolTip, choice.context) << ";\n";
}
if (!choice.whatsThis.isEmpty()) {
- stream() << " choice.whatsThis = "
- << translatedString(cfg(), choice.whatsThis, choice.context)
- << ";\n";
+ stream() << " choice.whatsThis = " << translatedString(cfg(), choice.whatsThis, choice.context) << ";\n";
}
}
stream() << " values" << entry->name << ".append( choice );\n";
@@ -300,12 +291,10 @@ void KConfigSourceGenerator::createNormalEntry(const CfgEntry *entry, const QStr
const QString itemVarStr = itemPath(entry, cfg());
const QString innerItemVarStr = innerItemVar(entry, cfg());
if (!entry->signalList.isEmpty()) {
- stream() << " " << innerItemVarStr << " = "
- << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n';
+ stream() << " " << innerItemVarStr << " = " << newInnerItem(entry, key, entry->defaultValue, cfg()) << '\n';
}
- stream() << " " << itemVarStr << " = "
- << newItem(entry, key, entry->defaultValue, cfg()) << '\n';
+ stream() << " " << itemVarStr << " = " << newItem(entry, key, entry->defaultValue, cfg()) << '\n';
if (!entry->min.isEmpty()) {
stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n";
@@ -353,19 +342,17 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt
const QString argBracket = QStringLiteral("[%1]").arg(i);
const QString innerItemVarStr = innerItemVar(entry, cfg()) + argBracket;
- const QString defaultStr = !entry->paramDefaultValues[i].isEmpty()
- ? entry->paramDefaultValues[i]
- : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i) : defaultValue(entry->type);
+ const QString defaultStr = !entry->paramDefaultValues[i].isEmpty() ? entry->paramDefaultValues[i]
+ : !entry->defaultValue.isEmpty() ? paramString(entry->defaultValue, entry, i)
+ : defaultValue(entry->type);
if (!entry->signalList.isEmpty()) {
- stream() << " " << innerItemVarStr << " = "
- << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n';
+ stream() << " " << innerItemVarStr << " = " << newInnerItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n';
}
const QString itemVarStr = itemPath(entry, cfg()) + argBracket;
- stream() << " " << itemVarStr << " = "
- << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n';
+ stream() << " " << itemVarStr << " = " << newItem(entry, paramString(key, entry, i), defaultStr, cfg(), argBracket) << '\n';
if (!entry->min.isEmpty()) {
stream() << " " << innerItemVarStr << "->setMinValue(" << entry->min << ");\n";
@@ -376,7 +363,8 @@ void KConfigSourceGenerator::createIndexedEntry(const CfgEntry *entry, const QSt
for (const CfgEntry::Choice &choice : qAsConst(entry->choices.choices)) {
if (!choice.val.isEmpty()) {
- stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val << "\" ));\n";
+ stream() << " " << itemVarStr << "->setValueForChoice(QStringLiteral( \"" << choice.name << "\" ), QStringLiteral( \"" << choice.val
+ << "\" ));\n";
}
}
@@ -419,14 +407,12 @@ void KConfigSourceGenerator::handleCurrentGroupChange(const CfgEntry *entry)
if (!entry->parentGroup.isEmpty()) {
QString parentGroup = QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W")));
if (!mConfigGroupList.contains(parentGroup)) {
- stream() << " KConfigGroup cg" << parentGroup
- << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n";
+ stream() << " KConfigGroup cg" << parentGroup << "(this->config(), " << paramString(entry->parentGroup, parseResult.parameters) << ");\n";
mConfigGroupList << parentGroup;
}
QString currentGroup = QString(mCurrentGroup).remove(QRegularExpression(QStringLiteral("\\W")));
if (!mConfigGroupList.contains(currentGroup)) {
- stream() << " KConfigGroup cg" << currentGroup
- << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W")))
+ stream() << " KConfigGroup cg" << currentGroup << " = cg" << QString(entry->parentGroup).remove(QRegularExpression(QStringLiteral("\\W")))
<< ".group(" << paramString(mCurrentGroup, parseResult.parameters) << ");\n";
mConfigGroupList << currentGroup;
}
@@ -470,8 +456,7 @@ void KConfigSourceGenerator::doConstructor()
// this cast to base-class pointer-to-member is valid C++
// https://stackoverflow.com/questions/4272909/is-it-safe-to-upcast-a-method-pointer-and-use-it-with-base-class-pointer/
stream() << " KConfigCompilerSignallingItem::NotifyFunction notifyFunction ="
- << " static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&"
- << cfg().className << "::itemChanged);\n";
+ << " static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&" << cfg().className << "::itemChanged);\n";
stream() << '\n';
}
@@ -524,7 +509,8 @@ void KConfigSourceGenerator::createGetterDPointerMode(const CfgEntry *entry)
void KConfigSourceGenerator::createImmutableGetterDPointerMode(const CfgEntry *entry)
{
stream() << whitespace() << "";
- stream() << "bool " << " " << immutableFunction(entry->name, cfg().className) << "(";
+ stream() << "bool "
+ << " " << immutableFunction(entry->name, cfg().className) << "(";
if (!entry->param.isEmpty()) {
stream() << " " << cppType(entry->paramType) << " i ";
}
@@ -569,8 +555,7 @@ void KConfigSourceGenerator::createItemGetterDPointerMode(const CfgEntry *entry)
return;
}
stream() << '\n';
- stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *"
- << getFunction(entry->name, cfg().className) << "Item(";
+ stream() << cfg().inherits << "::Item" << itemType(entry->type) << " *" << getFunction(entry->name, cfg().className) << "Item(";
if (!entry->param.isEmpty()) {
stream() << " " << cppType(entry->paramType) << " i ";
}
@@ -637,7 +622,8 @@ void KConfigSourceGenerator::createNonModifyingSignalsHelper()
if (!parseResult.hasNonModifySignals) {
return;
}
- stream() << "bool " << cfg().className << "::" << "usrSave()\n";
+ stream() << "bool " << cfg().className << "::"
+ << "usrSave()\n";
startScope();
stream() << " const bool res = " << cfg().inherits << "::usrSave();\n";
stream() << " if (!res) return false;\n\n";
@@ -685,7 +671,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler()
}
stream() << '\n';
- stream() << "void " << cfg().className << "::" << "itemChanged(quint64 flags) {\n";
+ stream() << "void " << cfg().className << "::"
+ << "itemChanged(quint64 flags) {\n";
if (parseResult.hasNonModifySignals)
stream() << " " << varPath(QStringLiteral("settingsChanged"), cfg()) << " |= flags;\n";
@@ -703,7 +690,8 @@ void KConfigSourceGenerator::createSignalFlagsHandler()
stream() << "}\n";
}
-void KConfigSourceGenerator::includeMoc() {
+void KConfigSourceGenerator::includeMoc()
+{
const QString mocFileName = cfg().baseName + QStringLiteral(".moc");
if (parseResult.signalList.count() || cfg().generateProperties) {
diff --git a/src/kconfig_compiler/KConfigSourceGenerator.h b/src/kconfig_compiler/KConfigSourceGenerator.h
index db2c8e72..4b3ef96c 100644
--- a/src/kconfig_compiler/KConfigSourceGenerator.h
+++ b/src/kconfig_compiler/KConfigSourceGenerator.h
@@ -17,21 +17,18 @@
#include "KConfigCodeGeneratorBase.h"
#include "KConfigCommonStructs.h"
-#include <QString>
#include <QList>
+#include <QString>
class KConfigParameters;
class CfgEntry;
class QTextStream;
struct ParseResult;
-class KConfigSourceGenerator : public KConfigCodeGeneratorBase {
+class KConfigSourceGenerator : public KConfigCodeGeneratorBase
+{
public:
- KConfigSourceGenerator(
- const QString &inputFile,
- const QString &baseDir,
- const KConfigParameters &parameters,
- ParseResult &parseResult);
+ KConfigSourceGenerator(const QString &inputFile, const QString &baseDir, const KConfigParameters &parameters, ParseResult &parseResult);
void start() override;
diff --git a/src/kconfig_compiler/KConfigXmlParser.cpp b/src/kconfig_compiler/KConfigXmlParser.cpp
index e1010564..97d61342 100644
--- a/src/kconfig_compiler/KConfigXmlParser.cpp
+++ b/src/kconfig_compiler/KConfigXmlParser.cpp
@@ -21,13 +21,15 @@
#include <QStringList>
#include <QTextStream>
#include <iostream>
-//TODO: Move preprocessDefault to Header / CPP implementation.
+// TODO: Move preprocessDefault to Header / CPP implementation.
// it makes no sense for a parser to process those values and generate code.
-static void preProcessDefault(QString &defaultValue, const QString &name,
+static void preProcessDefault(QString &defaultValue,
+ const QString &name,
const QString &type,
const CfgEntry::Choices &choices,
- QString &code, const KConfigParameters &cfg)
+ QString &code,
+ const KConfigParameters &cfg)
{
if (type == QLatin1String("String") && !defaultValue.isEmpty()) {
defaultValue = literalString(defaultValue);
@@ -64,8 +66,7 @@ static void preProcessDefault(QString &defaultValue, const QString &name,
defaultValue = QLatin1String("default") + name;
} else if (type == QLatin1String("Color") && !defaultValue.isEmpty()) {
- const QRegularExpression colorRe(QRegularExpression::anchoredPattern(
- QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?")));
+ const QRegularExpression colorRe(QRegularExpression::anchoredPattern(QStringLiteral("\\d+,\\s*\\d+,\\s*\\d+(,\\s*\\d+)?")));
if (colorRe.match(defaultValue).hasMatch()) {
defaultValue = QLatin1String("QColor( ") + defaultValue + QLatin1String(" )");
@@ -124,7 +125,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle
if (readEntry.param.isEmpty()) {
std::cerr << "Parameter must have a name: " << qPrintable(dumpNode(e)) << std::endl;
- exit (1);
+ exit(1);
}
if (readEntry.paramType.isEmpty()) {
@@ -157,7 +158,7 @@ void KConfigXmlParser::readParameterFromEntry(CfgEntry &readEntry, const QDomEle
readEntry.paramMax = readEntry.paramValues.count() - 1;
} else {
std::cerr << "Parameter '" << qPrintable(readEntry.param) << "' has type " << qPrintable(readEntry.paramType)
- << " but must be of type int, uint or Enum." << std::endl;
+ << " but must be of type int, uint or Enum." << std::endl;
exit(1);
}
}
@@ -190,7 +191,8 @@ void KConfigXmlParser::readChoicesFromEntry(CfgEntry &readEntry, const QDomEleme
if (choice.name.isEmpty()) {
std::cerr << "Tag <choice> requires attribute 'name'." << std::endl;
} else if (!choiceNameRegex.match(choice.name).hasMatch()) {
- std::cerr << "Tag <choice> attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name) << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl;
+ std::cerr << "Tag <choice> attribute 'name' must be compatible with Enum naming. name was '" << qPrintable(choice.name)
+ << "'. You can use attribute 'value' to pass any string as the choice value." << std::endl;
}
choice.val = e2.attribute(QStringLiteral("value"));
for (QDomElement e3 = e2.firstChildElement(); !e3.isNull(); e3 = e3.nextSiblingElement()) {
@@ -266,7 +268,7 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement
bool nameIsEmpty = readEntry.name.isEmpty();
if (nameIsEmpty && readEntry.key.isEmpty()) {
std::cerr << "Entry must have a name or a key: " << qPrintable(dumpNode(element)) << std::endl;
- exit (1);
+ exit(1);
}
if (readEntry.key.isEmpty()) {
@@ -284,12 +286,12 @@ void KConfigXmlParser::validateNameAndKey(CfgEntry &readEntry, const QDomElement
if (readEntry.name.contains(QStringLiteral("$("))) {
if (readEntry.param.isEmpty()) {
std::cerr << "Name may not be parameterized: " << qPrintable(readEntry.name) << std::endl;
- exit (1);
+ exit(1);
}
} else {
if (!readEntry.param.isEmpty()) {
std::cerr << "Name must contain '$(" << qPrintable(readEntry.param) << ")': " << qPrintable(readEntry.name) << std::endl;
- exit (1);
+ exit(1);
}
}
}
@@ -324,13 +326,13 @@ void KConfigXmlParser::readParamDefaultValues(CfgEntry &readEntry, const QDomEle
i = readEntry.paramValues.indexOf(index);
if (i == -1) {
std::cerr << "Index '" << qPrintable(index) << "' for default value is unknown." << std::endl;
- exit (1);
+ exit(1);
}
}
if ((i < 0) || (i > readEntry.paramMax)) {
std::cerr << "Index '" << i << "' for default value is out of range [0, " << readEntry.paramMax << "]." << std::endl;
- exit (1);
+ exit(1);
}
QString tmpDefaultValue = e.text();
@@ -349,7 +351,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare
readEntry.type = element.attribute(QStringLiteral("type"));
readEntry.name = element.attribute(QStringLiteral("name"));
readEntry.key = element.attribute(QStringLiteral("key"));
- readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true");;
+ readEntry.hidden = element.attribute(QStringLiteral("hidden")) == QLatin1String("true");
+ ;
readEntry.group = group;
readEntry.parentGroup = parentGroup;
@@ -364,29 +367,33 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare
}
if (readEntry.type.isEmpty()) {
- readEntry.type = QStringLiteral("String"); // XXX : implicit type might be bad
+ readEntry.type = QStringLiteral("String"); // XXX : implicit type might be bad
}
readParamDefaultValues(readEntry, element);
if (!mValidNameRegexp.match(readEntry.name).hasMatch()) {
if (nameIsEmpty)
- std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because "
- "it is not a valid name. You need to specify a valid name for this entry." << std::endl;
+ std::cerr << "The key '" << qPrintable(readEntry.key)
+ << "' can not be used as name for the entry because "
+ "it is not a valid name. You need to specify a valid name for this entry."
+ << std::endl;
else {
std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not a valid name for an entry." << std::endl;
}
- exit (1);
+ exit(1);
}
if (mAllNames.contains(readEntry.name)) {
if (nameIsEmpty)
- std::cerr << "The key '" << qPrintable(readEntry.key) << "' can not be used as name for the entry because "
- "it does not result in a unique name. You need to specify a unique name for this entry." << std::endl;
+ std::cerr << "The key '" << qPrintable(readEntry.key)
+ << "' can not be used as name for the entry because "
+ "it does not result in a unique name. You need to specify a unique name for this entry."
+ << std::endl;
else {
std::cerr << "The name '" << qPrintable(readEntry.name) << "' is not unique." << std::endl;
}
- exit (1);
+ exit(1);
}
mAllNames.append(readEntry.name);
@@ -433,7 +440,8 @@ CfgEntry *KConfigXmlParser::parseEntry(const QString &group, const QString &pare
// TODO: Change the name of the config variable.
KConfigXmlParser::KConfigXmlParser(const KConfigParameters &cfg, const QString &inputFileName)
- : cfg(cfg), mInputFileName(inputFileName)
+ : cfg(cfg)
+ , mInputFileName(inputFileName)
{
mValidNameRegexp.setPattern(QRegularExpression::anchoredPattern(QStringLiteral("[a-zA-Z_][a-zA-Z0-9_]*")));
}
@@ -447,14 +455,15 @@ void KConfigXmlParser::start()
int errorCol;
if (!doc.setContent(&input, &errorMsg, &errorRow, &errorCol)) {
std::cerr << "Unable to load document." << std::endl;
- std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg) << std::endl;
- exit (1);
+ std::cerr << "Parse error in " << qPrintable(mInputFileName) << ", line " << errorRow << ", col " << errorCol << ": " << qPrintable(errorMsg)
+ << std::endl;
+ exit(1);
}
QDomElement cfgElement = doc.documentElement();
if (cfgElement.isNull()) {
std::cerr << "No document in kcfg file" << std::endl;
- exit (1);
+ exit(1);
}
for (QDomElement element = cfgElement.firstChildElement(); !element.isNull(); element = element.nextSiblingElement()) {
@@ -490,7 +499,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e)
QString group = e.attribute(QStringLiteral("name"));
if (group.isEmpty()) {
std::cerr << "Group without name" << std::endl;
- exit (1);
+ exit(1);
}
const QString parentGroup = e.attribute(QStringLiteral("parentGroupName"));
@@ -504,7 +513,7 @@ void KConfigXmlParser::readGroupTag(const QDomElement &e)
mParseResult.entries.append(entry);
} else {
std::cerr << "Can not parse entry." << std::endl;
- exit (1);
+ exit(1);
}
}
}
@@ -531,7 +540,7 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e)
QString signalName = e.attribute(QStringLiteral("name"));
if (signalName.isEmpty()) {
std::cerr << "Signal without name." << std::endl;
- exit (1);
+ exit(1);
}
Signal theSignal;
theSignal.name = signalName;
@@ -542,9 +551,9 @@ void KConfigXmlParser::readSignalTag(const QDomElement &e)
argument.type = e2.attribute(QStringLiteral("type"));
if (argument.type.isEmpty()) {
std::cerr << "Signal argument without type." << std::endl;
- exit (1);
+ exit(1);
}
- argument.name= e2.text();
+ argument.name = e2.text();
theSignal.arguments.append(argument);
} else if (e2.tagName() == QLatin1String("label")) {
theSignal.label = e2.text();
diff --git a/src/kconfig_compiler/KConfigXmlParser.h b/src/kconfig_compiler/KConfigXmlParser.h
index 742cb496..58c2ed58 100644
--- a/src/kconfig_compiler/KConfigXmlParser.h
+++ b/src/kconfig_compiler/KConfigXmlParser.h
@@ -15,8 +15,8 @@
#define KCONFIGXMLPARSER_H
#include <QDomDocument>
-#include <QString>
#include <QRegularExpression>
+#include <QString>
#include "KConfigCommonStructs.h"
#include "KConfigParameters.h"
diff --git a/src/kconfig_compiler/kconfig_compiler.cpp b/src/kconfig_compiler/kconfig_compiler.cpp
index dd7b793c..449d437a 100644
--- a/src/kconfig_compiler/kconfig_compiler.cpp
+++ b/src/kconfig_compiler/kconfig_compiler.cpp
@@ -10,26 +10,26 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
+#include <QCommandLineOption>
+#include <QCommandLineParser>
#include <QCoreApplication>
+#include <QDomAttr>
#include <QFile>
#include <QFileInfo>
-#include <QSettings>
-#include <QTextStream>
-#include <QDomAttr>
#include <QRegularExpression>
+#include <QSettings>
#include <QStringList>
-#include <QCommandLineParser>
-#include <QCommandLineOption>
+#include <QTextStream>
-#include <ostream>
+#include <algorithm>
#include <iostream>
+#include <ostream>
#include <stdlib.h>
-#include <algorithm>
#include "../../kconfig_version.h"
-#include "KConfigParameters.h"
#include "KConfigCommonStructs.h"
#include "KConfigHeaderGenerator.h"
+#include "KConfigParameters.h"
#include "KConfigSourceGenerator.h"
#include "KConfigXmlParser.h"
@@ -114,12 +114,12 @@ QString setFunction(const QString &n, const QString &className)
QString changeSignalName(const QString &n)
{
- return n+QStringLiteral("Changed");
+ return n + QStringLiteral("Changed");
}
QString getDefaultFunction(const QString &n, const QString &className)
{
- QString result = QLatin1String("default") + n + QLatin1String("Value");
+ QString result = QLatin1String("default") + n + QLatin1String("Value");
result[7] = result.at(7).toUpper();
if (!className.isEmpty()) {
@@ -173,7 +173,9 @@ static QString quoteString(const QString &s)
QString literalString(const QString &str)
{
- const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) { return ch.unicode() > 127; });
+ const bool isAscii = std::none_of(str.cbegin(), str.cend(), [](const QChar ch) {
+ return ch.unicode() > 127;
+ });
if (isAscii) {
return QLatin1String{"QStringLiteral( "} + quoteString(str) + QLatin1String{" )"};
@@ -246,7 +248,7 @@ QString param(const QString &t)
return QStringLiteral("const QList<QUrl> &");
} else {
std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl;
- return QStringLiteral("QString"); //For now, but an assert would be better
+ return QStringLiteral("QString"); // For now, but an assert would be better
}
}
@@ -300,7 +302,7 @@ QString cppType(const QString &t)
return QStringLiteral("QList<QUrl>");
} else {
std::cerr << "kconfig_compiler_kf5 does not support type \"" << qPrintable(type) << "\"" << std::endl;
- return QStringLiteral("QString"); //For now, but an assert would be better
+ return QStringLiteral("QString"); // For now, but an assert would be better
}
}
@@ -308,7 +310,7 @@ QString defaultValue(const QString &t)
{
const QString type = t.toLower();
if (type == QLatin1String("string")) {
- return QStringLiteral("\"\""); // Use empty string, not null string!
+ return QStringLiteral("\"\""); // Use empty string, not null string!
} else if (type == QLatin1String("stringlist")) {
return QStringLiteral("QStringList()");
} else if (type == QLatin1String("font")) {
@@ -340,18 +342,18 @@ QString defaultValue(const QString &t)
} else if (type == QLatin1String("enum")) {
return QStringLiteral("0");
} else if (type == QLatin1String("path")) {
- return QStringLiteral("\"\""); // Use empty string, not null string!
+ return QStringLiteral("\"\""); // Use empty string, not null string!
} else if (type == QLatin1String("pathlist")) {
return QStringLiteral("QStringList()");
} else if (type == QLatin1String("password")) {
- return QStringLiteral("\"\""); // Use empty string, not null string!
+ return QStringLiteral("\"\""); // Use empty string, not null string!
} else if (type == QLatin1String("url")) {
return QStringLiteral("QUrl()");
} else if (type == QLatin1String("urllist")) {
return QStringLiteral("QList<QUrl>()");
} else {
std::cerr << "Error, kconfig_compiler_kf5 does not support the \"" << qPrintable(type) << "\" type!" << std::endl;
- return QStringLiteral("QString"); //For now, but an assert would be better
+ return QStringLiteral("QString"); // For now, but an assert would be better
}
}
@@ -381,8 +383,8 @@ QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg)
QString result;
if (!cfg.itemAccessors && !cfg.dpointer) {
- result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type)
- + QLatin1String{" *item"} + fCap + argSuffix + QLatin1String{";\n"};
+ result += QLatin1String{" "} + (!e->signalList.isEmpty() ? QStringLiteral("KConfigCompilerSignallingItem") : type) + QLatin1String{" *item"} + fCap
+ + argSuffix + QLatin1String{";\n"};
}
if (!e->signalList.isEmpty()) {
@@ -434,8 +436,8 @@ QString itemPath(const CfgEntry *e, const KConfigParameters &cfg)
QString newInnerItem(const CfgEntry *entry, const QString &key, const QString &defaultValue, const KConfigParameters &cfg, const QString &param)
{
- QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type)
- + QLatin1String{"( currentGroup(), "} + key + QLatin1String{", "} + varPath( entry->name, cfg ) + param;
+ QString t = QLatin1String{"new "} + cfg.inherits + QLatin1String{"::Item"} + itemType(entry->type) + QLatin1String{"( currentGroup(), "} + key
+ + QLatin1String{", "} + varPath(entry->name, cfg) + param;
if (entry->type == QLatin1String("Enum")) {
t += QLatin1String{", values"} + entry->name;
@@ -523,8 +525,7 @@ QString translatedString(const KConfigParameters &cfg, const QString &string, co
case KConfigParameters::KdeTranslation:
if (!cfg.translationDomain.isEmpty() && !context.isEmpty()) {
- result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "}
- + quoteString(context) + QLatin1String{", "};
+ result += QLatin1String{"i18ndc("} + quoteString(cfg.translationDomain) + QLatin1String{", "} + quoteString(context) + QLatin1String{", "};
} else if (!cfg.translationDomain.isEmpty()) {
result += QLatin1String{"i18nd("} + quoteString(cfg.translationDomain) + QLatin1String{", "};
} else if (!context.isEmpty()) {
@@ -573,21 +574,19 @@ QString userTextsFunctions(const CfgEntry *e, const KConfigParameters &cfg, QStr
return txt;
}
-
// returns the member mutator implementation
// which should go in the h file if inline
// or the cpp file if not inline
-//TODO: Fix add Debug Method, it should also take the debug string.
+// TODO: Fix add Debug Method, it should also take the debug string.
void addDebugMethod(QTextStream &out, const KConfigParameters &cfg, const QString &n)
{
if (cfg.qCategoryLoggingName.isEmpty()) {
- out << " qDebug() << \"" << setFunction(n);
+ out << " qDebug() << \"" << setFunction(n);
} else {
- out << " qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n);
+ out << " qCDebug(" << cfg.qCategoryLoggingName << ") << \"" << setFunction(n);
}
}
-
// returns the member get default implementation
// which should go in the h file if inline
// or the cpp file if not inline
@@ -633,7 +632,7 @@ QString itemAccessorBody(const CfgEntry *e, const KConfigParameters &cfg)
return result;
}
-//indents text adding X spaces per line
+// indents text adding X spaces per line
QString indent(QString text, int spaces)
{
QString result;
@@ -651,7 +650,7 @@ QString indent(QString text, int spaces)
return result;
}
-bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const KConfigParameters &cfg)
+bool hasErrors(KConfigXmlParser &parser, const ParseResult &parseResult, const KConfigParameters &cfg)
{
Q_UNUSED(parser)
@@ -671,18 +670,18 @@ bool hasErrors(KConfigXmlParser &parser, const ParseResult& parseResult, const K
}
/* TODO: For some reason some configuration files prefer to have *no* entries
- * at all in it, and the generated code is mostly bogus as KConfigXT will not
- * handle save / load / properties, etc, nothing.
- *
- * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop
- * project.
- * I think we should remove the possibility of creating configuration classes from configuration
- * files that don't really have configuration in it. but I'm changing this right now to allow
- * kdevelop files to pass.
- *
- * Remove for KDE 6
- * (to make things more interesting, it failed in a code that's never used within KDevelop... )
- */
+ * at all in it, and the generated code is mostly bogus as KConfigXT will not
+ * handle save / load / properties, etc, nothing.
+ *
+ * The first of those files that I came across are qmakebuilderconfig.kcfg from the KDevelop
+ * project.
+ * I think we should remove the possibility of creating configuration classes from configuration
+ * files that don't really have configuration in it. but I'm changing this right now to allow
+ * kdevelop files to pass.
+ *
+ * Remove for KDE 6
+ * (to make things more interesting, it failed in a code that's never used within KDevelop... )
+ */
if (parseResult.entries.isEmpty()) {
std::cerr << "No entries." << std::endl;
return false;
@@ -699,13 +698,13 @@ int main(int argc, char **argv)
QString inputFilename, codegenFilename;
- QCommandLineOption targetDirectoryOption(QStringList { QStringLiteral("d"), QStringLiteral("directory") },
- QCoreApplication::translate("main", "Directory to generate files in [.]"),
- QCoreApplication::translate("main", "directory"), QStringLiteral("."));
+ QCommandLineOption targetDirectoryOption(QStringList{QStringLiteral("d"), QStringLiteral("directory")},
+ QCoreApplication::translate("main", "Directory to generate files in [.]"),
+ QCoreApplication::translate("main", "directory"),
+ QStringLiteral("."));
- QCommandLineOption licenseOption (
- QStringList { QStringLiteral("l"), QStringLiteral("license") },
- QCoreApplication::translate("main", "Display software license."));
+ QCommandLineOption licenseOption(QStringList{QStringLiteral("l"), QStringLiteral("license")},
+ QCoreApplication::translate("main", "Display software license."));
QCommandLineParser parser;
@@ -713,7 +712,7 @@ int main(int argc, char **argv)
parser.addPositionalArgument(QStringLiteral("file.kcfgc"), QStringLiteral("Code generation options file"));
parser.addOption(targetDirectoryOption);
- parser.addOption (licenseOption);
+ parser.addOption(licenseOption);
parser.addVersionOption();
parser.addHelpOption();
@@ -732,7 +731,7 @@ int main(int argc, char **argv)
const QStringList args = parser.positionalArguments();
if (args.count() < 2) {
std::cerr << "Too few arguments." << std::endl;
- return 1;
+ return 1;
}
if (args.count() > 2) {
diff --git a/src/kreadconfig/kreadconfig.cpp b/src/kreadconfig/kreadconfig.cpp
index 3d26c3b8..444f3bde 100644
--- a/src/kreadconfig/kreadconfig.cpp
+++ b/src/kreadconfig/kreadconfig.cpp
@@ -38,64 +38,66 @@
int main(int argc, char **argv)
{
- QCoreApplication app(argc, argv);
+ QCoreApplication app(argc, argv);
- QCommandLineParser parser;
- parser.addOption(QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file")));
- parser.addOption(QCommandLineOption(QStringLiteral("group"), QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), QStringLiteral("group"), QStringLiteral("KDE")));
+ QCommandLineParser parser;
+ parser.addOption(
+ QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file")));
+ parser.addOption(QCommandLineOption(QStringLiteral("group"),
+ QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."),
+ QStringLiteral("group"),
+ QStringLiteral("KDE")));
parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key")));
parser.addOption(QCommandLineOption(QStringLiteral("default"), QCoreApplication::translate("main", "Default value"), QStringLiteral("value")));
parser.addOption(QCommandLineOption(QStringLiteral("type"), QCoreApplication::translate("main", "Type of variable"), QStringLiteral("type")));
- parser.process(app);
+ parser.process(app);
- const QStringList groups=parser.values(QStringLiteral("group"));
- QString key=parser.value(QStringLiteral("key"));
- QString file=parser.value(QStringLiteral("file"));
- QString dflt=parser.value(QStringLiteral("default"));
- QString type=parser.value(QStringLiteral("type")).toLower();
+ const QStringList groups = parser.values(QStringLiteral("group"));
+ QString key = parser.value(QStringLiteral("key"));
+ QString file = parser.value(QStringLiteral("file"));
+ QString dflt = parser.value(QStringLiteral("default"));
+ QString type = parser.value(QStringLiteral("type")).toLower();
if (key.isNull() || !parser.positionalArguments().isEmpty()) {
- parser.showHelp(1);
- }
+ parser.showHelp(1);
+ }
- KSharedConfig::openConfig();
+ KSharedConfig::openConfig();
- KConfig *konfig;
- bool configMustDeleted = false;
- if (file.isEmpty())
- konfig = KSharedConfig::openConfig().data();
- else
- {
- konfig = new KConfig( file, KConfig::NoGlobals );
- configMustDeleted=true;
- }
- KConfigGroup cfgGroup = konfig->group(QString());
+ KConfig *konfig;
+ bool configMustDeleted = false;
+ if (file.isEmpty())
+ konfig = KSharedConfig::openConfig().data();
+ else {
+ konfig = new KConfig(file, KConfig::NoGlobals);
+ configMustDeleted = true;
+ }
+ KConfigGroup cfgGroup = konfig->group(QString());
for (const QString &grp : groups)
- cfgGroup = cfgGroup.group(grp);
- if(type==QStringLiteral("bool")) {
- dflt=dflt.toLower();
- bool def=(dflt==QStringLiteral("true") || dflt==QStringLiteral("on") || dflt==QStringLiteral("yes") || dflt==QStringLiteral("1"));
- bool retValue = !cfgGroup.readEntry(key, def);
- if ( configMustDeleted )
- delete konfig;
- return retValue;
- } else if((type==QStringLiteral("num")) || (type==QStringLiteral("int"))) {
- int retValue = cfgGroup.readEntry(key, dflt.toInt());
- if ( configMustDeleted )
- delete konfig;
- return retValue;
- } else if (type==QStringLiteral("path")){
- fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data());
- if ( configMustDeleted )
- delete konfig;
- return 0;
- } else {
- /* Assume it's a string... */
- fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data());
- if ( configMustDeleted )
- delete konfig;
- return 0;
- }
+ cfgGroup = cfgGroup.group(grp);
+ if (type == QStringLiteral("bool")) {
+ dflt = dflt.toLower();
+ bool def = (dflt == QStringLiteral("true") || dflt == QStringLiteral("on") || dflt == QStringLiteral("yes") || dflt == QStringLiteral("1"));
+ bool retValue = !cfgGroup.readEntry(key, def);
+ if (configMustDeleted)
+ delete konfig;
+ return retValue;
+ } else if ((type == QStringLiteral("num")) || (type == QStringLiteral("int"))) {
+ int retValue = cfgGroup.readEntry(key, dflt.toInt());
+ if (configMustDeleted)
+ delete konfig;
+ return retValue;
+ } else if (type == QStringLiteral("path")) {
+ fprintf(stdout, "%s\n", cfgGroup.readPathEntry(key, dflt).toLocal8Bit().data());
+ if (configMustDeleted)
+ delete konfig;
+ return 0;
+ } else {
+ /* Assume it's a string... */
+ fprintf(stdout, "%s\n", cfgGroup.readEntry(key, dflt).toLocal8Bit().data());
+ if (configMustDeleted)
+ delete konfig;
+ return 0;
+ }
}
-
diff --git a/src/kreadconfig/kwriteconfig.cpp b/src/kreadconfig/kwriteconfig.cpp
index 8befa56d..ba16ec68 100644
--- a/src/kreadconfig/kwriteconfig.cpp
+++ b/src/kreadconfig/kwriteconfig.cpp
@@ -11,9 +11,9 @@
#include <KConfig>
#include <KConfigGroup>
-#include <stdio.h>
-#include <QCoreApplication>
#include <QCommandLineParser>
+#include <QCoreApplication>
+#include <stdio.h>
int main(int argc, char **argv)
{
@@ -21,20 +21,27 @@ int main(int argc, char **argv)
QCommandLineParser parser;
parser.addHelpOption();
- parser.addOption(QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file")));
- parser.addOption(QCommandLineOption(QStringLiteral("group"), QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."), QStringLiteral("group"), QStringLiteral("KDE")));
+ parser.addOption(
+ QCommandLineOption(QStringLiteral("file"), QCoreApplication::translate("main", "Use <file> instead of global config"), QStringLiteral("file")));
+ parser.addOption(QCommandLineOption(QStringLiteral("group"),
+ QCoreApplication::translate("main", "Group to look in. Use repeatedly for nested groups."),
+ QStringLiteral("group"),
+ QStringLiteral("KDE")));
parser.addOption(QCommandLineOption(QStringLiteral("key"), QCoreApplication::translate("main", "Key to look for"), QStringLiteral("key")));
- parser.addOption(QCommandLineOption(QStringLiteral("type"), QCoreApplication::translate("main", "Type of variable. Use \"bool\" for a boolean, otherwise it is treated as a string"), QStringLiteral("type")));
+ parser.addOption(
+ QCommandLineOption(QStringLiteral("type"),
+ QCoreApplication::translate("main", "Type of variable. Use \"bool\" for a boolean, otherwise it is treated as a string"),
+ QStringLiteral("type")));
parser.addOption(QCommandLineOption(QStringLiteral("delete"), QCoreApplication::translate("main", "Delete the designated key if enabled")));
- parser.addPositionalArgument(QStringLiteral("value"), QCoreApplication::translate("main", "The value to write. Mandatory, on a shell use '' for empty" ));
+ parser.addPositionalArgument(QStringLiteral("value"), QCoreApplication::translate("main", "The value to write. Mandatory, on a shell use '' for empty"));
parser.process(app);
- const QStringList groups=parser.values(QStringLiteral("group"));
- QString key=parser.value(QStringLiteral("key"));
- QString file=parser.value(QStringLiteral("file"));
- QString type=parser.value(QStringLiteral("type")).toLower();
- bool del=parser.isSet(QStringLiteral("delete"));
+ const QStringList groups = parser.values(QStringLiteral("group"));
+ QString key = parser.value(QStringLiteral("key"));
+ QString file = parser.value(QStringLiteral("file"));
+ QString type = parser.value(QStringLiteral("type")).toLower();
+ bool del = parser.isSet(QStringLiteral("delete"));
QString value;
if (del) {
@@ -47,28 +54,28 @@ int main(int argc, char **argv)
KConfig *konfig;
if (file.isEmpty())
- konfig = new KConfig(QStringLiteral( "kdeglobals"), KConfig::NoGlobals );
+ konfig = new KConfig(QStringLiteral("kdeglobals"), KConfig::NoGlobals);
else
- konfig = new KConfig( file, KConfig::NoGlobals );
+ konfig = new KConfig(file, KConfig::NoGlobals);
KConfigGroup cfgGroup = konfig->group(QString());
for (const QString &grp : groups)
cfgGroup = cfgGroup.group(grp);
- if ( konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable( key ) ) return 2;
+ if (konfig->accessMode() != KConfig::ReadWrite || cfgGroup.isEntryImmutable(key))
+ return 2;
if (del) {
- cfgGroup.deleteEntry( key );
- } else if (type==QStringLiteral("bool")) {
+ cfgGroup.deleteEntry(key);
+ } else if (type == QStringLiteral("bool")) {
// For symmetry with kreadconfig we accept a wider range of values as true than Qt
- bool boolvalue=(value==QStringLiteral("true") || value==QStringLiteral("on") || value==QStringLiteral("yes") || value==QStringLiteral("1"));
- cfgGroup.writeEntry( key, boolvalue );
- } else if (type==QStringLiteral("path")) {
- cfgGroup.writePathEntry( key, value );
+ bool boolvalue = (value == QStringLiteral("true") || value == QStringLiteral("on") || value == QStringLiteral("yes") || value == QStringLiteral("1"));
+ cfgGroup.writeEntry(key, boolvalue);
+ } else if (type == QStringLiteral("path")) {
+ cfgGroup.writePathEntry(key, value);
} else {
- cfgGroup.writeEntry( key, value );
+ cfgGroup.writeEntry(key, value);
}
konfig->sync();
delete konfig;
return 0;
}
-