summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsettings_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qsettings_win.cpp')
-rw-r--r--src/corelib/io/qsettings_win.cpp88
1 files changed, 27 insertions, 61 deletions
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 5146009c71..e88d738fe4 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsettings.h"
@@ -60,6 +24,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/* Keys are stored in QStrings. If the variable name starts with 'u', this is a "user"
key, ie. "foo/bar/alpha/beta". If the variable name starts with 'r', this is a "registry"
key, ie. "\foo\bar\alpha\beta". */
@@ -76,7 +42,7 @@ static const REGSAM registryPermissions = KEY_READ | KEY_WRITE;
static QString keyPath(const QString &rKey)
{
- int idx = rKey.lastIndexOf(QLatin1Char('\\'));
+ int idx = rKey.lastIndexOf(u'\\');
if (idx == -1)
return QString();
return rKey.left(idx + 1);
@@ -84,7 +50,7 @@ static QString keyPath(const QString &rKey)
static QString keyName(const QString &rKey)
{
- int idx = rKey.lastIndexOf(QLatin1Char('\\'));
+ int idx = rKey.lastIndexOf(u'\\');
QString res;
if (idx == -1)
@@ -92,8 +58,8 @@ static QString keyName(const QString &rKey)
else
res = rKey.mid(idx + 1);
- if (res == QLatin1String("Default") || res == QLatin1String("."))
- res = QLatin1String("");
+ if (res == "Default"_L1 || res == "."_L1)
+ res = ""_L1;
return res;
}
@@ -248,7 +214,7 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS
continue;
}
if (item.isEmpty())
- item = QLatin1String(".");
+ item = "."_L1;
result.append(item);
}
return result;
@@ -267,7 +233,7 @@ static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result,
for (int i = 0; i < childKeys.size(); ++i) {
QString s = rSubKey;
if (!s.isEmpty())
- s += QLatin1Char('\\');
+ s += u'\\';
s += childKeys.at(i);
result->insert(s, QString());
}
@@ -275,7 +241,7 @@ static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result,
for (int i = 0; i < childGroups.size(); ++i) {
QString s = rSubKey;
if (!s.isEmpty())
- s += QLatin1Char('\\');
+ s += u'\\';
s += childGroups.at(i);
allKeys(parentHandle, s, result, access);
}
@@ -411,9 +377,9 @@ QWinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString &
deleteWriteHandleOnExit = false;
if (!organization.isEmpty()) {
- QString prefix = QLatin1String("Software\\") + organization;
- QString orgPrefix = prefix + QLatin1String("\\OrganizationDefaults");
- QString appPrefix = prefix + QLatin1Char('\\') + application;
+ QString prefix = "Software\\"_L1 + organization;
+ QString orgPrefix = prefix + "\\OrganizationDefaults"_L1;
+ QString appPrefix = prefix + u'\\' + application;
if (scope == QSettings::UserScope) {
if (!application.isEmpty())
@@ -438,34 +404,34 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath, REGSAM access)
{
deleteWriteHandleOnExit = false;
- if (rPath.startsWith(QLatin1Char('\\')))
+ if (rPath.startsWith(u'\\'))
rPath.remove(0, 1);
int keyLength;
HKEY keyName;
- if (rPath.startsWith(QLatin1String("HKEY_CURRENT_USER"))) {
+ if (rPath.startsWith("HKEY_CURRENT_USER"_L1)) {
keyLength = 17;
keyName = HKEY_CURRENT_USER;
- } else if (rPath.startsWith(QLatin1String("HKCU"))) {
+ } else if (rPath.startsWith("HKCU"_L1)) {
keyLength = 4;
keyName = HKEY_CURRENT_USER;
- } else if (rPath.startsWith(QLatin1String("HKEY_LOCAL_MACHINE"))) {
+ } else if (rPath.startsWith("HKEY_LOCAL_MACHINE"_L1)) {
keyLength = 18;
keyName = HKEY_LOCAL_MACHINE;
- } else if (rPath.startsWith(QLatin1String("HKLM"))) {
+ } else if (rPath.startsWith("HKLM"_L1)) {
keyLength = 4;
keyName = HKEY_LOCAL_MACHINE;
- } else if (rPath.startsWith(QLatin1String("HKEY_CLASSES_ROOT"))) {
+ } else if (rPath.startsWith("HKEY_CLASSES_ROOT"_L1)) {
keyLength = 17;
keyName = HKEY_CLASSES_ROOT;
- } else if (rPath.startsWith(QLatin1String("HKCR"))) {
+ } else if (rPath.startsWith("HKCR"_L1)) {
keyLength = 4;
keyName = HKEY_CLASSES_ROOT;
- } else if (rPath.startsWith(QLatin1String("HKEY_USERS"))) {
+ } else if (rPath.startsWith("HKEY_USERS"_L1)) {
keyLength = 10;
keyName = HKEY_USERS;
- } else if (rPath.startsWith(QLatin1String("HKU"))) {
+ } else if (rPath.startsWith("HKU"_L1)) {
keyLength = 3;
keyName = HKEY_USERS;
} else {
@@ -474,7 +440,7 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath, REGSAM access)
if (rPath.length() == keyLength)
regList.append(RegistryKey(keyName, QString(), false, access));
- else if (rPath[keyLength] == QLatin1Char('\\'))
+ else if (rPath[keyLength] == u'\\')
regList.append(RegistryKey(keyName, rPath.mid(keyLength+1), false, access));
}
@@ -773,7 +739,7 @@ QStringList QWinSettingsPrivate::children(const QString &uKey, ChildSpec spec) c
if (spec == AllKeys) {
NameSet keys;
- allKeys(handle, QLatin1String(""), &keys, access);
+ allKeys(handle, ""_L1, &keys, access);
mergeKeySets(&result, keys);
} else { // ChildGroups or ChildKeys
QStringList names = childKeysOrGroups(handle, spec);
@@ -813,9 +779,9 @@ QString QWinSettingsPrivate::fileName() const
const RegistryKey &key = regList.at(0);
QString result;
if (key.parentHandle() == HKEY_CURRENT_USER)
- result = QLatin1String("\\HKEY_CURRENT_USER\\");
+ result = "\\HKEY_CURRENT_USER\\"_L1;
else
- result = QLatin1String("\\HKEY_LOCAL_MACHINE\\");
+ result = "\\HKEY_LOCAL_MACHINE\\"_L1;
return result + regList.at(0).key();
}