aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2021-02-04 14:06:34 +0200
committerAhmad Samir <a.samirh78@gmail.com>2021-02-06 22:10:10 +0200
commitbce76d2e73a462de673d18dbf6d94da0c592bf08 (patch)
tree455687733ca90a74ecf8c4c90100695332378bf4
parent2ac45198cf101f094cf8d94f3a546a57624e59f5 (diff)
downloadkconfig-bce76d2e73a462de673d18dbf6d94da0c592bf08.tar.gz
kconfig-bce76d2e73a462de673d18dbf6d94da0c592bf08.tar.bz2
Less implicit cast from ASCII
NO_CHANGELOG
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test.cpp4
-rw-r--r--autotests/kconfig_compiler/test4main.cpp2
-rw-r--r--autotests/kconfig_compiler/test_emptyentries_main.cpp2
-rw-r--r--autotests/kconfigguitest.cpp20
-rw-r--r--autotests/kconfigloadertest.cpp46
-rw-r--r--autotests/kconfigskeletontest.cpp47
-rw-r--r--autotests/kdesktopfiletest.cpp48
-rw-r--r--autotests/kstandardshortcuttest.cpp4
-rw-r--r--autotests/test_kconf_update.cpp25
-rw-r--r--src/kconf_update/kconf_update.cpp52
-rw-r--r--src/kconf_update/kconfigutils.cpp49
11 files changed, 167 insertions, 132 deletions
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
index 6afc0096..014bc0f3 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp
+++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
@@ -119,8 +119,8 @@ void KConfigCompiler_Test::testBaselineComparison()
qWarning() << "Failed to open" << fileRef.fileName() << "(" << testName << ".ref )";
QFAIL("Can't open file for comparison");
}
- QString content = file.readAll();
- QString contentRef = fileRef.readAll();
+ const QByteArray content = file.readAll();
+ const QByteArray contentRef = fileRef.readAll();
if (content != contentRef) {
appendFileDiff(fileRef.fileName(), file.fileName());
diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp
index 2d48e440..8792842f 100644
--- a/autotests/kconfig_compiler/test4main.cpp
+++ b/autotests/kconfig_compiler/test4main.cpp
@@ -19,7 +19,7 @@ int main(int argc, char **argv)
group.writeEntry(QStringLiteral("foo bar"), QStringLiteral("Value"));
}
Test4 *t = Test4::self();
- bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/test4rc");
+ const bool ok = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/test4rc"});
if (!ok) {
qWarning() << "config file was not created!";
}
diff --git a/autotests/kconfig_compiler/test_emptyentries_main.cpp b/autotests/kconfig_compiler/test_emptyentries_main.cpp
index 18c750a5..5dbce8e4 100644
--- a/autotests/kconfig_compiler/test_emptyentries_main.cpp
+++ b/autotests/kconfig_compiler/test_emptyentries_main.cpp
@@ -11,7 +11,7 @@ int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
Q_UNUSED(app);
- QMakeBuilderSettings::instance("abc");
+ QMakeBuilderSettings::instance(QStringLiteral("abc"));
auto *t = QMakeBuilderSettings::self();
delete t;
return 0;
diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp
index 2a618ce2..87168a7f 100644
--- a/autotests/kconfigguitest.cpp
+++ b/autotests/kconfigguitest.cpp
@@ -16,10 +16,16 @@
QTEST_MAIN(KConfigTest)
-#define COLORENTRY1 QColor("steelblue")
-#define COLORENTRY2 QColor(235, 235, 100, 125)
-#define COLORENTRY3 QColor(234, 234, 127)
-#define FONTENTRY QFont("Times", 16, QFont::Normal)
+// clazy:excludeall=non-pod-global-static
+
+const QColor COLORENTRY1(QLatin1String{"steelblue"});
+const QColor COLORENTRY2(235, 235, 100, 125);
+const QColor COLORENTRY3(234, 234, 127);
+
+static QFont fontEntry()
+{
+ return QFont{QStringLiteral("Times"), 16, QFont::Normal};
+}
void KConfigTest::initTestCase()
{
@@ -36,7 +42,7 @@ void KConfigTest::initTestCase()
cg.writeEntry("colorEntry2", COLORENTRY2);
cg.writeEntry("colorEntry3", (QList<int>() << 234 << 234 << 127));
cg.writeEntry("colorEntry4", (QList<int>() << 235 << 235 << 100 << 125));
- cg.writeEntry("fontEntry", FONTENTRY);
+ cg.writeEntry("fontEntry", fontEntry());
QVERIFY(sc.sync());
KConfig sc1(QStringLiteral("kdebugrc"));
@@ -51,7 +57,7 @@ void KConfigTest::initTestCase()
// This is fixed by https://codereview.qt-project.org/181645
// It's not in yet, and it depends on the app font, so rather than
// a version check, let's do a runtime check.
- QFont orig(FONTENTRY);
+ QFont orig(fontEntry());
QFont f;
f.fromString(orig.toString());
m_fontFromStringBug = (f.toString() != orig.toString());
@@ -81,7 +87,7 @@ void KConfigTest::testComplex()
if (m_fontFromStringBug) {
QEXPECT_FAIL("", "QFont fromString bug from Qt 5.8.0", Continue);
}
- QCOMPARE(sc3.readEntry("fontEntry", QFont()), FONTENTRY);
+ QCOMPARE(sc3.readEntry("fontEntry", QFont()), fontEntry());
}
void KConfigTest::testInvalid()
diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp
index afc58a1b..27a90916 100644
--- a/autotests/kconfigloadertest.cpp
+++ b/autotests/kconfigloadertest.cpp
@@ -12,7 +12,7 @@
Q_DECLARE_METATYPE(QList<int>)
-#define TEST_NAME QString::fromLatin1("kconfigloadertest")
+const QString TEST_NAME(QStringLiteral("kconfigloadertest"));
#define GET_CONFIG_ITEM_VALUE(type, configName) \
KConfigSkeletonItem* item = cl->findItem(TEST_NAME, configName); \
@@ -38,70 +38,70 @@ void ConfigLoaderTest::cleanup()
void ConfigLoaderTest::boolDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, "DefaultBoolItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, QStringLiteral("DefaultBoolItem"));
QVERIFY(typeItem->isEqual(true));
}
void ConfigLoaderTest::colorDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, "DefaultColorItem");
+ GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, QStringLiteral("DefaultColorItem"));
QVERIFY(typeItem->isEqual(QColor("#00FF00")));
}
void ConfigLoaderTest::dateTimeDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, "DefaultDateTimeItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, QStringLiteral("DefaultDateTimeItem"));
- QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010")));
+ QVERIFY(typeItem->isEqual(QDateTime::fromString(QStringLiteral("Thu Sep 09 2010"))));
}
void ConfigLoaderTest::enumDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, "DefaultEnumItem");
+ GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, QStringLiteral("DefaultEnumItem"));
QVERIFY(typeItem->isEqual(3));
}
void ConfigLoaderTest::fontDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, "DefaultFontItem");
+ GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, QStringLiteral("DefaultFontItem"));
- QVERIFY(typeItem->isEqual(QFont("DejaVu Sans")));
+ QVERIFY(typeItem->isEqual(QFont(QStringLiteral("DejaVu Sans"))));
}
void ConfigLoaderTest::intDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, "DefaultIntItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, QStringLiteral("DefaultIntItem"));
QVERIFY(typeItem->isEqual(27));
}
void ConfigLoaderTest::passwordDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, "DefaultPasswordItem");
+ GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, QStringLiteral("DefaultPasswordItem"));
QVERIFY(typeItem->isEqual(QString::fromLatin1("h4x.")));
}
void ConfigLoaderTest::pathDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, "DefaultPathItem");
+ GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, QStringLiteral("DefaultPathItem"));
QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null")));
}
void ConfigLoaderTest::stringDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, "DefaultStringItem");
+ GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, QStringLiteral("DefaultStringItem"));
QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString")));
}
void ConfigLoaderTest::stringListDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, "DefaultStringListItem");
+ GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, QStringLiteral("DefaultStringListItem"));
// Create a string list with the expected values.
QStringList expected;
@@ -116,28 +116,28 @@ void ConfigLoaderTest::stringListDefaultValue()
void ConfigLoaderTest::uintDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, "DefaultUIntItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, QStringLiteral("DefaultUIntItem"));
QVERIFY(typeItem->isEqual(7U));
}
void ConfigLoaderTest::urlDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, "DefaultUrlItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, QStringLiteral("DefaultUrlItem"));
- QVERIFY(typeItem->isEqual(QUrl("http://kde.org")));
+ QVERIFY(typeItem->isEqual(QUrl(QStringLiteral("http://kde.org"))));
}
void ConfigLoaderTest::doubleDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, "DefaultDoubleItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, QStringLiteral("DefaultDoubleItem"));
QVERIFY(typeItem->isEqual(13.37));
}
void ConfigLoaderTest::intListDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, "DefaultIntListItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, QStringLiteral("DefaultIntListItem"));
// Create a int list with the expected values.
QList<int> expected;
@@ -153,21 +153,21 @@ void ConfigLoaderTest::intListDefaultValue()
void ConfigLoaderTest::longLongDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, "DefaultLongLongItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, QStringLiteral("DefaultLongLongItem"));
QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808)));
}
void ConfigLoaderTest::pointDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, "DefaultPointItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, QStringLiteral("DefaultPointItem"));
QVERIFY(typeItem->isEqual(QPoint(185, 857)));
}
void ConfigLoaderTest::rectDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, "DefaultRectItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, QStringLiteral("DefaultRectItem"));
// Create a new QRect with the expected value.
QRect expected;
@@ -178,14 +178,14 @@ void ConfigLoaderTest::rectDefaultValue()
void ConfigLoaderTest::sizeDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, "DefaultSizeItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, QStringLiteral("DefaultSizeItem"));
QVERIFY(typeItem->isEqual(QSize(640, 480)));
}
void ConfigLoaderTest::ulongLongDefaultValue()
{
- GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, "DefaultULongLongItem");
+ GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, QStringLiteral("DefaultULongLongItem"));
QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806)));
}
diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp
index 896d4ee1..75708bc1 100644
--- a/autotests/kconfigskeletontest.cpp
+++ b/autotests/kconfigskeletontest.cpp
@@ -14,13 +14,22 @@ QTEST_MAIN(KConfigSkeletonTest)
#define DEFAULT_SETTING1 false
#define DEFAULT_SETTING2 QColor(1,2,3)
-#define DEFAULT_SETTING3 QFont("helvetica",12)
-#define DEFAULT_SETTING4 QString("Hello World")
+const QString DEFAULT_SETTING4{QStringLiteral("Hello World")};
+
#define WRITE_SETTING1 true
#define WRITE_SETTING2 QColor(3,2,1)
-#define WRITE_SETTING3 QFont("helvetica",14)
-#define WRITE_SETTING4 QString("KDE")
+const QString WRITE_SETTING4{QStringLiteral("KDE")};
+
+static QFont defaultSetting3()
+{
+ return QFont{QStringLiteral("helvetica"), 12};
+}
+
+static QFont writeSettings3()
+{
+ return QFont{QStringLiteral("helvetica"), 14};
+}
void KConfigSkeletonTest::initTestCase()
{
@@ -29,19 +38,19 @@ void KConfigSkeletonTest::initTestCase()
void KConfigSkeletonTest::init()
{
- QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/kconfigskeletontestrc");
+ QFile::remove(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/kconfigskeletontestrc"});
s = new KConfigSkeleton(QStringLiteral("kconfigskeletontestrc"));
s->setCurrentGroup(QStringLiteral("MyGroup"));
itemBool = s->addItemBool(QStringLiteral("MySetting1"), mMyBool, DEFAULT_SETTING1);
s->addItemColor(QStringLiteral("MySetting2"), mMyColor, DEFAULT_SETTING2);
s->setCurrentGroup(QStringLiteral("MyOtherGroup"));
- s->addItemFont(QStringLiteral("MySetting3"), mMyFont, DEFAULT_SETTING3);
+ s->addItemFont(QStringLiteral("MySetting3"), mMyFont, defaultSetting3());
s->addItemString(QStringLiteral("MySetting4"), mMyString, DEFAULT_SETTING4);
QCOMPARE(mMyBool, DEFAULT_SETTING1);
QCOMPARE(mMyColor, DEFAULT_SETTING2);
- QCOMPARE(mMyFont, DEFAULT_SETTING3);
+ QCOMPARE(mMyFont, defaultSetting3());
QCOMPARE(mMyString, DEFAULT_SETTING4);
QVERIFY(s->isDefaults());
@@ -57,7 +66,7 @@ void KConfigSkeletonTest::testSimple()
{
mMyBool = WRITE_SETTING1;
mMyColor = WRITE_SETTING2;
- mMyFont = WRITE_SETTING3;
+ mMyFont = writeSettings3();
mMyString = WRITE_SETTING4;
QVERIFY(s->isSaveNeeded());
@@ -83,35 +92,35 @@ void KConfigSkeletonTest::testSimple()
QCOMPARE(mMyBool, WRITE_SETTING1);
QCOMPARE(mMyColor, WRITE_SETTING2);
- QCOMPARE(mMyFont, WRITE_SETTING3);
+ QCOMPARE(mMyFont, writeSettings3());
QCOMPARE(mMyString, WRITE_SETTING4);
}
void KConfigSkeletonTest::testRemoveItem()
{
- QVERIFY(s->findItem("MySetting1"));
+ QVERIFY(s->findItem(QStringLiteral("MySetting1")));
s->removeItem(QStringLiteral("MySetting1"));
- QVERIFY(!s->findItem("MySetting1"));
+ QVERIFY(!s->findItem(QStringLiteral("MySetting1")));
}
void KConfigSkeletonTest::testClear()
{
- QVERIFY(s->findItem("MySetting2"));
- QVERIFY(s->findItem("MySetting3"));
- QVERIFY(s->findItem("MySetting4"));
+ QVERIFY(s->findItem(QStringLiteral("MySetting2")));
+ QVERIFY(s->findItem(QStringLiteral("MySetting3")));
+ QVERIFY(s->findItem(QStringLiteral("MySetting4")));
s->clearItems();
- QVERIFY(!s->findItem("MySetting2"));
- QVERIFY(!s->findItem("MySetting3"));
- QVERIFY(!s->findItem("MySetting4"));
+ QVERIFY(!s->findItem(QStringLiteral("MySetting2")));
+ QVERIFY(!s->findItem(QStringLiteral("MySetting3")));
+ QVERIFY(!s->findItem(QStringLiteral("MySetting4")));
}
void KConfigSkeletonTest::testDefaults()
{
mMyBool = WRITE_SETTING1;
mMyColor = WRITE_SETTING2;
- mMyFont = WRITE_SETTING3;
+ mMyFont = writeSettings3();
mMyString = WRITE_SETTING4;
QVERIFY(s->isSaveNeeded());
@@ -129,7 +138,7 @@ void KConfigSkeletonTest::testDefaults()
QCOMPARE(mMyBool, DEFAULT_SETTING1);
QCOMPARE(mMyColor, DEFAULT_SETTING2);
- QCOMPARE(mMyFont, DEFAULT_SETTING3);
+ QCOMPARE(mMyFont, defaultSetting3());
QCOMPARE(mMyString, DEFAULT_SETTING4);
s->save();
diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp
index 34391489..e45ba44e 100644
--- a/autotests/kdesktopfiletest.cpp
+++ b/autotests/kdesktopfiletest.cpp
@@ -53,7 +53,7 @@ void KDesktopFileTest::testRead()
#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 0)
void KDesktopFileTest::testReadDirectory()
{
- QTemporaryFile file("testReadDirectoryXXXXXX.directory");
+ QTemporaryFile file(QStringLiteral("testReadDirectoryXXXXXX.directory"));
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
@@ -178,20 +178,20 @@ void KDesktopFileTest::testActionGroup()
KDesktopFile df(fileName);
QCOMPARE(df.readType(), QString());
QCOMPARE(df.fileName(), QFileInfo(fileName).canonicalFilePath());
- QCOMPARE(df.readActions(), QStringList() << "encrypt" << "semi;colon" << "decrypt");
- QCOMPARE(df.hasActionGroup("encrypt"), true);
- QCOMPARE(df.hasActionGroup("semi;colon"), true);
- QCOMPARE(df.hasActionGroup("decrypt"), true);
- QCOMPARE(df.hasActionGroup("doesnotexist"), false);
+ QCOMPARE(df.readActions(), (QStringList{QStringLiteral("encrypt"), QStringLiteral("semi;colon"), QStringLiteral("decrypt")}));
+ QCOMPARE(df.hasActionGroup(QStringLiteral("encrypt")), true);
+ QCOMPARE(df.hasActionGroup(QStringLiteral("semi;colon")), true);
+ QCOMPARE(df.hasActionGroup(QStringLiteral("decrypt")), true);
+ QCOMPARE(df.hasActionGroup(QStringLiteral("doesnotexist")), false);
KConfigGroup cg = df.actionGroup(QStringLiteral("encrypt"));
QVERIFY(cg.hasKey("Name"));
- QCOMPARE(cg.readEntry("Name"), QString("Encrypt file"));
+ QCOMPARE(cg.readEntry("Name"), QStringLiteral("Encrypt file"));
cg = df.actionGroup(QStringLiteral("decrypt"));
QVERIFY(cg.hasKey("Name"));
- QCOMPARE(cg.readEntry("Name"), QString("Decrypt file"));
+ QCOMPARE(cg.readEntry("Name"), QStringLiteral("Decrypt file"));
cg = df.actionGroup(QStringLiteral("semi;colon"));
QVERIFY(cg.hasKey("Name"));
- QCOMPARE(cg.readEntry("Name"), QString("With semicolon"));
+ QCOMPARE(cg.readEntry("Name"), QStringLiteral("With semicolon"));
}
void KDesktopFileTest::testIsAuthorizedDesktopFile()
@@ -275,17 +275,25 @@ void KDesktopFileTest::testLocateLocal_data()
QTest::addColumn<QString>("path");
QTest::addColumn<QString>("result");
- QTest::newRow("configLocation, system-wide") << systemConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop";
- QTest::newRow("autostart, system-wide") << systemConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop";
- QTest::newRow("dataLocation, system-wide") << systemDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop";
- QTest::newRow("applications, system-wide") << systemDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop";
- QTest::newRow("desktop-directories, system-wide") << systemDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory";
- QTest::newRow("configLocation, writable") << writableConfigLocation + "/test.desktop" << writableConfigLocation + "/test.desktop";
- QTest::newRow("autostart, writable") << writableConfigLocation + "/autostart/test.desktop" << writableConfigLocation + "/autostart/test.desktop";
- QTest::newRow("dataLocation, writable") << writableDataLocation + "/test.desktop" << writableDataLocation + "/test.desktop";
- QTest::newRow("applications, writable") << writableDataLocation + "/applications/test.desktop" << writableDataLocation + "/applications/test.desktop";
- QTest::newRow("desktop-directories, writable") << writableDataLocation + "/desktop-directories/test.directory" << writableDataLocation + "/desktop-directories/test.directory";
- QTest::newRow("unknown location") << "/test.desktop" << writableDataLocation + "/test.desktop";
+ QTest::newRow("configLocation, system-wide") << systemConfigLocation + QLatin1String{"/test.desktop"}
+ << writableConfigLocation + QLatin1String{"/test.desktop"};
+ QTest::newRow("autostart, system-wide") << systemConfigLocation + QLatin1String{"/autostart/test.desktop"}
+ << writableConfigLocation + QLatin1String{"/autostart/test.desktop"};
+ QTest::newRow("dataLocation, system-wide") << systemDataLocation + QLatin1String{"/test.desktop"} << writableDataLocation + QLatin1String{"/test.desktop"};
+ QTest::newRow("applications, system-wide") << systemDataLocation + QLatin1String{"/applications/test.desktop"}
+ << writableDataLocation + QLatin1String{"/applications/test.desktop"};
+ QTest::newRow("desktop-directories, system-wide") << systemDataLocation + QLatin1String{"/desktop-directories/test.directory"}
+ << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"};
+ QTest::newRow("configLocation, writable") << writableConfigLocation + QLatin1String{"/test.desktop"}
+ << writableConfigLocation + QLatin1String{"/test.desktop"};
+ QTest::newRow("autostart, writable") << writableConfigLocation + QLatin1String{"/autostart/test.desktop"}
+ << writableConfigLocation + QLatin1String{"/autostart/test.desktop"};
+ QTest::newRow("dataLocation, writable") << writableDataLocation + QLatin1String{"/test.desktop"} << writableDataLocation + QLatin1String{"/test.desktop"};
+ QTest::newRow("applications, writable") << writableDataLocation + QLatin1String{"/applications/test.desktop"}
+ << writableDataLocation + QLatin1String{"/applications/test.desktop"};
+ QTest::newRow("desktop-directories, writable") << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"}
+ << writableDataLocation + QLatin1String{"/desktop-directories/test.directory"};
+ QTest::newRow("unknown location") << QStringLiteral("/test.desktop") << writableDataLocation + QLatin1String{"/test.desktop"};
}
void KDesktopFileTest::testLocateLocal()
diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp
index 69e234ab..1b7f88ff 100644
--- a/autotests/kstandardshortcuttest.cpp
+++ b/autotests/kstandardshortcuttest.cpp
@@ -49,8 +49,8 @@ void KStandardShortcutTest::testShortcut()
void KStandardShortcutTest::testFindStdAccel()
{
- QCOMPARE(KStandardShortcut::find(QString("Ctrl+F")), KStandardShortcut::Find);
- QCOMPARE(KStandardShortcut::find(QString("Ctrl+Shift+Alt+G")), KStandardShortcut::AccelNone);
+ QCOMPARE(KStandardShortcut::find(QKeySequence(Qt::CTRL | Qt::Key_F)), KStandardShortcut::Find);
+ QCOMPARE(KStandardShortcut::find(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::ALT | Qt::Key_G)), KStandardShortcut::AccelNone);
}
void KStandardShortcutTest::testFindByName()
diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp
index ba716f28..88ba385f 100644
--- a/autotests/test_kconf_update.cpp
+++ b/autotests/test_kconf_update.cpp
@@ -65,8 +65,8 @@ static std::unique_ptr<QTemporaryFile> writeUpdFile(const QString &content)
static void runKConfUpdate(const QString &updPath)
{
- QVERIFY(QFile::exists(KCONF_UPDATE_EXECUTABLE));
- QCOMPARE(0, QProcess::execute(KCONF_UPDATE_EXECUTABLE, QStringList() << "--testmode" << "--debug" << updPath));
+ QVERIFY(QFile::exists(QStringLiteral(KCONF_UPDATE_EXECUTABLE)));
+ QCOMPARE(0, QProcess::execute(QStringLiteral(KCONF_UPDATE_EXECUTABLE), QStringList{QStringLiteral("--testmode"), QStringLiteral("--debug"), updPath}));
}
void TestKConfUpdate::test_data()
@@ -313,10 +313,11 @@ void TestKConfUpdate::test()
QFETCH(bool, shouldUpdateWork);
// Prepend Version and the Id= field to the upd content
- const QString header = QStringLiteral("Id=%1\n").arg(QTest::currentDataTag());
+ const QString header = QLatin1String("Id=%1\n").arg(QLatin1String(QTest::currentDataTag()));
updContent = header + updContent;
- if (useVersion5)
- updContent.prepend("Version=5\n");
+ if (useVersion5) {
+ updContent.prepend(QLatin1String{"Version=5\n"});
+ }
const QString configDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
QVERIFY(QDir().mkpath(configDir));
@@ -331,7 +332,7 @@ void TestKConfUpdate::test()
std::unique_ptr<QTemporaryFile> updFile(writeUpdFile(updContent));
runKConfUpdate(updFile->fileName());
- QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag());
+ QString updateInfo = QLatin1String("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QLatin1String{QTest::currentDataTag()});
QString newConfContentAfter = readFile(newConfPath);
if (shouldUpdateWork) {
@@ -609,26 +610,24 @@ void TestKConfUpdate::testScript()
QFETCH(QString, expectedNewConfContent);
// Prepend the Version and Id= field to the upd content
- updContent = QStringLiteral("Version=5\nId=%1\n").arg(QTest::currentDataTag()) + updContent;
+ updContent.prepend(QLatin1String("Version=5\nId=%1\n").arg(QLatin1String{QTest::currentDataTag()}));
std::unique_ptr<QTemporaryFile> updFile(writeUpdFile(updContent));
- const QString scriptDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kconf_update";
+ const QString scriptDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String{"/kconf_update"};
QVERIFY(QDir().mkpath(scriptDir));
- QString scriptPath = scriptDir + "/test.sh";
+ const QString scriptPath = scriptDir + QLatin1String{"/test.sh"};
writeFile(scriptPath, updScript);
QCOMPARE(readFile(scriptPath), updScript);
- QString confPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + "testrc";
+ const QString confPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String{"/testrc"};
writeFile(confPath, oldConfContent);
QCOMPARE(readFile(confPath), oldConfContent);
runKConfUpdate(updFile->fileName());
- QString updateInfo = QStringLiteral("%1:%2").arg(updFile->fileName().section(QLatin1Char('/'), -1), QTest::currentDataTag());
+ const QString updateInfo = QLatin1String("%1:%2").arg(updFile->fileName().section(QLatin1Char{'/'}, -1), QLatin1String{QTest::currentDataTag()});
QString newConfContent = readFile(confPath);
expectedNewConfContent = expectedNewConfContent.arg(updateInfo);
QCOMPARE(newConfContent, expectedNewConfContent);
}
-
-
diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp
index a1a1ac72..c2552c23 100644
--- a/src/kconf_update/kconf_update.cpp
+++ b/src/kconf_update/kconf_update.cpp
@@ -122,7 +122,7 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)
// its mode. This can however be overridden by the environment, so
// we'll want to have a fallback warning if debug is not enabled
// after setting the filter.
- QLoggingCategory::setFilterRules(QStringLiteral("%1.debug=true").arg(KCONF_UPDATE_LOG().categoryName()));
+ 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",
@@ -138,7 +138,8 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)
m_bUseConfigInfo = false;
if (parser->isSet(QStringLiteral("check"))) {
m_bUseConfigInfo = true;
- const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kconf_update/" + parser->value(QStringLiteral("check")));
+ const QString file =
+ QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String{"kconf_update/"} + parser->value(QStringLiteral("check")));
if (file.isEmpty()) {
qWarning("File '%s' not found.", parser->value(QStringLiteral("check")).toLocal8Bit().data());
qCDebug(KCONF_UPDATE_LOG) << "File" << parser->value(QStringLiteral("check")) << "passed on command line not found";
@@ -211,7 +212,7 @@ QStringList KonfUpdate::findUpdateFiles(bool dirtyOnly)
bool KonfUpdate::checkFile(const QString &filename)
{
m_currentFilename = filename;
- int i = m_currentFilename.lastIndexOf('/');
+ const int i = m_currentFilename.lastIndexOf(QLatin1Char{'/'});
if (i != -1) {
m_currentFilename = m_currentFilename.mid(i + 1);
}
@@ -237,7 +238,7 @@ bool KonfUpdate::checkFile(const QString &filename)
foundVersion = true;
}
++lineCount;
- if (line.isEmpty() || (line[0] == '#')) {
+ if (line.isEmpty() || (line[0] == QLatin1Char{'#'})) {
continue;
}
if (line.startsWith(QLatin1String("Id="))) {
@@ -247,7 +248,7 @@ bool KonfUpdate::checkFile(const QString &filename)
qUtf8Printable(filename));
return true;
}
- id = m_currentFilename + ':' + line.mid(3);
+ id = m_currentFilename + QLatin1Char{':'} + line.mid(3);
} else if (line.startsWith(QLatin1String("File="))) {
checkGotFile(line.mid(5), id);
}
@@ -259,7 +260,7 @@ bool KonfUpdate::checkFile(const QString &filename)
void KonfUpdate::checkGotFile(const QString &_file, const QString &id)
{
QString file;
- int i = _file.indexOf(',');
+ const int i = _file.indexOf(QLatin1Char{','});
if (i == -1) {
file = _file.trimmed();
} else {
@@ -300,7 +301,7 @@ void KonfUpdate::checkGotFile(const QString &_file, const QString &id)
bool KonfUpdate::updateFile(const QString &filename)
{
m_currentFilename = filename;
- int i = m_currentFilename.lastIndexOf('/');
+ const int i = m_currentFilename.lastIndexOf(QLatin1Char{'/'});
if (i != -1) {
m_currentFilename = m_currentFilename.mid(i + 1);
}
@@ -441,7 +442,7 @@ void KonfUpdate::gotFile(const QString &_file)
KConfigGroup cg(m_oldConfig2, "$Version");
QStringList ids = cg.readEntry("update_info", QStringList());
- QString cfg_id = m_currentFilename + ':' + m_id;
+ QString cfg_id = m_currentFilename + QLatin1Char{':'} + m_id;
if (!ids.contains(cfg_id) && !m_skip) {
ids.append(cfg_id);
cg.writeEntry("update_info", ids);
@@ -463,7 +464,7 @@ void KonfUpdate::gotFile(const QString &_file)
// Close new file.
KConfigGroup cg(m_newConfig, "$Version");
QStringList ids = cg.readEntry("update_info", QStringList());
- QString cfg_id = m_currentFilename + ':' + m_id;
+ const QString cfg_id = m_currentFilename + QLatin1Char{':'} + m_id;
if (!ids.contains(cfg_id) && !m_skip) {
ids.append(cfg_id);
cg.writeEntry("update_info", ids);
@@ -476,7 +477,7 @@ void KonfUpdate::gotFile(const QString &_file)
}
m_newConfig = nullptr;
- int i = _file.indexOf(',');
+ const int i = _file.indexOf(QLatin1Char{','});
if (i == -1) {
m_oldFile = _file.trimmed();
} else {
@@ -489,7 +490,7 @@ void KonfUpdate::gotFile(const QString &_file)
if (!m_oldFile.isEmpty()) {
m_oldConfig2 = new KConfig(m_oldFile, KConfig::NoGlobals);
- QString cfg_id = m_currentFilename + ':' + m_id;
+ const QString cfg_id = m_currentFilename + QLatin1Char{':'} + m_id;
KConfigGroup cg(m_oldConfig2, "$Version");
QStringList ids = cg.readEntry("update_info", QStringList());
if (ids.contains(cfg_id)) {
@@ -549,7 +550,7 @@ void KonfUpdate::gotGroup(const QString &_group)
return;
}
- QStringList tokens = group.split(',');
+ const QStringList tokens = group.split(QLatin1Char{','});
m_oldGroup = parseGroupString(tokens.at(0));
if (tokens.count() == 1) {
m_newGroup = m_oldGroup;
@@ -579,7 +580,7 @@ void KonfUpdate::gotRemoveGroup(const QString &_group)
void KonfUpdate::gotKey(const QString &_key)
{
QString oldKey, newKey;
- int i = _key.indexOf(',');
+ const int i = _key.indexOf(QLatin1Char{','});
if (i == -1) {
oldKey = _key.trimmed();
newKey = oldKey;
@@ -704,7 +705,7 @@ void KonfUpdate::gotAllGroups()
void KonfUpdate::gotOptions(const QString &_options)
{
- const QStringList options = _options.split(',');
+ const QStringList options = _options.split(QLatin1Char{','});
for (QStringList::ConstIterator it = options.begin();
it != options.end();
++it) {
@@ -750,8 +751,9 @@ void KonfUpdate::gotScriptArguments(const QString &_arguments)
void KonfUpdate::gotScript(const QString &_script)
{
- QString script, interpreter;
- int i = _script.indexOf(',');
+ QString script;
+ QString interpreter;
+ const int i = _script.indexOf(QLatin1Char{','});
if (i == -1) {
script = _script.trimmed();
} else {
@@ -768,7 +770,7 @@ void KonfUpdate::gotScript(const QString &_script)
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kconf_update/") + script);
if (path.isEmpty()) {
if (interpreter.isEmpty()) {
- path = CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/kconf_update_bin/" + script;
+ path = QLatin1String{CMAKE_INSTALL_PREFIX "/" LIB_INSTALL_DIR "/kconf_update_bin/"} + script;
if (!QFile::exists(path)) {
path = QStandardPaths::findExecutable(script);
}
@@ -899,16 +901,16 @@ void KonfUpdate::gotScript(const QString &_script)
ts.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
while (!ts.atEnd()) {
- QString line = ts.readLine();
- if (line.startsWith('[')) {
+ const QString line = ts.readLine();
+ if (line.startsWith(QLatin1Char{'['})) {
group = parseGroupString(line);
} else if (line.startsWith(QLatin1String("# DELETE "))) {
QString key = line.mid(9);
- if (key[0] == '[') {
- int j = key.lastIndexOf(']') + 1;
- if (j > 0) {
- group = parseGroupString(key.left(j));
- key = key.mid(j);
+ if (key.startsWith(QLatin1Char{'['})) {
+ const int idx = key.lastIndexOf(QLatin1Char{']'}) + 1;
+ if (idx > 0) {
+ group = parseGroupString(key.left(idx));
+ key = key.mid(idx);
}
}
KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig2, group);
@@ -918,7 +920,7 @@ void KonfUpdate::gotScript(const QString &_script)
qCDebug(KCONF_UPDATE_LOG) << m_currentFilename << ": Removing empty group " << m_oldFile << ":" << group;
} (this should be automatic)*/
} else if (line.startsWith(QLatin1String("# DELETEGROUP"))) {
- QString str = line.mid(13).trimmed();
+ const QString str = line.mid(13).trimmed();
if (!str.isEmpty()) {
group = parseGroupString(str);
}
diff --git a/src/kconf_update/kconfigutils.cpp b/src/kconf_update/kconfigutils.cpp
index a47ef53a..56e5cba7 100644
--- a/src/kconf_update/kconfigutils.cpp
+++ b/src/kconf_update/kconfigutils.cpp
@@ -38,12 +38,12 @@ QStringList parseGroupString(const QString &_str, bool *ok, QString *error)
}
*ok = true;
- if (str[0] != '[') {
+ if (!str.startsWith(QLatin1Char{'['})) {
// Simplified notation, no '['
- return QStringList() << str;
+ return QStringList{str};
}
- if (!str.endsWith(']')) {
+ if (!str.endsWith(QLatin1Char{']'})) {
*ok = false;
*error = QStringLiteral("Missing closing ']' in %1").arg(_str);
return QStringList();
@@ -52,16 +52,16 @@ QStringList parseGroupString(const QString &_str, bool *ok, QString *error)
str.chop(1);
str.remove(0, 1);
- return str.split(QStringLiteral("]["));
+ return str.split(QLatin1String{"]["});
}
QString unescapeString(const QString &src, bool *ok, QString *error)
{
QString dst;
- int length = src.length();
+ const int length = src.length();
for (int pos = 0; pos < length; ++pos) {
QChar ch = src.at(pos);
- if (ch != '\\') {
+ if (ch != QLatin1Char{'\\'}) {
dst += ch;
} else {
++pos;
@@ -70,22 +70,29 @@ QString unescapeString(const QString &src, bool *ok, QString *error)
*error = QStringLiteral("Unfinished escape sequence in %1").arg(src);
return QString();
}
+
ch = src.at(pos);
- if (ch == 's') {
- dst += ' ';
- } else if (ch == 't') {
- dst += '\t';
- } else if (ch == 'n') {
- dst += '\n';
- } else if (ch == 'r') {
- dst += '\r';
- } else if (ch == '\\') {
- dst += '\\';
- } else if (ch == 'x') {
+ switch (ch.unicode()) {
+ case L's':
+ dst += QLatin1Char{' '};
+ break;
+ case L't':
+ dst += QLatin1Char{'\t'};
+ break;
+ case L'n':
+ dst += QLatin1Char{'\n'};
+ break;
+ case L'r':
+ dst += QLatin1Char{'\r'};
+ break;
+ case L'\\':
+ dst += QLatin1Char{'\\'};
+ break;
+ case L'x': {
if (pos + 2 < length) {
char value = src.midRef(pos + 1, 2).toInt(ok, 16);
if (*ok) {
- dst += QChar::fromLatin1(value);
+ dst += QLatin1Char{value};
pos += 2;
} else {
*error = QStringLiteral("Invalid hex escape sequence at column %1 in %2").arg(pos).arg(src);
@@ -96,11 +103,15 @@ QString unescapeString(const QString &src, bool *ok, QString *error)
*error = QStringLiteral("Unfinished hex escape sequence at column %1 in %2").arg(pos).arg(src);
return QString();
}
- } else {
+
+ break;
+ }
+ default: {
*ok = false;
*error = QStringLiteral("Invalid escape sequence at column %1 in %2").arg(pos).arg(src);
return QString();
}
+ }
}
}