OSDN Git Service

rework QSettings, use JSON as native format for it
authorIvailo Monev <xakepa10@laimg.moc>
Mon, 23 Dec 2019 21:05:10 +0000 (21:05 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Tue, 24 Dec 2019 01:30:39 +0000 (01:30 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
24 files changed:
src/core/io/qsettings.cpp
src/core/io/qsettings.h
src/core/io/qsettings_p.h
src/core/json/qjsonvalue.cpp
src/core/kernel/qcoreapplication.cpp
src/designer/shared/pluginmanager.cpp
src/designer/shared/qdesigner_qsettings.cpp
src/designer/shared/qdesigner_qsettings_p.h
src/gui/dialogs/qcolordialog.cpp
src/gui/dialogs/qfiledialog.cpp
src/gui/image/qiconloader.cpp
src/gui/kernel/qapplication_x11.cpp
src/gui/painting/qprintengine_ps.cpp
src/scripttools/debugging/qscriptenginedebugger.cpp
src/tools/qtconfig/mainwindow.cpp
tests/auto/qsettings/.gitattributes [deleted file]
tests/auto/qsettings/CMakeLists.txt
tests/auto/qsettings/qsettings.qrc [deleted file]
tests/auto/qsettings/resourcefile.ini [deleted file]
tests/auto/qsettings/resourcefile2.ini [deleted file]
tests/auto/qsettings/resourcefile3.ini [deleted file]
tests/auto/qsettings/resourcefile4.ini [deleted file]
tests/auto/qsettings/resourcefile5.ini [deleted file]
tests/auto/qsettings/tst_qsettings.cpp

index 8de70f6..bc8610b 100644 (file)
 #include "qdebug.h"
 #include "qplatformdefs.h"
 #include "qsettings.h"
+#include "qjsondocument.h"
+#include "qjsonobject.h"
+#include "qstandardpaths.h"
+#include "qmutex.h"
+#include "qcoreapplication.h"
+#include "qlibraryinfo.h"
 
 #ifndef QT_NO_SETTINGS
 
 #include "qsettings_p.h"
-#include "qcache.h"
 #include "qfile.h"
 #include "qdir.h"
-#include "qfileinfo.h"
-#include "qmutex.h"
-#include "qlibraryinfo.h"
-#include "qtemporaryfile.h"
-#include "qcoreapplication.h"
-
-#ifndef QT_NO_TEXTCODEC
-#  include "qtextcodec.h"
-#endif
 
 #ifndef QT_NO_GEOM_VARIANT
 #include "qsize.h"
 
 #include <stdlib.h>
 
-#ifdef Q_AUTOTEST_EXPORT
-#  define Q_AUTOTEST_EXPORT_HELPER Q_AUTOTEST_EXPORT
-#else
-#  define Q_AUTOTEST_EXPORT_HELPER static
-#endif
-
-// ************************************************************************
-// QConfFile
-
-/*
-    QConfFile objects are explicitly shared within the application.
-    This ensures that modification to the settings done through one
-    QSettings object are immediately reflected in other setting
-    objects of the same application.
-*/
-
 QT_BEGIN_NAMESPACE
 
-struct QConfFileCustomFormat
+struct QSettingsCustomFormat
 {
+    QSettings::Format format;
     QString extension;
     QSettings::ReadFunc readFunc;
     QSettings::WriteFunc writeFunc;
-    Qt::CaseSensitivity caseSensitivity;
 };
 
-typedef QHash<QString, QConfFile *> ConfFileHash;
-typedef QCache<QString, QConfFile> ConfFileCache;
-typedef QHash<int, QString> PathHash;
-typedef QVector<QConfFileCustomFormat> CustomFormatVector;
-
-Q_GLOBAL_STATIC(ConfFileHash, usedHashFunc)
-Q_GLOBAL_STATIC(ConfFileCache, unusedCacheFunc)
-Q_GLOBAL_STATIC(PathHash, pathHashFunc)
+typedef QVector<QSettingsCustomFormat> CustomFormatVector;
+typedef QVector<QSettings*> QSettingsVector;
+Q_GLOBAL_STATIC(QSettingsVector, qGlobalSettings)
 Q_GLOBAL_STATIC(CustomFormatVector, customFormatVectorFunc)
-Q_GLOBAL_STATIC(QMutex, globalMutex)
-static QSettings::Format globalDefaultFormat = QSettings::NativeFormat;
+Q_GLOBAL_STATIC(QMutex, qSettingsMutex)
 
-inline bool qt_isEvilFsTypeName(const char *name)
+static inline bool qt_isEvilFsTypeName(const char *name)
 {
     return (qstrncmp(name, "nfs", 3) == 0
             || qstrncmp(name, "autofs", 6) == 0
@@ -110,7 +84,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
 # include <sys/mount.h>
 QT_END_INCLUDE_NAMESPACE
 
-Q_AUTOTEST_EXPORT_HELPER bool qIsLikelyToBeNfs(int handle)
+static inline bool qIsLikelyToBeNfs(int handle)
 {
     struct statfs buf;
     if (fstatfs(handle, &buf) != 0)
@@ -136,7 +110,7 @@ QT_END_INCLUDE_NAMESPACE
 #  define AUTOFSNG_SUPER_MAGIC  0x7d92b1a0
 # endif
 
-Q_AUTOTEST_EXPORT_HELPER bool qIsLikelyToBeNfs(int handle)
+static inline bool qIsLikelyToBeNfs(int handle)
 {
     struct statfs buf;
     if (fstatfs(handle, &buf) != 0)
@@ -153,7 +127,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
 # include <sys/statvfs.h>
 QT_END_INCLUDE_NAMESPACE
 
-Q_AUTOTEST_EXPORT_HELPER bool qIsLikelyToBeNfs(int handle)
+static inline bool qIsLikelyToBeNfs(int handle)
 {
     struct statvfs buf;
     if (fstatvfs(handle, &buf) != 0)
@@ -165,7 +139,7 @@ Q_AUTOTEST_EXPORT_HELPER bool qIsLikelyToBeNfs(int handle)
 #endif
 }
 #else
-Q_AUTOTEST_EXPORT_HELPER inline bool qIsLikelyToBeNfs(int /* handle */)
+static inline inline bool qIsLikelyToBeNfs(int /* handle */)
 {
     return true;
 }
@@ -190,237 +164,291 @@ static bool unixLock(int handle, int lockType)
     return fcntl(handle, F_SETLKW, &fl) == 0;
 }
 
-QConfFile::QConfFile(const QString &fileName, bool _userPerms)
-    : name(fileName), size(0), ref(1), userPerms(_userPerms)
+// ************************************************************************
+// Native format
+static bool json_settings_read(QIODevice &device, QSettings::SettingsMap &map)
 {
-    usedHashFunc()->insert(name, this);
-}
+    QByteArray data = device.readAll();
+    if (Q_UNLIKELY(data.isEmpty())) {
+        return false;
+    }
 
-QConfFile::~QConfFile()
-{
-    if (usedHashFunc())
-        usedHashFunc()->remove(name);
+    QJsonDocument jsondoc = QJsonDocument::fromJson(data);
+    if (Q_UNLIKELY(jsondoc.isNull())) {
+        return false;
+    }
+
+    map = jsondoc.object().toVariantMap();
+
+    // qDebug() << "json_settings_read" << jsondoc.toJson();
+    return true;
 }
 
-ParsedSettingsMap QConfFile::mergedKeyMap() const
+static bool json_settings_write(QIODevice &device, const QSettings::SettingsMap &map)
 {
-    ParsedSettingsMap result = originalKeys;
-    ParsedSettingsMap::const_iterator i;
+    QJsonDocument jsondoc = QJsonDocument(QJsonObject::fromVariantMap(map));
+    QByteArray jsondata = jsondoc.toJson();
+    if (Q_UNLIKELY(jsondoc.isNull() || jsondata.isNull())) {
+        return false;
+    }
 
-    for (i = removedKeys.begin(); i != removedKeys.end(); ++i)
-        result.remove(i.key());
-    for (i = addedKeys.begin(); i != addedKeys.end(); ++i)
-        result.insert(i.key(), i.value());
-    return result;
+    // qDebug() << "json_settings_write" << jsondata;
+    return device.write(jsondata);
 }
 
-bool QConfFile::isWritable() const
+// ************************************************************************
+// INI format
+static bool ini_settings_read(QIODevice &device, QSettings::SettingsMap &map)
 {
-    QFileInfo fileInfo(name);
+    QByteArray section; // keys without section are allowed
 
-#ifndef QT_NO_TEMPORARYFILE
-    if (fileInfo.exists()) {
-#endif
-        QFile file(name);
-        return file.open(QFile::ReadWrite);
-#ifndef QT_NO_TEMPORARYFILE
-    } else {
-        // Create the directories to the file.
-        QDir dir(fileInfo.absolutePath());
-        if (!dir.exists()) {
-            if (!dir.mkpath(dir.absolutePath()))
-                return false;
+    bool parsedsomething = false;
+    while (!device.atEnd()) {
+        const QByteArray line = device.readLine().trimmed();
+        if (line.isEmpty() || line.startsWith(';')) {
+            continue;
+        } else if (line.startsWith('[') && line.endsWith(']')) {
+            section = line.mid(1, line.size() - 2);
+            continue;
+        }
+
+        const QList<QByteArray> splitline = line.split('=');
+        if (splitline.size() < 2) {
+            continue;
+        }
+
+        const QByteArray key = splitline.at(0).trimmed();
+        const QByteArray value = splitline.at(1).trimmed();
+        const QVariant variantvalue = QSettingsPrivate::stringToVariant(value);
+        if (section.isEmpty()) {
+            map.insert(key, variantvalue);
+        } else {
+            const QString actualkey = section + QLatin1Char('/') + key;
+            map.insert(actualkey, variantvalue);
         }
 
-        // we use a temporary file to avoid race conditions
-        QTemporaryFile file(name);
-        return file.open();
+        parsedsomething = true;
     }
-#endif
+
+    // qDebug() << "ini_settings_read" << map;
+    return parsedsomething;
 }
 
-QConfFile *QConfFile::fromName(const QString &fileName, bool _userPerms)
+static bool ini_settings_write(QIODevice &device, const QSettings::SettingsMap &map)
 {
-    QString absPath = QFileInfo(fileName).absoluteFilePath();
+    QString lastsection;
+    foreach (const QString &key, map.keys()) {
+        QString section;
+        int keypos = 0;
+        const QList<QString> splitkey = key.split(QLatin1Char('/'));
+        if (splitkey.size() > 1) {
+            section = QLatin1Char('[') + splitkey.at(0) + QLatin1String("]\n");
+            keypos = 1;
+        }
+
+        QString keyname;
+        for (int i = keypos; i < splitkey.size(); i++) {
+            if (i == keypos) {
+                keyname += splitkey.at(i);
+            } else {
+                keyname += QLatin1Char('/') + splitkey.at(i);
+            }
+        }
 
-    ConfFileHash *usedHash = usedHashFunc();
-    ConfFileCache *unusedCache = unusedCacheFunc();
+        if (section != lastsection) {
+            // separate each section with two line separators, do only for
+            // sections after the first one
+            if (!lastsection.isEmpty() && !device.write("\n")) {
+                return false;
+            }
+            if (!section.isEmpty() && !device.write(section.toAscii())) {
+                return false;
+            }
+        }
+        lastsection = section;
 
-    QConfFile *confFile = Q_NULLPTR;
-    QMutexLocker locker(globalMutex());
+        if (!device.write(keyname.toAscii())) {
+            return false;
+        }
 
-    if (!(confFile = usedHash->value(absPath))) {
-        if ((confFile = unusedCache->take(absPath)))
-            usedHash->insert(absPath, confFile);
-    }
-    if (confFile) {
-        confFile->ref.ref();
-        return confFile;
+        const QString stringvalue = QSettingsPrivate::variantToString(map.value(key));
+        const QString datavalue = QLatin1Char('=') + stringvalue + QLatin1Char('\n');
+        if (!device.write(datavalue.toAscii())) {
+            return false;
+        }
+
+        // qDebug() << "ini_settings_write" << section << keyname << variantvalue;
     }
-    return new QConfFile(absPath, _userPerms);
-}
 
-void QConfFile::clearCache()
-{
-    QMutexLocker locker(globalMutex());
-    unusedCacheFunc()->clear();
+    return true;
 }
 
+
 // ************************************************************************
 // QSettingsPrivate
-
-QSettingsPrivate::QSettingsPrivate(QSettings::Format format)
-    : format(format), scope(QSettings::UserScope /* nothing better to put */), iniCodec(0), spec(0), fallbacks(true),
-      pendingChanges(false), status(QSettings::NoError)
+static QSettingsCustomFormat getSettingsFormat(QSettings::Format format)
 {
-}
+    QSettingsCustomFormat result;
 
-QSettingsPrivate::QSettingsPrivate(QSettings::Format format, QSettings::Scope scope,
-                                   const QString &organization, const QString &application)
-    : format(format), scope(scope), organizationName(organization), applicationName(application),
-      iniCodec(0), spec(0), fallbacks(true), pendingChanges(false), status(QSettings::NoError)
-{
-}
+    if (format == QSettings::NativeFormat) {
+        result.extension = QLatin1String(".json");
+        result.readFunc = json_settings_read;
+        result.writeFunc = json_settings_write;
+        return result;
+    } else if (format == QSettings::IniFormat) {
+        result.extension = QLatin1String(".ini");
+        result.readFunc = ini_settings_read;
+        result.writeFunc = ini_settings_write;
+        return result;
+    }
 
-QSettingsPrivate::~QSettingsPrivate()
-{
+    QMutexLocker locker(qSettingsMutex());
+    const CustomFormatVector *customFormatVector = customFormatVectorFunc();
+    for (int i = 0; i < customFormatVector->size(); i++) {
+        const QSettingsCustomFormat &custom = customFormatVector->at(i);
+        if (custom.format == format) {
+            result.extension = custom.extension;
+            result.readFunc = custom.readFunc;
+            result.writeFunc = custom.writeFunc;
+            return result;
+        }
+    }
+
+    qWarning("QSettingsPrivate::getSettingsFormat: format not found %d", format);
+    result.extension = QLatin1String(".json");
+    result.readFunc = json_settings_read;
+    result.writeFunc = json_settings_write;
+    return result;
 }
 
-QString QSettingsPrivate::actualKey(const QString &key) const
+QString getSettingsPath(QSettings::Scope scope, const QString &filename, const QString &extension)
 {
-    QString n = normalizedKey(key);
-    Q_ASSERT_X(!n.isEmpty(), "QSettings", "empty key");
-    n.prepend(groupPrefix);
-    return n;
-}
+    QFileInfo info(filename);
+    if (info.isAbsolute()) {
+        return filename;
+    }
 
-/*
-    Returns a string that never starts nor ends with a slash (or an
-    empty string). Examples:
+    QString nameandext = filename;
+    if (!filename.endsWith(extension)) {
+        nameandext += extension;
+    }
 
-            "foo"            becomes   "foo"
-            "/foo//bar///"   becomes   "foo/bar"
-            "///"            becomes   ""
+    QStringList locations = QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
+    if (scope == QSettings::UserScope) {
+        locations = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
+    }
 
-    This function is optimized to avoid a QString deep copy in the
-    common case where the key is already normalized.
-*/
-QString QSettingsPrivate::normalizedKey(const QString &key)
-{
-    QString result = key;
-
-    int i = 0;
-    while (i < result.size()) {
-        while (result.at(i) == QLatin1Char('/')) {
-            result.remove(i, 1);
-            if (i == result.size())
-                goto after_loop;
-        }
-        while (result.at(i) != QLatin1Char('/')) {
-            ++i;
-            if (i == result.size())
-                return result;
+    foreach (const QString &location, locations) {
+        QDir dir(location);
+        if (dir.exists(location)) {
+            return location + QDir::separator() + nameandext;
         }
-        ++i; // leave the slash alone
     }
 
-after_loop:
-    if (!result.isEmpty())
-        result.truncate(i - 1); // remove the trailing slash
-    return result;
+    const QString fallback = QLibraryInfo::location(QLibraryInfo::SettingsPath);
+    QDir fallbackdir(fallback);
+    if (!fallbackdir.mkpath(fallback)) {
+        qWarning("QSettingsPrivate::getSettingsPath: no settings location");
+        fallbackdir.currentPath() + QDir::separator() + nameandext;
+    }
+    return fallback + QDir::separator() + nameandext;
 }
 
-QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope,
-                                           const QString &organization, const QString &application)
+QSettingsPrivate::QSettingsPrivate(QSettings::Format format, QSettings::Scope scope)
+    : format(format), scope(scope), status(QSettings::NoError)
 {
-    return new QConfFileSettingsPrivate(format, scope, organization, application);
+    QSettingsCustomFormat handler = getSettingsFormat(format);
+    filename = getSettingsPath(scope, QCoreApplication::applicationName(), handler.extension);
+    readFunc = handler.readFunc;
+    writeFunc = handler.writeFunc;
 }
 
-QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format)
+QSettingsPrivate::QSettingsPrivate(const QString &fileName, QSettings::Format format)
+    : format(format), scope(QSettings::UserScope), status(QSettings::NoError)
 {
-    return new QConfFileSettingsPrivate(fileName, format);
+    QSettingsCustomFormat handler = getSettingsFormat(format);
+    filename = getSettingsPath(scope, fileName, handler.extension);
+    readFunc = handler.readFunc;
+    writeFunc = handler.writeFunc;
 }
 
-void QSettingsPrivate::processChild(QString key, ChildSpec spec, QMap<QString, QString> &result)
+QSettingsPrivate::~QSettingsPrivate()
 {
-    if (spec != AllKeys) {
-        int slashPos = key.indexOf(QLatin1Char('/'));
-        if (slashPos == -1) {
-            if (spec != ChildKeys)
-                return;
-        } else {
-            if (spec != ChildGroups)
-                return;
-            key.truncate(slashPos);
-        }
-    }
-    result.insert(key, QString());
 }
 
-void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group)
+void QSettingsPrivate::read()
 {
-    groupStack.push(group);
-    if (!group.name().isEmpty()) {
-        groupPrefix += group.name();
-        groupPrefix += QLatin1Char('/');
+    QFileInfo info(filename);
+    if (!info.isReadable() || info.size() == 0) {
+        status = QSettings::AccessError;
+        // no warning, info.exists() may return false if not readable
+        return;
     }
-}
 
-/*
-    We only set an error if there isn't one set already. This way the user always gets the
-    first error that occurred. We always allow clearing errors.
-*/
+    QFile file(filename);
+    if (Q_UNLIKELY(!file.open(QFile::ReadOnly))) {
+        status = QSettings::AccessError;
+        qWarning("QSettingsPrivate::read: failed to open %s", filename.toLocal8Bit().constData());
+        return;
+    }
 
-void QSettingsPrivate::setStatus(QSettings::SettingsStatus status) const
-{
-    if (status == QSettings::NoError || this->status == QSettings::NoError)
-        this->status = status;
-}
+    if (Q_UNLIKELY(!unixLock(file.handle(), F_RDLCK))) {
+        status = QSettings::AccessError;
+        qWarning("QSettingsPrivate::read: failed to lock %s", filename.toLocal8Bit().constData());
+        return;
+    }
 
-void QSettingsPrivate::update()
-{
-    sync();
-    pendingChanges = false;
-}
+    QSettings::SettingsMap syncMap;
+    if (Q_UNLIKELY(!readFunc(file, syncMap))) {
+        status = QSettings::FormatError;
+        qWarning("QSettingsPrivate::read: could not read %s", filename.toLocal8Bit().constData());
+        return;
+    }
 
-void QSettingsPrivate::requestUpdate()
-{
-    if (!pendingChanges) {
-        pendingChanges = true;
-        Q_Q(QSettings);
-        QCoreApplication::postEvent(q, new QEvent(QEvent::UpdateRequest));
+    foreach (const QString &key, syncMap.keys()) {
+        map.insert(key, syncMap.value(key));
     }
+
+    timestamp = info.lastModified();
 }
 
-QStringList QSettingsPrivate::variantListToStringList(const QVariantList &l)
+void QSettingsPrivate::write()
 {
-    QStringList result;
-    result.reserve(l.count());
-    foreach (const QVariant &v, l)
-        result.append(variantToString(v));
-    return result;
+    QFileInfo info(filename);
+    const QDateTime newstamp = info.lastModified();
+    if (timestamp < newstamp || !newstamp.isValid()) {
+        QSettingsPrivate::read();
+    }
+
+    QFile file(filename);
+    if (Q_UNLIKELY(!file.open(QFile::WriteOnly))) {
+        status = QSettings::AccessError;
+        qWarning("QSettingsPrivate::write: failed to open %s", filename.toLocal8Bit().constData());
+        return;
+    }
+
+    if (Q_UNLIKELY(!unixLock(file.handle(), F_WRLCK))) {
+        status = QSettings::AccessError;
+        qWarning("QSettingsPrivate::write: failed to lock %s", filename.toLocal8Bit().constData());
+        return;
+    }
+
+    if (Q_UNLIKELY(!writeFunc(file, map))) {
+        status = QSettings::FormatError;
+        qWarning("QSettingsPrivate::write: could not write %s", filename.toLocal8Bit().constData());
+    }
 }
 
-QVariant QSettingsPrivate::stringListToVariantList(const QStringList &l)
+void QSettingsPrivate::notify()
 {
-    QStringList outStringList = l;
-    for (int i = 0; i < outStringList.count(); ++i) {
-        const QString &str = outStringList.at(i);
-
-        if (str.startsWith(QLatin1Char('@'))) {
-            if (str.length() >= 2 && str.at(1) == QLatin1Char('@')) {
-                outStringList[i].remove(0, 1);
-            } else {
-                QVariantList variantList;
-                const int stringCount = l.count();
-                variantList.reserve(stringCount);
-                for (int j = 0; j < stringCount; ++j)
-                    variantList.append(stringToVariant(l.at(j)));
-                return variantList;
-            }
+    Q_Q(QSettings);
+    QMutexLocker locker(qSettingsMutex());
+    for (int i = 0; i < qGlobalSettings()->size(); i++) {
+        QSettings *setting = qGlobalSettings()->at(i);
+        if (setting != q && setting->fileName() == q->fileName()) {
+            setting->d_func()->map = map;
         }
     }
-    return outStringList;
 }
 
 QString QSettingsPrivate::variantToString(const QVariant &v)
@@ -546,377 +574,13 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s)
         }
         if (s.startsWith(QLatin1String("@@")))
             return QVariant(s.mid(1));
+    } else if (s.contains(QLatin1Char(','))) {
+        return QVariant(s.split(QLatin1Char(',')));
     }
 
     return QVariant(s);
 }
 
-static const char hexDigits[] = "0123456789ABCDEF";
-
-void QSettingsPrivate::iniEscapedKey(const QString &key, QByteArray &result)
-{
-    result.reserve(result.length() + key.length() * 3 / 2);
-    for (int i = 0; i < key.size(); ++i) {
-        uint ch = key.at(i).unicode();
-
-        if (ch == '/') {
-            result += '\\';
-        } else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')
-                || ch == '_' || ch == '-' || ch == '.') {
-            result += (char)ch;
-        } else if (ch <= 0xFF) {
-            result += '%';
-            result += hexDigits[ch / 16];
-            result += hexDigits[ch % 16];
-        } else {
-            result += "%U";
-            QByteArray hexCode;
-            for (int i = 0; i < 4; ++i) {
-                hexCode.prepend(hexDigits[ch % 16]);
-                ch >>= 4;
-            }
-            result += hexCode;
-        }
-    }
-}
-
-bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to, QString &result)
-{
-    bool lowercaseOnly = true;
-    int i = from;
-    result.reserve(result.length() + (to - from));
-    while (i < to) {
-        int ch = (uchar)key.at(i);
-
-        if (ch == '\\') {
-            result += QLatin1Char('/');
-            ++i;
-            continue;
-        }
-
-        if (ch != '%' || i == to - 1) {
-            if (uint(ch - 'A') <= 'Z' - 'A') // only for ASCII
-                lowercaseOnly = false;
-            result += QLatin1Char(ch);
-            ++i;
-            continue;
-        }
-
-        int numDigits = 2;
-        int firstDigitPos = i + 1;
-
-        ch = key.at(i + 1);
-        if (ch == 'U') {
-            ++firstDigitPos;
-            numDigits = 4;
-        }
-
-        if (firstDigitPos + numDigits > to) {
-            result += QLatin1Char('%');
-            // ### missing U
-            ++i;
-            continue;
-        }
-
-        bool ok;
-        ch = key.mid(firstDigitPos, numDigits).toInt(&ok, 16);
-        if (!ok) {
-            result += QLatin1Char('%');
-            // ### missing U
-            ++i;
-            continue;
-        }
-
-        QChar qch(ch);
-        if (qch.isUpper())
-            lowercaseOnly = false;
-        result += qch;
-        i = firstDigitPos + numDigits;
-    }
-    return lowercaseOnly;
-}
-
-void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, QTextCodec *codec)
-{
-    bool needsQuotes = false;
-    bool escapeNextIfDigit = false;
-    bool useCodec = codec && !str.startsWith(QLatin1String("@ByteArray("))
-                    && !str.startsWith(QLatin1String("@Variant("));
-
-    int i;
-    int startPos = result.size();
-
-    result.reserve(startPos + str.size() * 3 / 2);
-    for (i = 0; i < str.size(); ++i) {
-        uint ch = str.at(i).unicode();
-        if (ch == ';' || ch == ',' || ch == '=')
-            needsQuotes = true;
-
-        if (escapeNextIfDigit
-                && ((ch >= '0' && ch <= '9')
-                    || (ch >= 'a' && ch <= 'f')
-                    || (ch >= 'A' && ch <= 'F'))) {
-            result += "\\x";
-            result += QByteArray::number(ch, 16);
-            continue;
-        }
-
-        escapeNextIfDigit = false;
-
-        switch (ch) {
-        case '\0':
-            result += "\\0";
-            escapeNextIfDigit = true;
-            break;
-        case '\a':
-            result += "\\a";
-            break;
-        case '\b':
-            result += "\\b";
-            break;
-        case '\f':
-            result += "\\f";
-            break;
-        case '\n':
-            result += "\\n";
-            break;
-        case '\r':
-            result += "\\r";
-            break;
-        case '\t':
-            result += "\\t";
-            break;
-        case '\v':
-            result += "\\v";
-            break;
-        case '"':
-        case '\\':
-            result += '\\';
-            result += (char)ch;
-            break;
-        default:
-            if (ch <= 0x1F || (ch >= 0x7F && !useCodec)) {
-                result += "\\x";
-                result += QByteArray::number(ch, 16);
-                escapeNextIfDigit = true;
-#ifndef QT_NO_TEXTCODEC
-            } else if (useCodec) {
-                // slow
-                result += codec->fromUnicode(str.at(i));
-#endif
-            } else {
-                result += (char)ch;
-            }
-        }
-    }
-
-    if (needsQuotes
-            || (startPos < result.size() && (result.at(startPos) == ' '
-                                                || result.at(result.size() - 1) == ' '))) {
-        result.insert(startPos, '"');
-        result += '"';
-    }
-}
-
-inline static void iniChopTrailingSpaces(QString &str)
-{
-    int n = str.size() - 1;
-    QChar ch;
-    while (n >= 0 && ((ch = str.at(n)) == QLatin1Char(' ') || ch == QLatin1Char('\t')))
-        str.truncate(n--);
-}
-
-void QSettingsPrivate::iniEscapedStringList(const QStringList &strs, QByteArray &result, QTextCodec *codec)
-{
-    if (strs.isEmpty()) {
-        /*
-            We need to distinguish between empty lists and one-item
-            lists that contain an empty string. Ideally, we'd have a
-            @EmptyList() symbol but that would break compatibility
-            with Qt 4.0. @Invalid() stands for QVariant(), and
-            QVariant().toStringList() returns an empty QStringList,
-            so we're in good shape.
-
-            ### Qt 5: Use a nicer syntax, e.g. @List, for variant lists
-        */
-        result += "@Invalid()";
-    } else {
-        for (int i = 0; i < strs.size(); ++i) {
-            if (i != 0)
-                result += ", ";
-            iniEscapedString(strs.at(i), result, codec);
-        }
-    }
-}
-
-bool QSettingsPrivate::iniUnescapedStringList(const QByteArray &str, int from, int to,
-                                              QString &stringResult, QStringList &stringListResult,
-                                              QTextCodec *codec)
-{
-#ifdef QT_NO_TEXTCODE
-    Q_UNUSED(codec);
-#endif
-    static const char escapeCodes[][2] =
-    {
-        { 'a', '\a' },
-        { 'b', '\b' },
-        { 'f', '\f' },
-        { 'n', '\n' },
-        { 'r', '\r' },
-        { 't', '\t' },
-        { 'v', '\v' },
-        { '"', '"' },
-        { '?', '?' },
-        { '\'', '\'' },
-        { '\\', '\\' }
-    };
-    static const int numEscapeCodes = sizeof(escapeCodes) / sizeof(escapeCodes[0]);
-
-    bool isStringList = false;
-    bool inQuotedString = false;
-    bool currentValueIsQuoted = false;
-    int escapeVal = 0;
-    int i = from;
-    char ch;
-
-StSkipSpaces:
-    while (i < to && ((ch = str.at(i)) == ' ' || ch == '\t'))
-        ++i;
-    // fallthrough
-
-StNormal:
-    while (i < to) {
-        switch (str.at(i)) {
-        case '\\':
-            ++i;
-            if (i >= to)
-                goto end;
-
-            ch = str.at(i++);
-            for (int j = 0; j < numEscapeCodes; ++j) {
-                if (ch == escapeCodes[j][0]) {
-                    stringResult += QLatin1Char(escapeCodes[j][1]);
-                    goto StNormal;
-                }
-            }
-
-            if (ch == 'x') {
-                escapeVal = 0;
-
-                if (i >= to)
-                    goto end;
-
-                ch = str.at(i);
-                if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f'))
-                    goto StHexEscape;
-            } else if (ch >= '0' && ch <= '7') {
-                escapeVal = ch - '0';
-                goto StOctEscape;
-            } else if (ch == '\n' || ch == '\r') {
-                if (i < to) {
-                    char ch2 = str.at(i);
-                    // \n, \r, \r\n, and \n\r are legitimate line terminators in INI files
-                    if ((ch2 == '\n' || ch2 == '\r') && ch2 != ch)
-                        ++i;
-                }
-            } else {
-                // the character is skipped
-            }
-            break;
-        case '"':
-            ++i;
-            currentValueIsQuoted = true;
-            inQuotedString = !inQuotedString;
-            if (!inQuotedString)
-                goto StSkipSpaces;
-            break;
-        case ',':
-            if (!inQuotedString) {
-                if (!currentValueIsQuoted)
-                    iniChopTrailingSpaces(stringResult);
-                if (!isStringList) {
-                    isStringList = true;
-                    stringListResult.clear();
-                    stringResult.squeeze();
-                }
-                stringListResult.append(stringResult);
-                stringResult.clear();
-                currentValueIsQuoted = false;
-                ++i;
-                goto StSkipSpaces;
-            }
-            // fallthrough
-        default: {
-            int j = i + 1;
-            while (j < to) {
-                ch = str.at(j);
-                if (ch == '\\' || ch == '"' || ch == ',')
-                    break;
-                ++j;
-            }
-
-#ifndef QT_NO_TEXTCODEC
-            if (codec) {
-                stringResult += codec->toUnicode(str.constData() + i, j - i);
-            } else
-#endif
-            {
-                int n = stringResult.size();
-                stringResult.resize(n + (j - i));
-                QChar *resultData = stringResult.data() + n;
-                for (int k = i; k < j; ++k)
-                    *resultData++ = QLatin1Char(str.at(k));
-            }
-            i = j;
-        }
-        }
-    }
-    goto end;
-
-StHexEscape:
-    if (i >= to) {
-        stringResult += QChar(escapeVal);
-        goto end;
-    }
-
-    ch = str.at(i);
-    if (ch >= 'a')
-        ch -= 'a' - 'A';
-    if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F')) {
-        escapeVal <<= 4;
-        escapeVal += strchr(hexDigits, ch) - hexDigits;
-        ++i;
-        goto StHexEscape;
-    } else {
-        stringResult += QChar(escapeVal);
-        goto StNormal;
-    }
-
-StOctEscape:
-    if (i >= to) {
-        stringResult += QChar(escapeVal);
-        goto end;
-    }
-
-    ch = str.at(i);
-    if (ch >= '0' && ch <= '7') {
-        escapeVal <<= 3;
-        escapeVal += ch - '0';
-        ++i;
-        goto StOctEscape;
-    } else {
-        stringResult += QChar(escapeVal);
-        goto StNormal;
-    }
-
-end:
-    if (!currentValueIsQuoted)
-        iniChopTrailingSpaces(stringResult);
-    if (isStringList)
-        stringListResult.append(stringResult);
-    return isStringList;
-}
-
 QStringList QSettingsPrivate::splitArgs(const QString &s, int idx)
 {
     int l = s.length();
@@ -943,964 +607,59 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx)
     return result;
 }
 
-// ************************************************************************
-// QConfFileSettingsPrivate
+/*!
+    \class QSettings
+    \brief The QSettings class provides persistent platform-independent application settings.
 
-void QConfFileSettingsPrivate::initFormat()
-{
-    extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini");
-    readFunc = 0;
-    writeFunc = 0;
-    caseSensitivity = IniCaseSensitivity;
-
-    if (format > QSettings::IniFormat) {
-        QMutexLocker locker(globalMutex());
-        const CustomFormatVector *customFormatVector = customFormatVectorFunc();
-
-        int i = (int)format - (int)QSettings::CustomFormat1;
-        if (i >= 0 && i < customFormatVector->size()) {
-            QConfFileCustomFormat info = customFormatVector->at(i);
-            extension = info.extension;
-            readFunc = info.readFunc;
-            writeFunc = info.writeFunc;
-            caseSensitivity = info.caseSensitivity;
-        }
-    }
-}
+    \ingroup io
 
-void QConfFileSettingsPrivate::initAccess()
-{
-    if (confFiles[spec]) {
-        if (format > QSettings::IniFormat) {
-            if (!readFunc)
-                setStatus(QSettings::AccessError);
-        }
-    }
+    \reentrant
 
-    sync();       // loads the files the first time
-}
+    Users normally expect an application to remember its settings
+    (window sizes and positions, options, etc.) across sessions.
+    On Unix systems, in the absence of a standard, many applications
+    (including the KDE applications) use INI text files.
 
-static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope)
-{
-    return int((uint(format) << 1) | uint(scope == QSettings::SystemScope));
-}
+    QSettings is an abstraction around these technologies, enabling
+    you to save and restore application settings in a portable
+    manner. It also supports \l{registerFormat()}{custom storage
+    formats}.
 
-static void initDefaultPaths(QMutexLocker *locker)
-{
-    PathHash *pathHash = pathHashFunc();
-    QString homePath = QDir::homePath();
-    QString systemPath;
+    QSettings's API is based on QVariant, allowing you to save
+    most value-based types, such as QString, QRect, and QImage,
+    with the minimum of effort.
 
-    locker->unlock();
+    If all you need is a non-persistent memory-based structure,
+    consider using QMap<QString, QVariant> instead.
 
-    /*
-       QLibraryInfo::location() uses QSettings, so in order to
-       avoid a dead-lock, we can't hold the global mutex while
-       calling it.
-    */
-    systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath);
-    systemPath += QLatin1Char('/');
-
-    locker->relock();
-    if (pathHash->isEmpty()) {
-        /*
-           Lazy initialization of pathHash. We initialize the
-           IniFormat paths and (on Unix) the NativeFormat paths.
-       */
-        QString userPath;
-        char *env = getenv("XDG_CONFIG_HOME");
-        if (env == 0) {
-            userPath = homePath + QLatin1Char('/') + QLatin1String(".config");
-        } else if (*env == '/') {
-            userPath = QFile::decodeName(env);
-        } else {
-            userPath = homePath + QLatin1Char('/') + QFile::decodeName(env);
-        }
-        userPath += QLatin1Char('/');
+    \tableofcontents section1
 
-        pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath);
-        pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), systemPath);
-        pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::UserScope), userPath);
-        pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::SystemScope), systemPath);
-    }
-}
+    \section1 Basic Usage
 
-static QString getPath(QSettings::Format format, QSettings::Scope scope)
-{
-    Q_ASSERT((int)QSettings::NativeFormat == 0);
-    Q_ASSERT((int)QSettings::IniFormat == 1);
+    If you use QSettings from many places in your application, you
+    might want to specify the application name using
+    QCoreApplication::setApplicationName() and then use the default
+    QSettings constructor:
 
-    QMutexLocker locker(globalMutex());
-    PathHash *pathHash = pathHashFunc();
-    if (pathHash->isEmpty())
-        initDefaultPaths(&locker);
+    QSettings stores settings. Each setting consists of a QString
+    that specifies the setting's name (the \e key) and a QVariant
+    that stores the data associated with the key. To write a setting,
+    use setValue().
 
-    QString result = pathHash->value(pathHashKey(format, scope));
-    if (!result.isEmpty())
-        return result;
+    If there already exists a setting with the same key, the existing
+    value is overwritten by the new value. For efficiency, the
+    changes may not be saved to permanent storage immediately. (You
+    can always call sync() to commit your changes.)
 
-    // fall back on INI path
-    return pathHash->value(pathHashKey(QSettings::IniFormat, scope));
-}
+    You can get a setting's value back using value(). If there is no
+    setting with the specified name, QSettings returns a null QVariant
+    (which can be converted to the integer 0). You can specify
+    another default value by passing a second argument to value():
 
-QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
-                                                   QSettings::Scope scope,
-                                                   const QString &organization,
-                                                   const QString &application)
-    : QSettingsPrivate(format, scope, organization, application),
-      nextPosition(0x40000000) // big positive number
-{
-    int i;
-    initFormat();
-
-    QString org = organization;
-    if (org.isEmpty()) {
-        setStatus(QSettings::AccessError);
-        org = QLatin1String("Unknown Organization");
-    }
-
-    const QString appFile = org + QDir::separator() + application + extension;
-    const QString orgFile = org + extension;
-
-    if (scope == QSettings::UserScope) {
-        const QString userPath = getPath(format, QSettings::UserScope);
-        if (!application.isEmpty())
-            confFiles[F_User | F_Application].reset(QConfFile::fromName(userPath + appFile, true));
-        confFiles[F_User | F_Organization].reset(QConfFile::fromName(userPath + orgFile, true));
-    }
-
-    const QString systemPath = getPath(format, QSettings::SystemScope);
-    if (!application.isEmpty())
-        confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false));
-    confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false));
-
-    for (i = 0; i < NumConfFiles; ++i) {
-        if (confFiles[i]) {
-            spec = i;
-            break;
-        }
-    }
-
-    initAccess();
-}
-
-QConfFileSettingsPrivate::QConfFileSettingsPrivate(const QString &fileName,
-                                                   QSettings::Format format)
-    : QSettingsPrivate(format),
-      nextPosition(0x40000000) // big positive number
-{
-    initFormat();
-
-    confFiles[0].reset(QConfFile::fromName(fileName, true));
-
-    initAccess();
-}
-
-QConfFileSettingsPrivate::~QConfFileSettingsPrivate()
-{
-    QMutexLocker locker(globalMutex());
-    ConfFileHash *usedHash = usedHashFunc();
-    ConfFileCache *unusedCache = unusedCacheFunc();
-
-    for (int i = 0; i < NumConfFiles; ++i) {
-        if (confFiles[i] && !confFiles[i]->ref.deref()) {
-            if (confFiles[i]->size == 0) {
-                delete confFiles[i].take();
-            } else {
-                if (usedHash)
-                    usedHash->remove(confFiles[i]->name);
-                if (unusedCache) {
-                    QT_TRY {
-                        // compute a better size?
-                        unusedCache->insert(confFiles[i]->name, confFiles[i].data(),
-                                        10 + (confFiles[i]->originalKeys.size() / 4));
-                        confFiles[i].take();
-                    } QT_CATCH(...) {
-                        // out of memory. Do not cache the file.
-                        delete confFiles[i].take();
-                    }
-                } else {
-                    // unusedCache is gone - delete the entry to prevent a memory leak
-                    delete confFiles[i].take();
-                }
-            }
-        }
-        // prevent the ScopedPointer to deref it again.
-        confFiles[i].take();
-    }
-}
-
-void QConfFileSettingsPrivate::remove(const QString &key)
-{
-    QConfFile *confFile = confFiles[spec].data();
-    if (!confFile)
-        return;
-
-    QSettingsKey theKey(key, caseSensitivity);
-    QSettingsKey prefix(key + QLatin1Char('/'), caseSensitivity);
-    QMutexLocker locker(&confFile->mutex);
-
-    ensureSectionParsed(confFile, theKey);
-    ensureSectionParsed(confFile, prefix);
-
-    ParsedSettingsMap::iterator i = confFile->addedKeys.lowerBound(prefix);
-    while (i != confFile->addedKeys.end() && i.key().startsWith(prefix))
-        i = confFile->addedKeys.erase(i);
-    confFile->addedKeys.remove(theKey);
-
-    ParsedSettingsMap::const_iterator j = const_cast<const ParsedSettingsMap *>(&confFile->originalKeys)->lowerBound(prefix);
-    while (j != confFile->originalKeys.constEnd() && j.key().startsWith(prefix)) {
-        confFile->removedKeys.insert(j.key(), QVariant());
-        ++j;
-    }
-    if (confFile->originalKeys.contains(theKey))
-        confFile->removedKeys.insert(theKey, QVariant());
-}
-
-void QConfFileSettingsPrivate::set(const QString &key, const QVariant &value)
-{
-    QConfFile *confFile = confFiles[spec].data();
-    if (!confFile)
-        return;
-
-    QSettingsKey theKey(key, caseSensitivity, nextPosition++);
-    QMutexLocker locker(&confFile->mutex);
-    confFile->removedKeys.remove(theKey);
-    confFile->addedKeys.insert(theKey, value);
-}
-
-bool QConfFileSettingsPrivate::get(const QString &key, QVariant *value) const
-{
-    QSettingsKey theKey(key, caseSensitivity);
-    ParsedSettingsMap::const_iterator j;
-    bool found = false;
-
-    for (int i = 0; i < NumConfFiles; ++i) {
-        if (QConfFile *confFile = confFiles[i].data()) {
-            QMutexLocker locker(&confFile->mutex);
-
-            if (!confFile->addedKeys.isEmpty()) {
-                j = confFile->addedKeys.constFind(theKey);
-                found = (j != confFile->addedKeys.constEnd());
-            }
-            if (!found) {
-                ensureSectionParsed(confFile, theKey);
-                j = confFile->originalKeys.constFind(theKey);
-                found = (j != confFile->originalKeys.constEnd()
-                         && !confFile->removedKeys.contains(theKey));
-            }
-
-            if (found && value)
-                *value = *j;
-
-            if (found)
-                return true;
-            if (!fallbacks)
-                break;
-        }
-    }
-    return false;
-}
-
-QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec spec) const
-{
-    QMap<QString, QString> result;
-    ParsedSettingsMap::const_iterator j;
-
-    QSettingsKey thePrefix(prefix, caseSensitivity);
-    int startPos = prefix.size();
-
-    for (int i = 0; i < NumConfFiles; ++i) {
-        if (QConfFile *confFile = confFiles[i].data()) {
-            QMutexLocker locker(&confFile->mutex);
-
-            if (thePrefix.isEmpty()) {
-                ensureAllSectionsParsed(confFile);
-            } else {
-                ensureSectionParsed(confFile, thePrefix);
-            }
-
-            j = const_cast<const ParsedSettingsMap *>(
-                    &confFile->originalKeys)->lowerBound( thePrefix);
-            while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) {
-                if (!confFile->removedKeys.contains(j.key()))
-                    processChild(j.key().originalCaseKey().mid(startPos), spec, result);
-                ++j;
-            }
-
-            j = const_cast<const ParsedSettingsMap *>(
-                    &confFile->addedKeys)->lowerBound(thePrefix);
-            while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) {
-                processChild(j.key().originalCaseKey().mid(startPos), spec, result);
-                ++j;
-            }
-
-            if (!fallbacks)
-                break;
-        }
-    }
-    return result.keys();
-}
-
-void QConfFileSettingsPrivate::clear()
-{
-    QConfFile *confFile = confFiles[spec].data();
-    if (!confFile)
-        return;
-
-    QMutexLocker locker(&confFile->mutex);
-    ensureAllSectionsParsed(confFile);
-    confFile->addedKeys.clear();
-    confFile->removedKeys = confFile->originalKeys;
-}
-
-void QConfFileSettingsPrivate::sync()
-{
-    // people probably won't be checking the status a whole lot, so in case of
-    // error we just try to go on and make the best of it
-
-    for (int i = 0; i < NumConfFiles; ++i) {
-        QConfFile *confFile = confFiles[i].data();
-        if (confFile) {
-            QMutexLocker locker(&confFile->mutex);
-            syncConfFile(i);
-        }
-    }
-}
-
-QString QConfFileSettingsPrivate::fileName() const
-{
-    QConfFile *confFile = confFiles[spec].data();
-    if (!confFile)
-        return QString();
-    return confFile->name;
-}
-
-bool QConfFileSettingsPrivate::isWritable() const
-{
-    if (format > QSettings::IniFormat && !writeFunc)
-        return false;
-
-    QConfFile *confFile = confFiles[spec].data();
-    if (!confFile)
-        return false;
-
-    return confFile->isWritable();
-}
-
-void QConfFileSettingsPrivate::syncConfFile(int confFileNo)
-{
-    QConfFile *confFile = confFiles[confFileNo].data();
-    bool readOnly = confFile->addedKeys.isEmpty() && confFile->removedKeys.isEmpty();
-    bool ok;
-
-    /*
-        We can often optimize the read-only case, if the file on disk
-        hasn't changed.
-    */
-    if (readOnly && confFile->size > 0) {
-        QFileInfo fileInfo(confFile->name);
-        if (confFile->size == fileInfo.size() && confFile->timeStamp == fileInfo.lastModified())
-            return;
-    }
-
-    /*
-        Open the configuration file and try to use it using a named
-        semaphore on Windows and an advisory lock on Unix-based
-        systems. This protect us against other QSettings instances
-        trying to access the same file from other threads or
-        processes.
-
-        As it stands now, the locking mechanism doesn't work for
-        .plist files.
-    */
-    QFile file(confFile->name);
-    bool createFile = !file.exists();
-    if (!readOnly && confFile->isWritable())
-        file.open(QFile::ReadWrite);
-    if (!file.isOpen())
-        file.open(QFile::ReadOnly);
-
-    if (!createFile && !file.isOpen())
-        setStatus(QSettings::AccessError);
-
-    // If we have created the file, apply the file perms
-    if (file.isOpen()) {
-        unixLock(file.handle(), readOnly ? F_RDLCK : F_WRLCK);
-
-        if (createFile) {
-            QFile::Permissions perms = file.permissions() | QFile::ReadOwner | QFile::WriteOwner;
-            if (!confFile->userPerms)
-                perms |= QFile::ReadGroup | QFile::ReadOther;
-            file.setPermissions(perms);
-        }
-    }
-
-    /*
-        We hold the lock. Let's reread the file if it has changed
-        since last time we read it.
-    */
-    QFileInfo fileInfo(confFile->name);
-    bool mustReadFile = true;
-
-    if (!readOnly)
-        mustReadFile = (confFile->size != fileInfo.size()
-                        || (confFile->size != 0 && confFile->timeStamp != fileInfo.lastModified()));
-
-    if (mustReadFile) {
-        confFile->unparsedIniSections.clear();
-        confFile->originalKeys.clear();
-
-        /*
-            Files that we can't read (because of permissions or
-            because they don't exist) are treated as empty files.
-        */
-        if (file.isReadable() && fileInfo.size() != 0) {
-            if (format <= QSettings::IniFormat) {
-                QByteArray data = file.readAll();
-                ok = readIniFile(data, &confFile->unparsedIniSections);
-            } else {
-                if (readFunc) {
-                    QSettings::SettingsMap tempNewKeys;
-                    ok = readFunc(file, tempNewKeys);
-
-                    if (ok) {
-                        QSettings::SettingsMap::const_iterator i = tempNewKeys.constBegin();
-                        while (i != tempNewKeys.constEnd()) {
-                            confFile->originalKeys.insert(QSettingsKey(i.key(),
-                                                                        caseSensitivity),
-                                                            i.value());
-                            ++i;
-                        }
-                    }
-                } else {
-                    ok = false;
-                }
-            }
-
-            if (!ok)
-                setStatus(QSettings::FormatError);
-        }
-
-        confFile->size = fileInfo.size();
-        confFile->timeStamp = fileInfo.lastModified();
-    }
-
-    /*
-        We also need to save the file. We still hold the file lock,
-        so everything is under control.
-    */
-    if (!readOnly) {
-        ensureAllSectionsParsed(confFile);
-        ParsedSettingsMap mergedKeys = confFile->mergedKeyMap();
-
-        if (file.isWritable()) {
-            file.seek(0);
-            file.resize(0);
-
-            if (format <= QSettings::IniFormat) {
-                ok = writeIniFile(file, mergedKeys);
-                if (!ok) {
-                    // try to restore old data; might work if the disk was full and the new data
-                    // was larger than the old data
-                    file.seek(0);
-                    file.resize(0);
-                    writeIniFile(file, confFile->originalKeys);
-                }
-            } else {
-                if (writeFunc) {
-                    QSettings::SettingsMap tempOriginalKeys;
-
-                    ParsedSettingsMap::const_iterator i = mergedKeys.constBegin();
-                    while (i != mergedKeys.constEnd()) {
-                        tempOriginalKeys.insert(i.key(), i.value());
-                        ++i;
-                    }
-                    ok = writeFunc(file, tempOriginalKeys);
-                } else {
-                    ok = false;
-                }
-            }
-        } else {
-            ok = false;
-        }
-
-        if (ok) {
-            confFile->unparsedIniSections.clear();
-            confFile->originalKeys = mergedKeys;
-            confFile->addedKeys.clear();
-            confFile->removedKeys.clear();
-
-            QFileInfo fileInfo(confFile->name);
-            confFile->size = fileInfo.size();
-            confFile->timeStamp = fileInfo.lastModified();
-        } else {
-            setStatus(QSettings::AccessError);
-        }
-    }
-}
-
-enum { Space = 0x1, Special = 0x2 };
-
-static const char charTraits[256] =
-{
-    // Space: '\t', '\n', '\r', ' '
-    // Special: '\n', '\r', '"', ';', '=', '\\'
-
-    0, 0, 0, 0, 0, 0, 0, 0, 0, Space, Space | Special, 0, 0, Space | Special, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    Space, 0, Special, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Special, 0, Special, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Special, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-bool QConfFileSettingsPrivate::readIniLine(const QByteArray &data, int &dataPos,
-                                           int &lineStart, int &lineLen, int &equalsPos)
-{
-    int dataLen = data.length();
-    bool inQuotes = false;
-
-    equalsPos = -1;
-
-    lineStart = dataPos;
-    while (lineStart < dataLen && (charTraits[uint(uchar(data.at(lineStart)))] & Space))
-        ++lineStart;
-
-    int i = lineStart;
-    while (i < dataLen) {
-        while (!(charTraits[uint(uchar(data.at(i)))] & Special)) {
-            if (++i == dataLen)
-                goto break_out_of_outer_loop;
-        }
-
-        char ch = data.at(i++);
-        if (ch == '=') {
-            if (!inQuotes && equalsPos == -1)
-                equalsPos = i - 1;
-        } else if (ch == '\n' || ch == '\r') {
-            if (i == lineStart + 1) {
-                ++lineStart;
-            } else if (!inQuotes) {
-                --i;
-                goto break_out_of_outer_loop;
-            }
-        } else if (ch == '\\') {
-            if (i < dataLen) {
-                char ch = data.at(i++);
-                if (i < dataLen) {
-                    char ch2 = data.at(i);
-                    // \n, \r, \r\n, and \n\r are legitimate line terminators in INI files
-                    if ((ch == '\n' && ch2 == '\r') || (ch == '\r' && ch2 == '\n'))
-                        ++i;
-                }
-            }
-        } else if (ch == '"') {
-            inQuotes = !inQuotes;
-        } else {
-            Q_ASSERT(ch == ';');
-
-            if (i == lineStart + 1) {
-                char ch;
-                while (i < dataLen && ((ch = data.at(i) != '\n') && ch != '\r'))
-                    ++i;
-                lineStart = i;
-            } else if (!inQuotes) {
-                --i;
-                goto break_out_of_outer_loop;
-            }
-        }
-    }
-
-break_out_of_outer_loop:
-    dataPos = i;
-    lineLen = i - lineStart;
-    return lineLen > 0;
-}
-
-/*
-    Returns false on parse error. However, as many keys are read as
-    possible, so if the user doesn't check the status he will get the
-    most out of the file anyway.
-*/
-bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data,
-                                           UnparsedSettingsMap *unparsedIniSections)
-{
-#define FLUSH_CURRENT_SECTION() \
-    { \
-        QByteArray &sectionData = (*unparsedIniSections)[QSettingsKey(currentSection, \
-                                                                      IniCaseSensitivity, \
-                                                                      sectionPosition)]; \
-        if (!sectionData.isEmpty()) \
-            sectionData.append('\n'); \
-        sectionData += data.mid(currentSectionStart, lineStart - currentSectionStart); \
-        sectionPosition = ++position; \
-    }
-
-    QString currentSection;
-    int currentSectionStart = 0;
-    int dataPos = 0;
-    int lineStart;
-    int lineLen;
-    int equalsPos;
-    int position = 0;
-    int sectionPosition = 0;
-    bool ok = true;
-
-    while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
-        char ch = data.at(lineStart);
-        if (ch == '[') {
-            FLUSH_CURRENT_SECTION();
-
-            // this is a section
-            QByteArray iniSection;
-            int idx = data.indexOf(']', lineStart);
-            if (idx == -1 || idx >= lineStart + lineLen) {
-                ok = false;
-                iniSection = data.mid(lineStart + 1, lineLen - 1);
-            } else {
-                iniSection = data.mid(lineStart + 1, idx - lineStart - 1);
-            }
-
-            iniSection = iniSection.trimmed();
-
-            if (qstricmp(iniSection.constData(), "general") == 0) {
-                currentSection.clear();
-            } else {
-                if (qstricmp(iniSection.constData(), "%general") == 0) {
-                    currentSection = QLatin1String(iniSection.constData() + 1);
-                } else {
-                    currentSection.clear();
-                    iniUnescapedKey(iniSection, 0, iniSection.size(), currentSection);
-                }
-                currentSection += QLatin1Char('/');
-            }
-            currentSectionStart = dataPos;
-        }
-        ++position;
-    }
-
-    Q_ASSERT(lineStart == data.length());
-    FLUSH_CURRENT_SECTION();
-
-    return ok;
-
-#undef FLUSH_CURRENT_SECTION
-}
-
-bool QConfFileSettingsPrivate::readIniSection(const QSettingsKey &section, const QByteArray &data,
-                                              ParsedSettingsMap *settingsMap, QTextCodec *codec)
-{
-    QStringList strListValue;
-    bool sectionIsLowercase = (section == section.originalCaseKey());
-    int equalsPos;
-
-    bool ok = true;
-    int dataPos = 0;
-    int lineStart;
-    int lineLen;
-    int position = section.originalKeyPosition();
-
-    while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
-        char ch = data.at(lineStart);
-        Q_ASSERT(ch != '[');
-
-        if (equalsPos == -1) {
-            if (ch != ';')
-                ok = false;
-            continue;
-        }
-
-        int keyEnd = equalsPos;
-        while (keyEnd > lineStart && ((ch = data.at(keyEnd - 1)) == ' ' || ch == '\t'))
-            --keyEnd;
-        int valueStart = equalsPos + 1;
-
-        QString key = section.originalCaseKey();
-        bool keyIsLowercase = (iniUnescapedKey(data, lineStart, keyEnd, key) && sectionIsLowercase);
-
-        QString strValue;
-        strValue.reserve(lineLen - (valueStart - lineStart));
-        bool isStringList = iniUnescapedStringList(data, valueStart, lineStart + lineLen,
-                                                   strValue, strListValue, codec);
-        QVariant variant;
-        if (isStringList) {
-            variant = stringListToVariantList(strListValue);
-        } else {
-            variant = stringToVariant(strValue);
-        }
-
-        /*
-            We try to avoid the expensive toLower() call in
-            QSettingsKey by passing Qt::CaseSensitive when the
-            key is already in lowercase.
-        */
-        settingsMap->insert(QSettingsKey(key, keyIsLowercase ? Qt::CaseSensitive
-                                                             : IniCaseSensitivity,
-                                         position),
-                            variant);
-        ++position;
-    }
-
-    return ok;
-}
-
-class QSettingsIniKey : public QString
-{
-public:
-    inline QSettingsIniKey() : position(-1) {}
-    inline QSettingsIniKey(const QString &str, int pos = -1) : QString(str), position(pos) {}
-
-    int position;
-};
-
-static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
-{
-    if (k1.position != k2.position)
-        return k1.position < k2.position;
-    return static_cast<const QString &>(k1) < static_cast<const QString &>(k2);
-}
-
-typedef QMap<QSettingsIniKey, QVariant> IniKeyMap;
-
-struct QSettingsIniSection
-{
-    int position;
-    IniKeyMap keyMap;
-
-    inline QSettingsIniSection() : position(-1) {}
-};
-
-typedef QMap<QString, QSettingsIniSection> IniMap;
-
-/*
-    This would be more straightforward if we didn't try to remember the original
-    key order in the .ini file, but we do.
-*/
-bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSettingsMap &map)
-{
-    IniMap iniMap;
-    IniMap::const_iterator i;
-
-    const char eol = '\n';
-
-    for (ParsedSettingsMap::const_iterator j = map.constBegin(); j != map.constEnd(); ++j) {
-        QString section;
-        QSettingsIniKey key(j.key().originalCaseKey(), j.key().originalKeyPosition());
-        int slashPos;
-
-        if ((slashPos = key.indexOf(QLatin1Char('/'))) != -1) {
-            section = key.left(slashPos);
-            key.remove(0, slashPos + 1);
-        }
-
-        QSettingsIniSection &iniSection = iniMap[section];
-
-        // -1 means infinity
-        if (uint(key.position) < uint(iniSection.position))
-            iniSection.position = key.position;
-        iniSection.keyMap[key] = j.value();
-    }
-
-    const int sectionCount = iniMap.size();
-    QVector<QSettingsIniKey> sections;
-    sections.reserve(sectionCount);
-    for (i = iniMap.constBegin(); i != iniMap.constEnd(); ++i)
-        sections.append(QSettingsIniKey(i.key(), i.value().position));
-    qSort(sections);
-
-    bool writeError = false;
-    for (int j = 0; !writeError && j < sectionCount; ++j) {
-        i = iniMap.constFind(sections.at(j));
-        Q_ASSERT(i != iniMap.constEnd());
-
-        QByteArray realSection;
-
-        iniEscapedKey(i.key(), realSection);
-
-        if (realSection.isEmpty()) {
-            realSection = "[General]";
-        } else if (qstricmp(realSection.constData(), "general") == 0) {
-            realSection = "[%General]";
-        } else {
-            realSection.prepend('[');
-            realSection.append(']');
-        }
-
-        if (j != 0)
-            realSection.prepend(eol);
-        realSection += eol;
-
-        device.write(realSection);
-
-        const IniKeyMap &ents = i.value().keyMap;
-        for (IniKeyMap::const_iterator j = ents.constBegin(); j != ents.constEnd(); ++j) {
-            QByteArray block;
-            iniEscapedKey(j.key(), block);
-            block += '=';
-
-            const QVariant &value = j.value();
-
-            /*
-                The size() != 1 trick is necessary because
-                QVariant(QString("foo")).toList() returns an empty
-                list, not a list containing "foo".
-            */
-            if (value.type() == QVariant::StringList
-                    || (value.type() == QVariant::List && value.toList().size() != 1)) {
-                iniEscapedStringList(variantListToStringList(value.toList()), block, iniCodec);
-            } else {
-                iniEscapedString(variantToString(value), block, iniCodec);
-            }
-            block += eol;
-            if (device.write(block) == -1) {
-                writeError = true;
-                break;
-            }
-        }
-    }
-    return !writeError;
-}
-
-void QConfFileSettingsPrivate::ensureAllSectionsParsed(QConfFile *confFile) const
-{
-    UnparsedSettingsMap::const_iterator i = confFile->unparsedIniSections.constBegin();
-    const UnparsedSettingsMap::const_iterator end = confFile->unparsedIniSections.constEnd();
-
-    for (; i != end; ++i) {
-        if (!QConfFileSettingsPrivate::readIniSection(i.key(), i.value(), &confFile->originalKeys, iniCodec))
-            setStatus(QSettings::FormatError);
-    }
-    confFile->unparsedIniSections.clear();
-}
-
-void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
-                                                   const QSettingsKey &key) const
-{
-    if (confFile->unparsedIniSections.isEmpty())
-        return;
-
-    UnparsedSettingsMap::iterator i;
-
-    int indexOfSlash = key.indexOf(QLatin1Char('/'));
-    if (indexOfSlash != -1) {
-        i = confFile->unparsedIniSections.upperBound(key);
-        if (i == confFile->unparsedIniSections.begin())
-            return;
-        --i;
-        if (i.key().isEmpty() || !key.startsWith(i.key()))
-            return;
-    } else {
-        i = confFile->unparsedIniSections.begin();
-        if (i == confFile->unparsedIniSections.end() || !i.key().isEmpty())
-            return;
-    }
-
-    if (!QConfFileSettingsPrivate::readIniSection(i.key(), i.value(), &confFile->originalKeys, iniCodec))
-        setStatus(QSettings::FormatError);
-    confFile->unparsedIniSections.erase(i);
-}
-
-/*!
-    \class QSettings
-    \brief The QSettings class provides persistent platform-independent application settings.
-
-    \ingroup io
-
-    \reentrant
-
-    Users normally expect an application to remember its settings
-    (window sizes and positions, options, etc.) across sessions. This
-    information is often stored in the system registry on Windows,
-    and in XML preferences files on Mac OS X. On Unix systems, in the
-    absence of a standard, many applications (including the KDE
-    applications) use INI text files.
-
-    QSettings is an abstraction around these technologies, enabling
-    you to save and restore application settings in a portable
-    manner. It also supports \l{registerFormat()}{custom storage
-    formats}.
-
-    QSettings's API is based on QVariant, allowing you to save
-    most value-based types, such as QString, QRect, and QImage,
-    with the minimum of effort.
-
-    If all you need is a non-persistent memory-based structure,
-    consider using QMap<QString, QVariant> instead.
-
-    \tableofcontents section1
-
-    \section1 Basic Usage
-
-    When creating a QSettings object, you must pass the name of your
-    company or organization as well as the name of your application.
-    For example, if your product is called Star Runner and your
-    company is called MySoft, you would construct the QSettings
-    object as follows:
-
-    \snippet doc/src/snippets/settings/settings.cpp 0
-
-    QSettings objects can be created either on the stack or on
-    the heap (i.e. using \c new). Constructing and destroying a
-    QSettings object is very fast.
-
-    If you use QSettings from many places in your application, you
-    might want to specify the organization name and the application
-    name using QCoreApplication::setOrganizationName() and
-    QCoreApplication::setApplicationName(), and then use the default
-    QSettings constructor:
-
-    \snippet doc/src/snippets/settings/settings.cpp 1
-    \snippet doc/src/snippets/settings/settings.cpp 2
-    \snippet doc/src/snippets/settings/settings.cpp 3
-    \dots
-    \snippet doc/src/snippets/settings/settings.cpp 4
-
-    (Here, we also specify the organization's Internet domain. When
-    the Internet domain is set, it is used on Mac OS X instead of the
-    organization name, since Mac OS X applications conventionally use
-    Internet domains to identify themselves. If no domain is set, a
-    fake domain is derived from the organization name. See the
-    \l{Platform-Specific Notes} below for details.)
-
-    QSettings stores settings. Each setting consists of a QString
-    that specifies the setting's name (the \e key) and a QVariant
-    that stores the data associated with the key. To write a setting,
-    use setValue(). For example:
-
-    \snippet doc/src/snippets/settings/settings.cpp 5
-
-    If there already exists a setting with the same key, the existing
-    value is overwritten by the new value. For efficiency, the
-    changes may not be saved to permanent storage immediately. (You
-    can always call sync() to commit your changes.)
-
-    You can get a setting's value back using value():
-
-    \snippet doc/src/snippets/settings/settings.cpp 6
-
-    If there is no setting with the specified name, QSettings
-    returns a null QVariant (which can be converted to the integer 0).
-    You can specify another default value by passing a second
-    argument to value():
-
-    \snippet doc/src/snippets/settings/settings.cpp 7
-
-    To test whether a given key exists, call contains(). To remove
-    the setting associated with a key, call remove(). To obtain the
-    list of all keys, call allKeys(). To remove all keys, call
-    clear().
+    To test whether a given key exists, call contains(). To remove
+    the setting associated with a key, call remove(). To obtain the
+    list of all keys, call keys(). To get a map of all settings, call
+    map(). To remove all keys, call clear().
 
     \section1 QVariant and GUI Types
 
@@ -1908,27 +667,20 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     conversion functions to data types such as QColor, QImage, and
     QPixmap, which are part of \l QtGui. In other words, there is no
     \c toColor(), \c toImage(), or \c toPixmap() functions in QVariant.
-
     Instead, you can use the QVariant::value() or the qVariantValue()
-    template function. For example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 0
+    template function.
 
     The inverse conversion (e.g., from QColor to QVariant) is
     automatic for all data types supported by QVariant, including
-    GUI-related types:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 1
+    GUI-related types.
 
     Custom types registered using qRegisterMetaType() and
     qRegisterMetaTypeStreamOperators() can be stored using QSettings.
 
     \section1 Section and Key Syntax
 
-    Setting keys can contain any Unicode characters. The Windows
-    registry and INI files use case-insensitive keys, whereas the
-    Carbon Preferences API on Mac OS X uses case-sensitive keys. To
-    avoid portability problems, follow these simple rules:
+    Setting keys can contain any Unicode characters. To avoid portability
+    problems, follow these simple rules:
 
     \list 1
     \o Always refer to the same key using the same case. For example,
@@ -1939,134 +691,35 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
        example, if you have a key called "MainWindow", don't try to
        save another key as "mainwindow".
 
-    \o Do not use slashes ('/' and '\\') in section or key names; the
-       backslash character is used to separate sub keys (see below). On
+    \o Do not use slashes ('/' and '\\') in key names. The backslash
+       character is used to separate sub keys (see below). On
        windows '\\' are converted by QSettings to '/', which makes
        them identical.
     \endlist
 
     You can form hierarchical keys using the '/' character as a
-    separator, similar to Unix file paths. For example:
-
-    \snippet doc/src/snippets/settings/settings.cpp 8
-    \snippet doc/src/snippets/settings/settings.cpp 9
-    \snippet doc/src/snippets/settings/settings.cpp 10
-
-    If you want to save or restore many settings with the same
-    prefix, you can specify the prefix using beginGroup() and call
-    endGroup() at the end. Here's the same example again, but this
-    time using the group mechanism:
-
-    \snippet doc/src/snippets/settings/settings.cpp 11
-    \codeline
-    \snippet doc/src/snippets/settings/settings.cpp 12
+    separator, similar to Unix file paths.
 
-    If a group is set using beginGroup(), the behavior of most
-    functions changes consequently. Groups can be set recursively.
-
-    In addition to groups, QSettings also supports an "array"
-    concept. See beginReadArray() and beginWriteArray() for details.
-
-    \section1 Fallback Mechanism
-
-    Let's assume that you have created a QSettings object with the
-    organization name MySoft and the application name Star Runner.
-    When you look up a value, up to four locations are searched in
-    that order:
-
-    \list 1
-    \o a user-specific location for the Star Runner application
-    \o a user-specific location for all applications by MySoft
-    \o a system-wide location for the Star Runner application
-    \o a system-wide location for all applications by MySoft
-    \endlist
-
-    (See \l{Platform-Specific Notes} below for information on what
-    these locations are on the different platforms supported by Qt.)
-
-    If a key cannot be found in the first location, the search goes
-    on in the second location, and so on. This enables you to store
-    system-wide or organization-wide settings and to override them on
-    a per-user or per-application basis. To turn off this mechanism,
-    call setFallbacksEnabled(false).
-
-    Although keys from all four locations are available for reading,
-    only the first file (the user-specific location for the
-    application at hand) is accessible for writing. To write to any
-    of the other files, omit the application name and/or specify
-    QSettings::SystemScope (as opposed to QSettings::UserScope, the
-    default).
-
-    Let's see with an example:
-
-    \snippet doc/src/snippets/settings/settings.cpp 13
-    \snippet doc/src/snippets/settings/settings.cpp 14
-
-    The table below summarizes which QSettings objects access
-    which location. "\bold{X}" means that the location is the main
-    location associated to the QSettings object and is used both
-    for reading and for writing; "o" means that the location is used
-    as a fallback when reading.
-
-    \table
-    \header \o Locations               \o \c{obj1} \o \c{obj2} \o \c{obj3} \o \c{obj4}
-    \row    \o 1. User, Application    \o \bold{X} \o          \o          \o
-    \row    \o 2. User, Organization   \o o        \o \bold{X} \o          \o
-    \row    \o 3. System, Application  \o o        \o          \o \bold{X} \o
-    \row    \o 4. System, Organization \o o        \o o        \o o        \o \bold{X}
-    \endtable
-
-    The beauty of this mechanism is that it works on all platforms
-    supported by Qt and that it still gives you a lot of flexibility,
-    without requiring you to specify any file names or registry
-    paths.
-
-    If you want to use INI files on all platforms instead of the
-    native API, you can pass QSettings::IniFormat as the first
-    argument to the QSettings constructor, followed by the scope, the
-    organization name, and the application name:
-
-    \snippet doc/src/snippets/settings/settings.cpp 15
-
-    The \l{tools/settingseditor}{Settings Editor} example lets you
-    experiment with different settings location and with fallbacks
-    turned on or off.
+    If you want to use specific format instead of the native, you
+    can pass QSettings::IniFormat as the first argument to the
+    QSettings constructor, followed by the scope.
 
     \section1 Restoring the State of a GUI Application
 
-    QSettings is often used to store the state of a GUI
-    application. The following example illustrates how to use QSettings
-    to save and restore the geometry of an application's main window.
-
-    \snippet doc/src/snippets/settings/settings.cpp 16
-    \codeline
-    \snippet doc/src/snippets/settings/settings.cpp 17
-
+    QSettings is often used to store the state of a GUI application.
     See \l{Window Geometry} for a discussion on why it is better to
-    call QWidget::resize() and QWidget::move() rather than QWidget::setGeometry()
-    to restore a window's geometry.
+    call QWidget::resize() and QWidget::move() rather than
+    QWidget::setGeometry() to restore a window's geometry.
 
     The \c readSettings() and \c writeSettings() functions must be
-    called from the main window's constructor and close event handler
-    as follows:
-
-    \snippet doc/src/snippets/settings/settings.cpp 18
-    \dots
-    \snippet doc/src/snippets/settings/settings.cpp 19
-    \snippet doc/src/snippets/settings/settings.cpp 20
-    \codeline
-    \snippet doc/src/snippets/settings/settings.cpp 21
-
-    See the \l{mainwindows/application}{Application} example for a
-    self-contained example that uses QSettings.
+    called from the main window's constructor and close event handler.
 
     \section1 Accessing Settings from Multiple Threads or Processes Simultaneously
 
-    QSettings is \l{reentrant}. This means that you can use
-    distinct QSettings object in different threads
-    simultaneously. This guarantee stands even when the QSettings
-    objects refer to the same files on disk (or to the same entries
-    in the system registry). If a setting is modified through one
+    QSettings is \l{reentrant}. This means that you can use distinct
+    QSettings object in different threads simultaneously. This
+    guarantee stands even when the QSettings objects refer to the
+    same files on disk. If a setting is modified through one
     QSettings object, the change will immediately be visible in
     any other QSettings objects that operate on the same location
     and that live in the same process.
@@ -2083,54 +736,37 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
 
     \section2 Locations Where Application Settings Are Stored
 
-    As mentioned in the \l{Fallback Mechanism} section, QSettings
-    stores settings for an application in up to four locations,
+    QSettings stores settings for an application in two locations,
     depending on whether the settings are user-specific or
-    system-wide and whether the settings are application-specific
-    or organization-wide. For simplicity, we're assuming the
-    organization is called MySoft and the application is called Star
-    Runner.
+    system-wide. For simplicity, we're assuming the application is
+    called MySoft.
 
     On Unix systems, if the file format is NativeFormat, the
     following files are used by default:
 
     \list 1
-    \o \c{$HOME/.config/MySoft/Star Runner.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.conf})
-    \o \c{$HOME/.config/MySoft.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.conf})
-    \o \c{/etc/xdg/MySoft/Star Runner.conf}
-    \o \c{/etc/xdg/MySoft.conf}
+    \o \c{$HOME/.config/MySoft.json}
+    \o \c{/etc/xdg/MySoft.json}
     \endlist
 
     If the file format is IniFormat, the following files are
     used on Unix:
 
     \list 1
-    \o \c{$HOME/.config/MySoft/Star Runner.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.ini})
-    \o \c{$HOME/.config/MySoft.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.ini})
-    \o \c{/etc/xdg/MySoft/Star Runner.ini}
+    \o \c{$HOME/.config/MySoft.ini}
     \o \c{/etc/xdg/MySoft.ini}
     \endlist
 
-    The SystemScope settings location is determined from the installation
-    drive and Secure ID (UID3) of the application. If the application is
-    built-in on the ROM, the drive used for SystemScope is \c c:.
-
-    The paths for the \c .ini and \c .conf files can be changed using
-    setPath(). On Unix, the user can override them by setting the
-    \c XDG_CONFIG_HOME environment variable; see setPath() for details.
-
-    \section2 Accessing INI and .plist Files Directly
-
-    Sometimes you do want to access settings stored in a specific
-    file or registry path. On all platforms, if you want to read an
-    INI file directly, you can use the QSettings constructor that
-    takes a file name as first argument and pass QSettings::IniFormat
-    as second argument. For example:
+    The paths for the \c .ini and \c .json files can be changed by the
+    user by setting the \c XDG_CONFIG_HOME environment variable.
 
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 2
+    \section2 Accessing Files Directly
 
-    You can then use the QSettings object to read and write settings
-    in the file.
+    Sometimes you do want to access settings stored in a specific file.
+    If you want to read an INI file directly, you can use the QSettings
+    constructor that takes a file name as first argument and pass
+    QSettings::IniFormat as second argument. You can then use the
+    QSettings object to read and write settingsin the file.
 
     \section2 Platform Limitations
 
@@ -2146,7 +782,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
 
     \endlist
 
-    \sa QVariant, QSessionManager, {Settings Editor Example}, {Application Example}
+    \sa QVariant, QSessionManager
 */
 
 /*! \enum QSettings::SettingsStatus
@@ -2164,12 +800,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
 
     This enum type specifies the storage format used by QSettings.
 
-    \value NativeFormat  Store the settings using the most
-                         appropriate storage format for the platform.
-                         On Windows, this means the system registry;
-                         on Mac OS X, this means the CFPreferences
-                         API; on Unix, this means textual
-                         configuration files in INI format.
+    \value NativeFormat  Store the settings in JSON files.
     \value IniFormat  Store the settings in INI files.
     \value InvalidFormat Special value returned by registerFormat().
     \omitvalue CustomFormat1
@@ -2189,10 +820,6 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     \omitvalue CustomFormat15
     \omitvalue CustomFormat16
 
-    On Unix, NativeFormat and IniFormat mean the same thing, except
-    that the file extension is different (\c .conf for NativeFormat,
-    \c .ini for IniFormat).
-
     The INI file format is a Windows file format that Qt supports on
     all platforms. In the absence of an INI standard, we try to
     follow what Microsoft does, with the following exceptions:
@@ -2231,11 +858,10 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
         we accept and conservative in what we generate, QSettings
         will accept Latin-1 encoded INI files, but generate pure
         ASCII files, where non-ASCII values are encoded using standard
-        INI escape sequences. To make the INI files more readable (but
-        potentially less compatible), call setIniCodec().
+        INI escape sequences.
     \endlist
 
-    \sa registerFormat(), setPath()
+    \sa registerFormat()
 */
 
 /*! \enum QSettings::Scope
@@ -2249,10 +875,6 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     \value SystemScope  Store settings in a global location, so that
                         all users on the same machine access the same
                         set of settings.
-    \omitvalue User
-    \omitvalue Global
-
-    \sa setPath()
 */
 
 /*!
@@ -2260,44 +882,20 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
     application called \a application from the organization called \a
     organization, and with parent \a parent.
 
-    Example:
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 10
-
-    The scope is set to QSettings::UserScope, and the format is
-    set to QSettings::NativeFormat (i.e. calling setDefaultFormat()
-    before calling this constructor has no effect).
-
-    \sa setDefaultFormat(), {Fallback Mechanism}
-*/
-QSettings::QSettings(const QString &organization, const QString &application, QObject *parent)
-    : QObject(*QSettingsPrivate::create(NativeFormat, UserScope, organization, application),
-              parent)
-{
-}
-
-/*!
-    Constructs a QSettings object for accessing settings of the
-    application called \a application from the organization called \a
-    organization, and with parent \a parent.
-
     If \a scope is QSettings::UserScope, the QSettings object searches
-    user-specific settings first, before it searches system-wide
-    settings as a fallback. If \a scope is QSettings::SystemScope, the
-    QSettings object ignores user-specific settings and provides
+    user-specific settings only. If \a scope is QSettings::SystemScope,
+    the QSettings object ignores user-specific settings and provides
     access to system-wide settings.
 
-    The storage format is set to QSettings::NativeFormat (i.e. calling
-    setDefaultFormat() before calling this constructor has no effect).
-
-    If no application name is given, the QSettings object will
-    only access the organization-wide \l{Fallback Mechanism}{locations}.
-
-    \sa setDefaultFormat()
+    The storage format is set to QSettings::NativeFormat.
 */
-QSettings::QSettings(Scope scope, const QString &organization, const QString &application,
-                     QObject *parent)
-    : QObject(*QSettingsPrivate::create(NativeFormat, scope, organization, application), parent)
+QSettings::QSettings(Scope scope, QObject *parent)
+    : QObject(*new QSettingsPrivate(NativeFormat, scope), parent)
 {
+    QMutexLocker locker(qSettingsMutex());
+    qGlobalSettings()->append(this);
+    Q_D(QSettings);
+    d->read();
 }
 
 /*!
@@ -2306,22 +904,21 @@ QSettings::QSettings(Scope scope, const QString &organization, const QString &ap
     \a organization, and with parent \a parent.
 
     If \a scope is QSettings::UserScope, the QSettings object searches
-    user-specific settings first, before it searches system-wide
-    settings as a fallback. If \a scope is
-    QSettings::SystemScope, the QSettings object ignores user-specific
-    settings and provides access to system-wide settings.
-
-    If \a format is QSettings::NativeFormat, the native API is used for
-    storing settings. If \a format is QSettings::IniFormat, the INI format
-    is used.
+    user-specific settings only. If \a scope is QSettings::SystemScope,
+    the QSettings object ignores user-specific settings and provides
+    access to system-wide settings.
 
-    If no application name is given, the QSettings object will
-    only access the organization-wide \l{Fallback Mechanism}{locations}.
+    If \a format is QSettings::NativeFormat, the native JSON API is used
+    for storing settings. If \a format is QSettings::IniFormat, the INI
+    format is used.
 */
-QSettings::QSettings(Format format, Scope scope, const QString &organization,
-                     const QString &application, QObject *parent)
-    : QObject(*QSettingsPrivate::create(format, scope, organization, application), parent)
+QSettings::QSettings(Format format, Scope scope, QObject *parent)
+    : QObject(*new QSettingsPrivate(format, scope), parent)
 {
+    QMutexLocker locker(qSettingsMutex());
+    qGlobalSettings()->append(this);
+    Q_D(QSettings);
+    d->read();
 }
 
 /*!
@@ -2329,20 +926,13 @@ QSettings::QSettings(Format format, Scope scope, const QString &organization,
     stored in the file called \a fileName, with parent \a parent. If
     the file doesn't already exist, it is created.
 
-    If \a format is QSettings::NativeFormat, the meaning of \a
-    fileName depends on the platform. On Unix, \a fileName is the
-    name of an INI file. On Mac OS X, \a fileName is the name of a
-    \c .plist file. On Windows, \a fileName is a path in the system
-    registry.
+    The meaning of \a fileName depends on the format. If \a format is
+    QSettings::NativeFormat, the filename will end with end with .json
+    suffix, if it is QSettings::IniFormat it will be suffixed with .ini.
 
     If \a format is QSettings::IniFormat, \a fileName is the name of an INI
     file.
 
-    \warning This function is provided for convenience. It works well for
-    accessing INI or \c .plist files generated by Qt, but might fail on some
-    syntaxes found in such files originated by other programs. In particular,
-    be aware of the following limitations:
-
     \list
     \o QSettings provides no way of reading INI "path" entries, i.e., entries
        with unescaped slash characters. (This is because these entries are
@@ -2355,48 +945,31 @@ QSettings::QSettings(Format format, Scope scope, const QString &organization,
     \sa fileName()
 */
 QSettings::QSettings(const QString &fileName, Format format, QObject *parent)
-    : QObject(*QSettingsPrivate::create(fileName, format), parent)
+    : QObject(*new QSettingsPrivate(fileName, format), parent)
 {
+    QMutexLocker locker(qSettingsMutex());
+    qGlobalSettings()->append(this);
+    Q_D(QSettings);
+    d->read();
 }
 
 /*!
     Constructs a QSettings object for accessing settings of the
-    application and organization set previously with a call to
-    QCoreApplication::setOrganizationName(),
-    QCoreApplication::setOrganizationDomain(), and
+    application set previously with a call to
     QCoreApplication::setApplicationName().
 
     The scope is QSettings::UserScope and the format is
-    defaultFormat() (QSettings::NativeFormat by default).
-    Use setDefaultFormat() before calling this constructor
-    to change the default format used by this constructor.
-
-    The code
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 11
-
-    is equivalent to
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 12
-
-    If QCoreApplication::setOrganizationName() and
-    QCoreApplication::setApplicationName() has not been previously
-    called, the QSettings object will not be able to read or write
-    any settings, and status() will return AccessError.
+    QSettings::NativeFormat.
 
-    \sa QCoreApplication::setOrganizationName(),
-        QCoreApplication::setOrganizationDomain(),
-        QCoreApplication::setApplicationName(),
-        setDefaultFormat()
+    \sa QCoreApplication::setApplicationName()
 */
 QSettings::QSettings(QObject *parent)
-    : QObject(*QSettingsPrivate::create(globalDefaultFormat, UserScope,
-                                        QCoreApplication::organizationName().isEmpty()
-                                            ? QCoreApplication::organizationDomain()
-                                            : QCoreApplication::organizationName()
-                                        , QCoreApplication::applicationName()),
-              parent)
+    : QObject(*new QSettingsPrivate(QSettings::NativeFormat, UserScope), parent)
 {
+    QMutexLocker locker(qSettingsMutex());
+    qGlobalSettings()->append(this);
+    Q_D(QSettings);
+    d->read();
 }
 
 /*!
@@ -2409,32 +982,23 @@ QSettings::QSettings(QObject *parent)
 */
 QSettings::~QSettings()
 {
-    Q_D(QSettings);
-    if (d->pendingChanges) {
-        QT_TRY {
-            d->sync();
-        } QT_CATCH(...) {
-            ; // ok. then don't sync but at least don't throw in the destructor
-        }
-    }
+    QSettings::sync();
+    QMutexLocker locker(qSettingsMutex());
+    const int index = qGlobalSettings()->indexOf(this);
+    qGlobalSettings()->remove(index);
 }
 
 /*!
     Removes all entries in the primary location associated to this
     QSettings object.
 
-    Entries in fallback locations are not removed.
-
-    If you only want to remove the entries in the current group(),
-    use remove("") instead.
-
-    \sa remove(), setFallbacksEnabled()
+    \sa remove()
 */
 void QSettings::clear()
 {
     Q_D(QSettings);
-    d->clear();
-    d->requestUpdate();
+    d->map.clear();
+    d->notify();
 }
 
 /*!
@@ -2451,22 +1015,20 @@ void QSettings::clear()
 void QSettings::sync()
 {
     Q_D(QSettings);
-    d->sync();
+    d->write();
+    d->notify();
 }
 
 /*!
     Returns the path where settings written using this QSettings
     object are stored.
 
-    On Windows, if the format is QSettings::NativeFormat, the return value
-    is a system registry path, not a file path.
-
     \sa isWritable(), format()
 */
 QString QSettings::fileName() const
 {
     Q_D(const QSettings);
-    return d->fileName();
+    return d->filename;
 }
 
 /*!
@@ -2474,7 +1036,7 @@ QString QSettings::fileName() const
 
     Returns the format used for storing the settings.
 
-    \sa defaultFormat(), fileName(), scope(), organizationName(), applicationName()
+    \sa fileName(), scope()
 */
 QSettings::Format QSettings::format() const
 {
@@ -2487,7 +1049,7 @@ QSettings::Format QSettings::format() const
 
     Returns the scope used for storing the settings.
 
-    \sa format(), organizationName(), applicationName()
+    \sa format()
 */
 QSettings::Scope QSettings::scope() const
 {
@@ -2496,87 +1058,6 @@ QSettings::Scope QSettings::scope() const
 }
 
 /*!
-    \since 4.4
-
-    Returns the organization name used for storing the settings.
-
-    \sa QCoreApplication::organizationName(), format(), scope(), applicationName()
-*/
-QString QSettings::organizationName() const
-{
-    Q_D(const QSettings);
-    return d->organizationName;
-}
-
-/*!
-    \since 4.4
-
-    Returns the application name used for storing the settings.
-
-    \sa QCoreApplication::applicationName(), format(), scope(), organizationName()
-*/
-QString QSettings::applicationName() const
-{
-    Q_D(const QSettings);
-    return d->applicationName;
-}
-
-#ifndef QT_NO_TEXTCODEC
-
-/*!
-    \since 4.5
-
-    Sets the codec for accessing INI files (including \c .conf files on Unix)
-    to \a codec. The codec is used for decoding any data that is read from
-    the INI file, and for encoding any data that is written to the file. By
-    default, no codec is used, and non-ASCII characters are encoded using
-    standard INI escape sequences.
-
-    \warning The codec must be set immediately after creating the QSettings
-    object, before accessing any data.
-
-    \sa iniCodec()
-*/
-void QSettings::setIniCodec(QTextCodec *codec)
-{
-    Q_D(QSettings);
-    d->iniCodec = codec;
-}
-
-/*!
-    \since 4.5
-    \overload
-
-    Sets the codec for accessing INI files (including \c .conf files on Unix)
-    to the QTextCodec for the encoding specified by \a codecName. Common
-    values for \c codecName include "ISO 8859-1", "UTF-8", and "UTF-16".
-    If the encoding isn't recognized, nothing happens.
-
-    \sa QTextCodec::codecForName()
-*/
-void QSettings::setIniCodec(const char *codecName)
-{
-    Q_D(QSettings);
-    if (QTextCodec *codec = QTextCodec::codecForName(codecName))
-        d->iniCodec = codec;
-}
-
-/*!
-    \since 4.5
-
-    Returns the codec that is used for accessing INI files. By default,
-    no codec is used, so a null pointer is returned.
-*/
-
-QTextCodec *QSettings::iniCodec() const
-{
-    Q_D(const QSettings);
-    return d->iniCodec;
-}
-
-#endif // QT_NO_TEXTCODEC
-
-/*!
     Returns a status code indicating the first error that was met by
     QSettings, or QSettings::NoError if no error occurred.
 
@@ -2593,250 +1074,30 @@ QSettings::SettingsStatus QSettings::status() const
 }
 
 /*!
-    Appends \a prefix to the current group.
-
-    The current group is automatically prepended to all keys
-    specified to QSettings. In addition, query functions such as
-    childGroups(), childKeys(), and allKeys() are based on the group.
-    By default, no group is set.
-
-    Groups are useful to avoid typing in the same setting paths over
-    and over. For example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 13
-
-    This will set the value of three settings:
-
-    \list
-    \o \c mainwindow/size
-    \o \c mainwindow/fullScreen
-    \o \c outputpanel/visible
-    \endlist
-
-    Call endGroup() to reset the current group to what it was before
-    the corresponding beginGroup() call. Groups can be nested.
-
-    \sa endGroup(), group()
-*/
-void QSettings::beginGroup(const QString &prefix)
-{
-    Q_D(QSettings);
-    d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix)));
-}
-
-/*!
-    Resets the group to what it was before the corresponding
-    beginGroup() call.
-
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 14
-
-    \sa beginGroup(), group()
-*/
-void QSettings::endGroup()
-{
-    Q_D(QSettings);
-    if (d->groupStack.isEmpty()) {
-        qWarning("QSettings::endGroup: No matching beginGroup()");
-        return;
-    }
-
-    QSettingsGroup group = d->groupStack.pop();
-    int len = group.toString().size();
-    if (len > 0)
-        d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1));
-
-    if (group.isArray())
-        qWarning("QSettings::endGroup: Expected endArray() instead");
-}
-
-/*!
-    Returns the current group.
-
-    \sa beginGroup(), endGroup()
-*/
-QString QSettings::group() const
-{
-    Q_D(const QSettings);
-    return d->groupPrefix.left(d->groupPrefix.size() - 1);
-}
-
-/*!
-    Adds \a prefix to the current group and starts reading from an
-    array. Returns the size of the array.
-
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 15
-
-    Use beginWriteArray() to write the array in the first place.
-
-    \sa beginWriteArray(), endArray(), setArrayIndex()
-*/
-int QSettings::beginReadArray(const QString &prefix)
-{
-    Q_D(QSettings);
-    d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), false));
-    return value(QLatin1String("size")).toInt();
-}
-
-/*!
-    Adds \a prefix to the current group and starts writing an array
-    of size \a size. If \a size is -1 (the default), it is automatically
-    determined based on the indexes of the entries written.
-
-    If you have many occurrences of a certain set of keys, you can
-    use arrays to make your life easier. For example, let's suppose
-    that you want to save a variable-length list of user names and
-    passwords. You could then write:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 16
-
-    The generated keys will have the form
-
-    \list
-    \o \c logins/size
-    \o \c logins/1/userName
-    \o \c logins/1/password
-    \o \c logins/2/userName
-    \o \c logins/2/password
-    \o \c logins/3/userName
-    \o \c logins/3/password
-    \o ...
-    \endlist
-
-    To read back an array, use beginReadArray().
-
-    \sa beginReadArray(), endArray(), setArrayIndex()
-*/
-void QSettings::beginWriteArray(const QString &prefix, int size)
-{
-    Q_D(QSettings);
-    d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), size < 0));
-
-    if (size < 0)
-        remove(QLatin1String("size"));
-    else
-        setValue(QLatin1String("size"), size);
-}
-
-/*!
-    Closes the array that was started using beginReadArray() or
-    beginWriteArray().
-
-    \sa beginReadArray(), beginWriteArray()
-*/
-void QSettings::endArray()
-{
-    Q_D(QSettings);
-    if (d->groupStack.isEmpty()) {
-        qWarning("QSettings::endArray: No matching beginArray()");
-        return;
-    }
-
-    QSettingsGroup group = d->groupStack.top();
-    int len = group.toString().size();
-    d->groupStack.pop();
-    if (len > 0)
-        d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1));
-
-    if (group.arraySizeGuess() != -1)
-        setValue(group.name() + QLatin1String("/size"), group.arraySizeGuess());
-
-    if (!group.isArray())
-        qWarning("QSettings::endArray: Expected endGroup() instead");
-}
-
-/*!
-    Sets the current array index to \a i. Calls to functions such as
-    setValue(), value(), remove(), and contains() will operate on the
-    array entry at that index.
-
-    You must call beginReadArray() or beginWriteArray() before you
-    can call this function.
-*/
-void QSettings::setArrayIndex(int i)
-{
-    Q_D(QSettings);
-    if (d->groupStack.isEmpty() || !d->groupStack.top().isArray()) {
-        qWarning("QSettings::setArrayIndex: Missing beginArray()");
-        return;
-    }
-
-    QSettingsGroup &top = d->groupStack.top();
-    int len = top.toString().size();
-    top.setArrayIndex(qMax(i, 0));
-    d->groupPrefix.replace(d->groupPrefix.size() - len - 1, len, top.toString());
-}
-
-/*!
-    Returns a list of all keys, including subkeys, that can be read
-    using the QSettings object.
-
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 17
-
-    If a group is set using beginGroup(), only the keys in the group
-    are returned, without the group prefix:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 18
-
-    \sa childGroups(), childKeys()
-*/
-QStringList QSettings::allKeys() const
-{
-    Q_D(const QSettings);
-    return d->children(d->groupPrefix, QSettingsPrivate::AllKeys);
-}
-
-/*!
-    Returns a list of all top-level keys that can be read using the
-    QSettings object.
-
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 19
-
-    If a group is set using beginGroup(), the top-level keys in that
-    group are returned, without the group prefix:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 20
-
-    You can navigate through the entire setting hierarchy using
-    childKeys() and childGroups() recursively.
+    Returns a map of all keys, with their values, that the QSettings
+    object holds.
 
-    \sa childGroups(), allKeys()
+    \sa keys()
 */
-QStringList QSettings::childKeys() const
+QSettings::SettingsMap QSettings::map() const
 {
     Q_D(const QSettings);
-    return d->children(d->groupPrefix, QSettingsPrivate::ChildKeys);
+    return d->map;
 }
 
 /*!
     Returns a list of all key top-level groups that contain keys that
     can be read using the QSettings object.
 
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 21
-
-    If a group is set using beginGroup(), the first-level keys in
-    that group are returned, without the group prefix.
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 22
-
     You can navigate through the entire setting hierarchy using
-    childKeys() and childGroups() recursively.
+    keys() and map().
 
-    \sa childKeys(), allKeys()
+    \sa map()
 */
-QStringList QSettings::childGroups() const
+QStringList QSettings::keys() const
 {
     Q_D(const QSettings);
-    return d->children(d->groupPrefix, QSettingsPrivate::ChildGroups);
+    return d->map.keys();
 }
 
 /*!
@@ -2854,7 +1115,8 @@ QStringList QSettings::childGroups() const
 bool QSettings::isWritable() const
 {
     Q_D(const QSettings);
-    return d->isWritable();
+    QFileInfo info(d->filename);
+    return info.isWritable();
 }
 
 /*!
@@ -2862,112 +1124,37 @@ bool QSettings::isWritable() const
   Sets the value of setting \a key to \a value. If the \a key already
   exists, the previous value is overwritten.
 
-  Example:
-
-  \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 23
-
   \sa value(), remove(), contains()
 */
 void QSettings::setValue(const QString &key, const QVariant &value)
 {
     Q_D(QSettings);
-    QString k = d->actualKey(key);
-    d->set(k, value);
-    d->requestUpdate();
+    d->map.insert(key, value);
+    d->notify();
 }
 
 /*!
-    Removes the setting \a key and any sub-settings of \a key.
-
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 24
-
-    Be aware that if one of the fallback locations contains a setting
-    with the same key, that setting will be visible after calling
-    remove().
-
-    If \a key is an empty string, all keys in the current group() are
-    removed. For example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 25
+    Removes the setting \a key.
 
     \sa setValue(), value(), contains()
 */
 void QSettings::remove(const QString &key)
 {
     Q_D(QSettings);
-    /*
-        We cannot use actualKey(), because remove() supports empty
-        keys. The code is also tricky because of slash handling.
-    */
-    QString theKey = d->normalizedKey(key);
-    if (theKey.isEmpty())
-        theKey = group();
-    else
-        theKey.prepend(d->groupPrefix);
-
-    if (theKey.isEmpty()) {
-        d->clear();
-    } else {
-        d->remove(theKey);
-    }
-    d->requestUpdate();
+    d->map.remove(key);
+    d->notify();
 }
 
 /*!
     Returns true if there exists a setting called \a key; returns
     false otherwise.
 
-    If a group is set using beginGroup(), \a key is taken to be
-    relative to that group.
-
     \sa value(), setValue()
 */
 bool QSettings::contains(const QString &key) const
 {
     Q_D(const QSettings);
-    QString k = d->actualKey(key);
-    return d->get(k, 0);
-}
-
-/*!
-    Sets whether fallbacks are enabled to \a b.
-
-    By default, fallbacks are enabled.
-
-    \sa fallbacksEnabled()
-*/
-void QSettings::setFallbacksEnabled(bool b)
-{
-    Q_D(QSettings);
-    d->fallbacks = !!b;
-}
-
-/*!
-    Returns true if fallbacks are enabled; returns false otherwise.
-
-    By default, fallbacks are enabled.
-
-    \sa setFallbacksEnabled()
-*/
-bool QSettings::fallbacksEnabled() const
-{
-    Q_D(const QSettings);
-    return d->fallbacks;
-}
-
-/*!
-    \reimp
-*/
-bool QSettings::event(QEvent *event)
-{
-    Q_D(QSettings);
-    if (event->type() == QEvent::UpdateRequest) {
-        d->update();
-        return true;
-    }
-    return QObject::event(event);
+    return d->map.contains(key);
 }
 
 /*!
@@ -2977,116 +1164,12 @@ bool QSettings::event(QEvent *event)
     If no default value is specified, a default QVariant is
     returned.
 
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 26
-
     \sa setValue(), contains(), remove()
 */
 QVariant QSettings::value(const QString &key, const QVariant &defaultValue) const
 {
     Q_D(const QSettings);
-    QVariant result = defaultValue;
-    QString k = d->actualKey(key);
-    d->get(k, &result);
-    return result;
-}
-
-/*!
-    \since 4.4
-
-    Sets the default file format to the given \a format, which is used
-    for storing settings for the QSettings(QObject *) constructor.
-
-    If no default format is set, QSettings::NativeFormat is used. See
-    the documentation for the QSettings constructor you are using to
-    see if that constructor will ignore this function.
-
-    \sa format()
-*/
-void QSettings::setDefaultFormat(Format format)
-{
-    globalDefaultFormat = format;
-}
-
-/*!
-    \since 4.4
-
-    Returns default file format used for storing settings for the QSettings(QObject *) constructor.
-    If no default format is set, QSettings::NativeFormat is used.
-
-    \sa format()
-*/
-QSettings::Format QSettings::defaultFormat()
-{
-    return globalDefaultFormat;
-}
-
-/*!
-    \obsolete
-
-    Use setPath() instead.
-
-    \oldcode
-        setSystemIniPath(path);
-    \newcode
-        setPath(QSettings::NativeFormat, QSettings::SystemScope, path);
-        setPath(QSettings::IniFormat, QSettings::SystemScope, path);
-    \endcode
-*/
-void QSettings::setSystemIniPath(const QString &dir)
-{
-    setPath(IniFormat, SystemScope, dir);
-    setPath(NativeFormat, SystemScope, dir);
-}
-
-/*!
-    \obsolete
-
-    Use setPath() instead.
-*/
-
-void QSettings::setUserIniPath(const QString &dir)
-{
-    setPath(IniFormat, UserScope, dir);
-    setPath(NativeFormat, UserScope, dir);
-}
-
-/*!
-    \since 4.1
-
-    Sets the path used for storing settings for the given \a format
-    and \a scope, to \a path. The \a format can be a custom format.
-
-    The table below summarizes the default values:
-
-    \table
-    \header \o Platform         \o Format                       \o Scope       \o Path
-    \row    \o{1,2} Unix        \o{1,2} NativeFormat, IniFormat \o UserScope   \o \c $HOME/.config
-    \row                                                        \o SystemScope \o \c /etc/xdg
-    \endtable
-
-    The default UserScope paths on Unix and Mac OS X (\c
-    $HOME/.config or $HOME/Settings) can be overridden by the user by setting the
-    \c XDG_CONFIG_HOME environment variable. The default SystemScope
-    paths on Unix and Mac OS X (\c /etc/xdg) can be overridden when
-    building the Qt library using the \c configure script's \c
-    --sysconfdir flag (see QLibraryInfo for details).
-
-    Setting the NativeFormat paths on Windows and Mac OS X has no
-    effect.
-
-    \warning This function doesn't affect existing QSettings objects.
-
-    \sa registerFormat()
-*/
-void QSettings::setPath(Format format, Scope scope, const QString &path)
-{
-    QMutexLocker locker(globalMutex());
-    PathHash *pathHash = pathHashFunc();
-    if (pathHash->isEmpty())
-        initDefaultPaths(&locker);
-    pathHash->insert(pathHashKey(format, scope), path + QDir::separator());
+    return d->map.value(key, defaultValue);
 }
 
 /*!
@@ -3141,45 +1224,25 @@ void QSettings::setPath(Format format, Scope scope, const QString &path)
     functions that read and write a set of key/value pairs. The
     QIODevice parameter to the read and write functions is always
     opened in binary mode (i.e., without the QIODevice::Text flag).
-
-    The \a caseSensitivity parameter specifies whether keys are case
-    sensitive or not. This makes a difference when looking up values
-    using QSettings. The default is case sensitive.
-
-    By default, if you use one of the constructors that work in terms
-    of an organization name and an application name, the file system
-    locations used are the same as for IniFormat. Use setPath() to
-    specify other locations.
-
-    Example:
-
-    \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 29
-
-    \sa setPath()
 */
 QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc readFunc,
-                                            WriteFunc writeFunc,
-                                            Qt::CaseSensitivity caseSensitivity)
+                                            WriteFunc writeFunc)
 {
-#ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
-    Q_ASSERT(caseSensitivity == Qt::CaseSensitive);
-#endif
-
-    QMutexLocker locker(globalMutex());
+    QMutexLocker locker(qSettingsMutex());
     CustomFormatVector *customFormatVector = customFormatVectorFunc();
     int index = customFormatVector->size();
     if (index == 16) // the QSettings::Format enum has room for 16 custom formats
         return QSettings::InvalidFormat;
 
-    QConfFileCustomFormat info;
+    QSettingsCustomFormat info;
+    info.format = static_cast<QSettings::Format>(QSettings::CustomFormat1 + index);
     info.extension = QLatin1Char('.');
     info.extension += extension;
     info.readFunc = readFunc;
     info.writeFunc = writeFunc;
-    info.caseSensitivity = caseSensitivity;
     customFormatVector->append(info);
 
-    return QSettings::Format((int)QSettings::CustomFormat1 + index);
+    return info.format;
 }
 
 #include "moc_qsettings.h"
index 925f3de..683143b 100644 (file)
@@ -85,32 +85,20 @@ public:
         SystemScope
     };
 
-    explicit QSettings(const QString &organization,
-                       const QString &application = QString(), QObject *parent = Q_NULLPTR);
-    QSettings(Scope scope, const QString &organization,
-              const QString &application = QString(), QObject *parent = Q_NULLPTR);
-    QSettings(Format format, Scope scope, const QString &organization,
-              const QString &application = QString(), QObject *parent = Q_NULLPTR);
-    QSettings(const QString &fileName, Format format, QObject *parent = Q_NULLPTR);
+    typedef QMap<QString, QVariant> SettingsMap;
+
     explicit QSettings(QObject *parent = Q_NULLPTR);
+    QSettings(Scope scope, QObject *parent = Q_NULLPTR);
+    QSettings(Format format, Scope scope, QObject *parent = Q_NULLPTR);
+    QSettings(const QString &fileName, Format format, QObject *parent = Q_NULLPTR);
     ~QSettings();
 
     void clear();
     void sync();
     SettingsStatus status() const;
 
-    void beginGroup(const QString &prefix);
-    void endGroup();
-    QString group() const;
-
-    int beginReadArray(const QString &prefix);
-    void beginWriteArray(const QString &prefix, int size = -1);
-    void endArray();
-    void setArrayIndex(int i);
-
-    QStringList allKeys() const;
-    QStringList childKeys() const;
-    QStringList childGroups() const;
+    SettingsMap map() const;
+    QStringList keys() const;
     bool isWritable() const;
 
     void setValue(const QString &key, const QVariant &value);
@@ -119,36 +107,14 @@ public:
     void remove(const QString &key);
     bool contains(const QString &key) const;
 
-    void setFallbacksEnabled(bool b);
-    bool fallbacksEnabled() const;
-
     QString fileName() const;
     Format format() const;
     Scope scope() const;
-    QString organizationName() const;
-    QString applicationName() const;
-
-#ifndef QT_NO_TEXTCODEC
-    void setIniCodec(QTextCodec *codec);
-    void setIniCodec(const char *codecName);
-    QTextCodec *iniCodec() const;
-#endif
-
-    static void setDefaultFormat(Format format);
-    static Format defaultFormat();
-    static void setSystemIniPath(const QString &dir); // ### remove in 5.0 (use setPath() instead)
-    static void setUserIniPath(const QString &dir);   // ### remove in 5.0 (use setPath() instead)
-    static void setPath(Format format, Scope scope, const QString &path);
 
-    typedef QMap<QString, QVariant> SettingsMap;
     typedef bool (*ReadFunc)(QIODevice &device, SettingsMap &map);
     typedef bool (*WriteFunc)(QIODevice &device, const SettingsMap &map);
 
-    static Format registerFormat(const QString &extension, ReadFunc readFunc, WriteFunc writeFunc,
-                                 Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive);
-
-protected:
-    bool event(QEvent *event);
+    static Format registerFormat(const QString &extension, ReadFunc readFunc, WriteFunc writeFunc);
 
 private:
     Q_DISABLE_COPY(QSettings)
index 1b30524..2b4f8f7 100644 (file)
 // We mean it.
 //
 
-#include "QtCore/qdatetime.h"
-#include "QtCore/qmutex.h"
-#include "QtCore/qstack.h"
-#include "QtCore/qstringlist.h"
+#include "qdatetime.h"
+#include "qstringlist.h"
+
 #ifndef QT_NO_QOBJECT
 #include "qobject_p.h"
 #endif
-#include "qscopedpointer_p.h"
 
 QT_BEGIN_NAMESPACE
 
-// used in testing framework
-#define QSETTINGS_P_H_VERSION 3
-
-// defined in some tests
-#ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
-static const Qt::CaseSensitivity IniCaseSensitivity = Qt::CaseSensitive;
-
-class QSettingsKey : public QString
-{
-public:
-    inline QSettingsKey(const QString &key, Qt::CaseSensitivity cs, int /* position */ = -1)
-        : QString(key) { Q_ASSERT(cs == Qt::CaseSensitive); Q_UNUSED(cs); }
-
-    inline QString originalCaseKey() const { return *this; }
-    inline int originalKeyPosition() const { return -1; }
-};
-#else
-static const Qt::CaseSensitivity IniCaseSensitivity = Qt::CaseInsensitive;
-
-class QSettingsKey : public QString
-{
-public:
-    inline QSettingsKey(const QString &key, Qt::CaseSensitivity cs, int position = -1)
-         : QString(key), theOriginalKey(key), theOriginalKeyPosition(position)
-    {
-        if (cs == Qt::CaseInsensitive)
-            QString::operator=(toLower());
-    }
-
-    inline QString originalCaseKey() const { return theOriginalKey; }
-    inline int originalKeyPosition() const { return theOriginalKeyPosition; }
-
-private:
-    QString theOriginalKey;
-    int theOriginalKeyPosition;
-};
-#endif
-
-typedef QMap<QSettingsKey, QByteArray> UnparsedSettingsMap;
-typedef QMap<QSettingsKey, QVariant> ParsedSettingsMap;
-
-class QSettingsGroup
-{
-public:
-    inline QSettingsGroup()
-        : num(-1), maxNum(-1) {}
-    inline QSettingsGroup(const QString &s)
-        : str(s), num(-1), maxNum(-1) {}
-    inline QSettingsGroup(const QString &s, bool guessArraySize)
-        : str(s), num(0), maxNum(guessArraySize ? 0 : -1) {}
-
-    inline QString name() const { return str; }
-    inline QString toString() const;
-    inline bool isArray() const { return num != -1; }
-    inline int arraySizeGuess() const { return maxNum; }
-    inline void setArrayIndex(int i)
-    { num = i + 1; if (maxNum != -1 && num > maxNum) maxNum = num; }
-
-    QString str;
-    int num;
-    int maxNum;
-};
-
-inline QString QSettingsGroup::toString() const
-{
-    QString result;
-    result = str;
-    if (num > 0) {
-        result += QLatin1Char('/');
-        result += QString::number(num);
-    }
-    return result;
-}
-
-class Q_AUTOTEST_EXPORT QConfFile
-{
-public:
-    ~QConfFile();
-
-    ParsedSettingsMap mergedKeyMap() const;
-    bool isWritable() const;
-
-    static QConfFile *fromName(const QString &name, bool _userPerms);
-    static void clearCache();
-
-    QString name;
-    QDateTime timeStamp;
-    qint64 size;
-    UnparsedSettingsMap unparsedIniSections;
-    ParsedSettingsMap originalKeys;
-    ParsedSettingsMap addedKeys;
-    ParsedSettingsMap removedKeys;
-    QAtomicInt ref;
-    QMutex mutex;
-    bool userPerms;
-
-private:
-#ifdef Q_DISABLE_COPY
-    QConfFile(const QConfFile &);
-    QConfFile &operator=(const QConfFile &);
-#endif
-    QConfFile(const QString &name, bool _userPerms);
-
-    friend class QConfFile_createsItself; // silences compiler warning
-};
-
 class Q_AUTOTEST_EXPORT QSettingsPrivate
 #ifndef QT_NO_QOBJECT
     : public QObjectPrivate
@@ -173,120 +65,30 @@ class Q_AUTOTEST_EXPORT QSettingsPrivate
     Q_DECLARE_PUBLIC(QSettings)
 
 public:
-    QSettingsPrivate(QSettings::Format format);
-    QSettingsPrivate(QSettings::Format format, QSettings::Scope scope,
-                     const QString &organization, const QString &application);
-    virtual ~QSettingsPrivate();
-
-    virtual void remove(const QString &key) = 0;
-    virtual void set(const QString &key, const QVariant &value) = 0;
-    virtual bool get(const QString &key, QVariant *value) const = 0;
-
-    enum ChildSpec { AllKeys, ChildKeys, ChildGroups };
-    virtual QStringList children(const QString &prefix, ChildSpec spec) const = 0;
-
-    virtual void clear() = 0;
-    virtual void sync() = 0;
-    virtual bool isWritable() const = 0;
-    virtual QString fileName() const = 0;
-
-    QString actualKey(const QString &key) const;
-    void beginGroupOrArray(const QSettingsGroup &group);
-    void setStatus(QSettings::SettingsStatus status) const;
-    void requestUpdate();
-    void update();
-
-    static QString normalizedKey(const QString &key);
-    static QSettingsPrivate *create(QSettings::Format format, QSettings::Scope scope,
-                                        const QString &organization, const QString &application);
-    static QSettingsPrivate *create(const QString &fileName, QSettings::Format format);
+    QSettingsPrivate(QSettings::Format format, QSettings::Scope scope);
+    QSettingsPrivate(const QString &fileName, QSettings::Format format);
+    ~QSettingsPrivate();
 
-    static void processChild(QString key, ChildSpec spec, QMap<QString, QString> &result);
+    void read();
+    void write();
 
-    // Variant streaming functions
-    static QStringList variantListToStringList(const QVariantList &l);
-    static QVariant stringListToVariantList(const QStringList &l);
-
-    // parser functions
+    // INI parser functions
     static QString variantToString(const QVariant &v);
     static QVariant stringToVariant(const QString &s);
-    static void iniEscapedKey(const QString &key, QByteArray &result);
-    static bool iniUnescapedKey(const QByteArray &key, int from, int to, QString &result);
-    static void iniEscapedString(const QString &str, QByteArray &result, QTextCodec *codec);
-    static void iniEscapedStringList(const QStringList &strs, QByteArray &result, QTextCodec *codec);
-    static bool iniUnescapedStringList(const QByteArray &str, int from, int to,
-                                       QString &stringResult, QStringList &stringListResult,
-                                       QTextCodec *codec);
     static QStringList splitArgs(const QString &s, int idx);
 
-    /*
-    The numeric values of these enums define their search order. For example,
-    F_User | F_Organization is searched before F_System | F_Application,
-    because their values are respectively 1 and 2.
-    */
-    enum {
-        F_Application = 0x0,
-        F_Organization = 0x1,
-        F_User = 0x0,
-        F_System = 0x2,
-        NumConfFiles = 4
-    };
+    void notify();
 
     QSettings::Format format;
     QSettings::Scope scope;
-    QString organizationName;
-    QString applicationName;
-    QTextCodec *iniCodec;
-
-protected:
-    QStack<QSettingsGroup> groupStack;
-    QString groupPrefix;
-    int spec;
-    bool fallbacks;
-    bool pendingChanges;
-    mutable QSettings::SettingsStatus status;
-};
-
-class QConfFileSettingsPrivate : public QSettingsPrivate
-{
-public:
-    QConfFileSettingsPrivate(QSettings::Format format, QSettings::Scope scope,
-                             const QString &organization, const QString &application);
-    QConfFileSettingsPrivate(const QString &fileName, QSettings::Format format);
-    ~QConfFileSettingsPrivate();
+    QSettings::SettingsStatus status;
+    QString filename;
+    QSettings::SettingsMap map;
 
-    void remove(const QString &key);
-    void set(const QString &key, const QVariant &value);
-    bool get(const QString &key, QVariant *value) const;
-
-    QStringList children(const QString &prefix, ChildSpec spec) const;
-
-    void clear();
-    void sync();
-    void flush();
-    bool isWritable() const;
-    QString fileName() const;
-
-    static bool readIniFile(const QByteArray &data, UnparsedSettingsMap *unparsedIniSections);
-    static bool readIniSection(const QSettingsKey &section, const QByteArray &data,
-                               ParsedSettingsMap *settingsMap, QTextCodec *codec);
-    static bool readIniLine(const QByteArray &data, int &dataPos, int &lineStart, int &lineLen,
-                            int &equalsPos);
-
-private:
-    void initFormat();
-    void initAccess();
-    void syncConfFile(int confFileNo);
-    bool writeIniFile(QIODevice &device, const ParsedSettingsMap &map);
-    void ensureAllSectionsParsed(QConfFile *confFile) const;
-    void ensureSectionParsed(QConfFile *confFile, const QSettingsKey &key) const;
-
-    QScopedSharedPointer<QConfFile> confFiles[NumConfFiles];
     QSettings::ReadFunc readFunc;
     QSettings::WriteFunc writeFunc;
-    QString extension;
-    Qt::CaseSensitivity caseSensitivity;
-    int nextPosition;
+
+    QDateTime timestamp;
 };
 
 QT_END_NAMESPACE
index 85b3119..488d12b 100644 (file)
@@ -334,31 +334,40 @@ QJsonValue &QJsonValue::operator =(const QJsonValue &other)
  */
 QJsonValue QJsonValue::fromVariant(const QVariant &variant)
 {
-   switch (variant.type()) {
-      case QVariant::Bool:
-         return QJsonValue(variant.toBool());
-      case QVariant::Int:
-      case QVariant::Double:
-      case QVariant::LongLong:
-      case QVariant::ULongLong:
-      case QVariant::UInt:
-         return QJsonValue(variant.toDouble());
-      case QVariant::String:
-         return QJsonValue(variant.toString());
-      case QVariant::StringList:
-         return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
-      case QVariant::List:
-         return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
-      case QVariant::Map:
-         return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
-      default:
-         break;
-   }
-   QString string = variant.toString();
-   if (string.isEmpty()) {
-      return QJsonValue();
-   }
-   return QJsonValue(string);
+    switch (variant.type()) {
+        case QVariant::Bool:
+            return QJsonValue(variant.toBool());
+        case QVariant::Int:
+        case QVariant::Double:
+        case QVariant::LongLong:
+        case QVariant::ULongLong:
+        case QVariant::UInt:
+            return QJsonValue(variant.toDouble());
+        case QVariant::String:
+            return QJsonValue(variant.toString());
+        case QVariant::StringList:
+            return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
+        case QVariant::List:
+            return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
+        case QVariant::Map:
+            return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
+        default:
+            break;
+    }
+
+    QByteArray a;
+    {
+        QDataStream s(&a, QIODevice::WriteOnly);
+        s << variant;
+    }
+    if (a.isEmpty()) {
+        return QJsonValue();
+    }
+
+    QString result = QLatin1String("@(");
+    result += QString::fromLatin1(a.constData(), a.size());
+    result += QLatin1String(")@");
+    return QJsonValue(result);
 }
 
 /*!
@@ -378,25 +387,38 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
  */
 QVariant QJsonValue::toVariant() const
 {
-   switch (t) {
-      case Bool:
-         return b;
-      case Double:
-         return dbl;
-      case String:
-         return toString();
-      case Array:
-         return d ?
-                QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() :
-                QVariantList();
-      case Object:
-         return d ?
-                QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() :
-                QVariantMap();
-      case Null:
-      case Undefined:
-         break;
-   }
+    switch (t) {
+        case Bool:
+            return b;
+        case Double:
+            return dbl;
+        case String: {
+            QVariant variant = toString();
+            QString string = variant.toString();
+            if (string.startsWith(QLatin1String("@(")) && string.endsWith(")@")) {
+                QByteArray a(string.toLatin1());
+                a.remove(0, 2);
+                a.chop(2);
+                QDataStream stream(&a, QIODevice::ReadOnly);
+                QVariant result;
+                stream >> result;
+                return result;
+            }
+            return variant;
+        }
+        case Array:
+            return d ?
+                    QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() :
+                    QVariantList();
+        case Object:
+            return d ?
+                    QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() :
+                    QVariantMap();
+        case Null:
+        case Undefined:
+            return QVariant();
+    }
+
    return QVariant();
 }
 
index 746d559..6b823d7 100644 (file)
@@ -160,7 +160,7 @@ Q_CORE_EXPORT bool qt_locale_initialized = false;
   be thrown out of QSetting's cache for unused settings.
   */
 #ifndef QT_NO_SETTINGS
-Q_GLOBAL_STATIC_WITH_ARGS(QSettings, staticKatieConf, (QSettings::UserScope, QLatin1String("Katie")))
+Q_GLOBAL_STATIC_WITH_ARGS(QSettings, staticKatieConf, (QLatin1String("Katie"), QSettings::NativeFormat))
 
 QSettings *QCoreApplicationPrivate::staticConf()
 {
index 682b324..5da8003 100644 (file)
@@ -549,7 +549,7 @@ QDesignerPluginManager::QDesignerPluginManager(QDesignerFormEditorInterface *cor
     m_d(new QDesignerPluginManagerPrivate(core))
 {
     m_d->m_pluginPaths = defaultPluginPaths();
-    const QSettings settings(qApp->organizationName(), QDesignerQSettings::settingsApplicationName());
+    const QDesignerQSettings settings;
     m_d->m_disabledPlugins = unique(settings.value(QLatin1String("PluginManager/DisabledPlugins")).toStringList());
 
     // Register plugins
@@ -709,7 +709,7 @@ void QDesignerPluginManager::registerPlugin(const QString &plugin)
 
 bool QDesignerPluginManager::syncSettings()
 {
-    QSettings settings(qApp->organizationName(), QDesignerQSettings::settingsApplicationName());
+    QDesignerQSettings settings;
     settings.beginGroup(QLatin1String("PluginManager"));
     settings.setValue(QLatin1String("DisabledPlugins"), m_d->m_disabledPlugins);
     settings.endGroup();
index 507fa48..04786ad 100644 (file)
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
   */
 
 QDesignerQSettings::QDesignerQSettings() :
-    m_settings(qApp->organizationName(), settingsApplicationName())
+    m_settings(settingsApplicationName(), QSettings::NativeFormat)
 {
 }
 
@@ -67,12 +67,13 @@ QString QDesignerQSettings::settingsApplicationName()
 
 void QDesignerQSettings::beginGroup(const QString &prefix)
 {
-    m_settings.beginGroup(prefix);
+    Q_ASSERT(m_group.isEmpty()); // no sub-groups support
+    m_group = prefix;
 }
 
 void QDesignerQSettings::endGroup()
 {
-    m_settings.endGroup();
+    m_group.clear();
 }
 
 bool QDesignerQSettings::contains(const QString &key) const
@@ -82,12 +83,19 @@ bool QDesignerQSettings::contains(const QString &key) const
 
 void QDesignerQSettings::setValue(const QString &key, const QVariant &value)
 {
-    m_settings.setValue(key, value);
+    if (m_group.isEmpty()) {
+        m_settings.setValue(key, value);
+    } else {
+        m_settings.setValue(m_group + QLatin1Char('/') + key, value);
+    }
 }
 
 QVariant QDesignerQSettings::value(const QString &key, const QVariant &defaultValue) const
 {
-    return m_settings.value(key, defaultValue);
+    if (m_group.isEmpty()) {
+        return m_settings.value(key, defaultValue);
+    }
+    return m_settings.value(m_group + QLatin1Char('/') + key, defaultValue);
 }
 
 void QDesignerQSettings::remove(const QString &key)
@@ -95,4 +103,9 @@ void QDesignerQSettings::remove(const QString &key)
     m_settings.remove(key);
 }
 
+QSettings::SettingsStatus QDesignerQSettings::status() const
+{
+    return m_settings.status();
+}
+
 QT_END_NAMESPACE
index a07196d..262164c 100644 (file)
@@ -66,12 +66,15 @@ public:
     virtual QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
     virtual void remove(const QString &key);
 
+    virtual QSettings::SettingsStatus status() const;
+
     // The application name to be used for settings. Allows for including
     // the Qt version to prevent settings of different Qt versions from
     // interfering.
     static QString settingsApplicationName();
 
 private:
+    QString m_group;
     QSettings m_settings;
 };
 
index c2e0a50..d0a57bb 100644 (file)
@@ -63,6 +63,7 @@
 #include "qspinbox.h"
 #include "qdialogbuttonbox.h"
 #include "qguiplatformplugin.h"
+#include "qcoreapplication_p.h"
 
 QT_BEGIN_NAMESPACE
 
@@ -1393,9 +1394,9 @@ void QColorDialogPrivate::init(const QColor &initial)
     initRGB();
 
     if (!customSet) {
-        QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
+        QSettings *settings = QCoreApplicationPrivate::staticConf();
         for (int i = 0; i < 2*8; ++i) {
-            QVariant v = settings.value(QLatin1String("Qt/customColors/") + QString::number(i));
+            QVariant v = settings->value(QLatin1String("Qt/customColors/") + QString::number(i));
             if (v.isValid()) {
                 QRgb rgb = v.toUInt();
                 cusrgb[i] = rgb;
@@ -1810,9 +1811,9 @@ QColorDialog::~QColorDialog()
     Q_D(QColorDialog);
 
     if (!customSet) {
-        QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
+        QSettings *settings = QCoreApplicationPrivate::staticConf();
         for (int i = 0; i < 2*8; ++i)
-            settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), cusrgb[i]);
+            settings->setValue(QLatin1String("Qt/customColors/") + QString::number(i), cusrgb[i]);
     }
     if (d->nativeDialogInUse)
         qt_guiPlatformPlugin()->colorDialogDelete(this);
index 8ef9348..fc7852f 100644 (file)
@@ -58,6 +58,7 @@
 #include "qapplication.h"
 #include "qstylepainter.h"
 #include "qfileiconprovider_p.h"
+#include "qcoreapplication_p.h"
 #include "ui_qfiledialog.h"
 
 #include <stdlib.h>
@@ -330,9 +331,8 @@ QFileDialog::QFileDialog(const QFileDialogArgs &args)
 QFileDialog::~QFileDialog()
 {
     Q_D(QFileDialog);
-    QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
-    settings.beginGroup(QLatin1String("Qt"));
-    settings.setValue(QLatin1String("filedialog"), saveState());
+    QSettings *settings = QCoreApplicationPrivate::staticConf();
+    settings->setValue(QLatin1String("Qt/filedialog"), saveState());
     d->deleteNativeDialog_sys();
 }
 
@@ -2025,11 +2025,10 @@ void QFileDialogPrivate::init(const QString &directory, const QString &nameFilte
     retranslateStrings();
     q->setFileMode(fileMode);
 
-    QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
-    settings.beginGroup(QLatin1String("Qt"));
+    QSettings *settings = QCoreApplicationPrivate::staticConf();
     if (!directory.isEmpty())
         setLastVisitedDirectory(workingDirectory(directory));
-    q->restoreState(settings.value(QLatin1String("filedialog")).toByteArray());
+    q->restoreState(settings->value(QLatin1String("Qt/filedialog")).toByteArray());
 
     // Default case
     if (!nameFilter.isEmpty())
index 97edae6..b40216a 100644 (file)
@@ -143,7 +143,7 @@ QIconTheme::QIconTheme(const QString &themeName)
     }
     if (themeIndex.exists()) {
         const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
-        QStringListIterator keyIterator(indexReader.allKeys());
+        QStringListIterator keyIterator(indexReader.keys());
         while (keyIterator.hasNext()) {
 
             const QString key = keyIterator.next();
index fbeee08..4b90668 100644 (file)
@@ -697,9 +697,7 @@ bool QApplicationPrivate::x11_apply_settings()
         return true;
     }
 
-    QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
-
-    settings.beginGroup(QLatin1String("Qt"));
+    QSettings *settings = QCoreApplicationPrivate::staticConf();
 
     /*
       Qt settings. This is now they are written into the datastream.
@@ -722,21 +720,21 @@ bool QApplicationPrivate::x11_apply_settings()
 
     QPalette pal(Qt::black);
     int groupCount = 0;
-    QStringList strlist = settings.value(QLatin1String("Palette/active")).toStringList();
+    QStringList strlist = settings->value(QLatin1String("Qt/Palette/active")).toStringList();
     if (!strlist.isEmpty()) {
         ++groupCount;
         for (int i = 0; i < qMin(strlist.count(), int(QPalette::NColorRoles)); i++)
             pal.setColor(QPalette::Active, (QPalette::ColorRole) i,
                          QColor(strlist[i]));
     }
-    strlist = settings.value(QLatin1String("Palette/inactive")).toStringList();
+    strlist = settings->value(QLatin1String("Qt/Palette/inactive")).toStringList();
     if (!strlist.isEmpty()) {
         ++groupCount;
         for (int i = 0; i < qMin(strlist.count(), int(QPalette::NColorRoles)); i++)
             pal.setColor(QPalette::Inactive, (QPalette::ColorRole) i,
                          QColor(strlist[i]));
     }
-    strlist = settings.value(QLatin1String("Palette/disabled")).toStringList();
+    strlist = settings->value(QLatin1String("Qt/Palette/disabled")).toStringList();
     if (!strlist.isEmpty()) {
         ++groupCount;
         for (int i = 0; i < qMin(strlist.count(), int(QPalette::NColorRoles)); i++)
@@ -749,7 +747,7 @@ bool QApplicationPrivate::x11_apply_settings()
         QApplicationPrivate::setSystemPalette(pal);
 
     if (!appFont) {
-        QString fontDescription = settings.value(QLatin1String("font")).toString();
+        QString fontDescription = settings->value(QLatin1String("Qt/font")).toString();
         if (!fontDescription .isEmpty()) {
             QFont font(QApplication::font());
             font.fromString(fontDescription );
@@ -758,8 +756,7 @@ bool QApplicationPrivate::x11_apply_settings()
     }
 
     // read library (ie. plugin) path list
-    QString libpathkey = QString::fromLatin1("libraryPath");
-    QStringList pathlist = settings.value(libpathkey).toString().split(QLatin1Char(':'));
+    QStringList pathlist = settings->value(QLatin1String("Qt/libraryPath")).toString().split(QLatin1Char(':'));
     if (! pathlist.isEmpty()) {
         QStringList::ConstIterator it = pathlist.constBegin();
         while (it != pathlist.constEnd())
@@ -767,7 +764,7 @@ bool QApplicationPrivate::x11_apply_settings()
     }
 
     // read new QStyle
-    QString stylename = settings.value(QLatin1String("style")).toString();
+    QString stylename = settings->value(QLatin1String("Qt/style")).toString();
 
     if (stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull() && qt_x11Data->use_xrender) {
         stylename = qt_guiPlatformPlugin()->styleName();
@@ -784,21 +781,21 @@ bool QApplicationPrivate::x11_apply_settings()
         }
     }
 
-    int num = settings.value(QLatin1String("doubleClickInterval"),
+    int num = settings->value(QLatin1String("Qt/doubleClickInterval"),
                              QApplication::doubleClickInterval()).toInt();
     QApplication::setDoubleClickInterval(num);
 
-    num = settings.value(QLatin1String("cursorFlashTime"),
+    num = settings->value(QLatin1String("Qt/cursorFlashTime"),
                          QApplication::cursorFlashTime()).toInt();
     QApplication::setCursorFlashTime(num);
 
 #ifndef QT_NO_WHEELEVENT
-    num = settings.value(QLatin1String("wheelScrollLines"),
+    num = settings->value(QLatin1String("Qt/wheelScrollLines"),
                          QApplication::wheelScrollLines()).toInt();
     QApplication::setWheelScrollLines(num);
 #endif
 
-    QString defaultcodec = settings.value(QLatin1String("defaultCodec"),
+    QString defaultcodec = settings->value(QLatin1String("Qt/defaultCodec"),
                                           QVariant(QLatin1String("none"))).toString();
     if (defaultcodec != QLatin1String("none")) {
         QTextCodec *codec = QTextCodec::codecForName(defaultcodec.toLatin1());
@@ -806,13 +803,13 @@ bool QApplicationPrivate::x11_apply_settings()
             QTextCodec::setCodecForTr(codec);
     }
 
-    int w = settings.value(QLatin1String("globalStrut/width")).toInt();
-    int h = settings.value(QLatin1String("globalStrut/height")).toInt();
+    int w = settings->value(QLatin1String("Qt/globalStrut/width")).toInt();
+    int h = settings->value(QLatin1String("Qt/globalStrut/height")).toInt();
     QSize strut(w, h);
     if (strut.isValid())
         QApplication::setGlobalStrut(strut);
 
-    QStringList effects = settings.value(QLatin1String("GUIEffects")).toStringList();
+    QStringList effects = settings->value(QLatin1String("Qt/GUIEffects")).toStringList();
     QApplication::setEffectEnabled(Qt::UI_General,
                                    effects.contains(QLatin1String("general")));
     QApplication::setEffectEnabled(Qt::UI_AnimateMenu,
@@ -829,17 +826,16 @@ bool QApplicationPrivate::x11_apply_settings()
                                    effects.contains(QLatin1String("animatetoolbox")));
 
     if (!qt_x11Data->has_fontconfig) {
-        settings.beginGroup(QLatin1String("Font Substitutions"));
-        foreach (const QString &fam, settings.childKeys()) {
-            QStringList subs = settings.value(fam).toStringList();
+        foreach (const QString &fam, settings->keys()) {
+            if (!fam.startsWith(QLatin1String("Qt/Font Substitutions/"))) {
+                continue;
+            }
+            QStringList subs = settings->value(fam).toStringList();
             QFont::insertSubstitutions(fam, subs);
         }
-        settings.endGroup();
     }
 
-    qt_use_rtl_extensions = settings.value(QLatin1String("useRtlExtensions"), false).toBool();
-
-    settings.endGroup(); // Qt
+    qt_use_rtl_extensions = settings->value(QLatin1String("Qt/useRtlExtensions"), false).toBool();
 
     QIconLoader::instance()->updateSystemTheme();
 
@@ -1648,27 +1644,23 @@ void qt_init(QApplicationPrivate *priv, int,
         // read some non-GUI settings when not using the X server...
 
         if (QApplication::desktopSettingsAware()) {
-            QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
-            settings.beginGroup(QLatin1String("Qt"));
+            QSettings *settings = QCoreApplicationPrivate::staticConf();
 
             // read library (ie. plugin) path list
-            QString libpathkey = QString::fromLatin1("libraryPath");
-            QStringList pathlist = settings.value(libpathkey).toString().split(QLatin1Char(':'));
+            QStringList pathlist = settings->value(QLatin1String("Qt/libraryPath")).toString().split(QLatin1Char(':'));
             if (!pathlist.isEmpty()) {
                 QStringList::ConstIterator it = pathlist.constBegin();
                 while (it != pathlist.constEnd())
                     QApplication::addLibraryPath(*it++);
             }
 
-            QString defaultcodec = settings.value(QLatin1String("defaultCodec"),
+            QString defaultcodec = settings->value(QLatin1String("Qt/defaultCodec"),
                                                   QVariant(QLatin1String("none"))).toString();
             if (defaultcodec != QLatin1String("none")) {
                 QTextCodec *codec = QTextCodec::codecForName(defaultcodec.toLatin1());
                 if (codec)
                     QTextCodec::setCodecForTr(codec);
             }
-
-            settings.endGroup(); // Qt
         }
     }
 }
index 97056aa..64ea763 100644 (file)
@@ -67,6 +67,7 @@
 #include "qdebug.h"
 #include "qdrawhelper_p.h"
 #include "qmutexpool_p.h"
+#include "qcoreapplication_p.h"
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -177,9 +178,8 @@ QPSPrintEnginePrivate::QPSPrintEnginePrivate(QPrinter::PrinterMode m)
 
     firstPage = true;
 
-    QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
-    settings.beginGroup(QLatin1String("Qt"));
-    embedFonts = settings.value(QLatin1String("embedFonts"), true).toBool();
+    QSettings *settings = QCoreApplicationPrivate::staticConf();
+    embedFonts = settings->value(QLatin1String("Qt/embedFonts"), true).toBool();
 }
 
 QPSPrintEnginePrivate::~QPSPrintEnginePrivate()
index aaf0c0d..3eb5b13 100644 (file)
@@ -44,6 +44,7 @@
 #include "qscriptenginedebuggerfrontend_p.h"
 #include "qscriptdebuggerstandardwidgetfactory_p.h"
 #include "qobject_p.h"
+#include "qcoreapplication_p.h"
 
 #include <QtCore/qsettings.h>
 #include <QtGui/qapplication.h>
@@ -308,11 +309,11 @@ QScriptEngineDebuggerPrivate::~QScriptEngineDebuggerPrivate()
     delete frontend;
 #ifndef QT_NO_MAINWINDOW
     if (standardWindow) {
-        QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
+        QSettings *settings = QCoreApplicationPrivate::staticConf();
         QByteArray geometry = standardWindow->saveGeometry();
-        settings.setValue(QLatin1String("Qt/scripttools/debugging/mainWindowGeometry"), geometry);
+        settings->setValue(QLatin1String("Qt/scripttools/debugging/mainWindowGeometry"), geometry);
         QByteArray state = standardWindow->saveState();
-        settings.setValue(QLatin1String("Qt/scripttools/debugging/mainWindowState"), state);
+        settings->setValue(QLatin1String("Qt/scripttools/debugging/mainWindowState"), state);
         if (standardWindow->parent() == 0)
             delete standardWindow;
     }
@@ -595,11 +596,11 @@ QMainWindow *QScriptEngineDebugger::standardWindow() const
 
     win->setWindowTitle(tr("Katie Script Debugger"));
 
-    QSettings settings(QSettings::UserScope, QLatin1String("Katie"));
-    QVariant geometry = settings.value(QLatin1String("Qt/scripttools/debugging/mainWindowGeometry"));
+    QSettings *settings = QCoreApplicationPrivate::staticConf();
+    QVariant geometry = settings->value(QLatin1String("Qt/scripttools/debugging/mainWindowGeometry"));
     if (geometry.isValid())
         win->restoreGeometry(geometry.toByteArray());
-    QVariant state = settings.value(QLatin1String("Qt/scripttools/debugging/mainWindowState"));
+    QVariant state = settings->value(QLatin1String("Qt/scripttools/debugging/mainWindowState"));
     if (state.isValid())
         win->restoreState(state.toByteArray());
 
index 8e94ea0..17b0a3f 100644 (file)
@@ -216,10 +216,9 @@ MainWindow::MainWindow()
                                    Qt::ToolTipRole);
     ui->guiStyleCombo->addItems(gstyles);
 
-    QSettings settings(QLatin1String("Katie"));
-    settings.beginGroup(QLatin1String("Qt"));
+    QSettings settings(QLatin1String("Katie"), QSettings::NativeFormat);
 
-    QString currentstyle = settings.value(QLatin1String("style")).toString();
+    QString currentstyle = settings.value(QLatin1String("Qt/style")).toString();
     if (currentstyle.isEmpty()) {
         ui->guiStyleCombo->setCurrentIndex(ui->guiStyleCombo->findText(desktopThemeName));
         currentstyle = QApplication::style()->objectName();
@@ -348,16 +347,14 @@ MainWindow::MainWindow()
     ui->substitutionsListBox->clear();
     ui->substitutionsListBox->insertItems(0, subs);
 
-    ui->rtlExtensionsCheckBox->setChecked(settings.value(QLatin1String("useRtlExtensions"), false)
+    ui->rtlExtensionsCheckBox->setChecked(settings.value(QLatin1String("Qt/useRtlExtensions"), false)
                                           .toBool());
 
-    ui->fontEmbeddingCheckBox->setChecked(settings.value(QLatin1String("embedFonts"), true)
+    ui->fontEmbeddingCheckBox->setChecked(settings.value(QLatin1String("Qt/embedFonts"), true)
                                           .toBool());
-    fontpaths = settings.value(QLatin1String("fontPath")).toStringList();
+    fontpaths = settings.value(QLatin1String("Qt/fontPath")).toStringList();
     ui->fontpathListBox->insertItems(0, fontpaths);
 
-    settings.endGroup(); // Qt
-
     ui->helpView->setText(tr(appearance_text));
 
     setModified(false);
@@ -383,8 +380,7 @@ void MainWindow::fileSave()
     statusBar()->showMessage(tr("Saving changes..."));
 
     {
-        QSettings settings(QLatin1String("Katie"));
-        settings.beginGroup(QLatin1String("Qt"));
+        QSettings settings(QLatin1String("Katie"), QSettings::NativeFormat);
         QFontDatabase db;
         QFont font = db.font(ui->fontFamilyCombo->currentText(),
                              ui->fontStyleCombo->currentText(),
@@ -405,27 +401,27 @@ void MainWindow::fileSave()
                                            QPalette::ColorRole(i)).name();
         }
 
-        settings.setValue(QLatin1String("font"), font.toString());
-        settings.setValue(QLatin1String("Palette/active"), actcg);
-        settings.setValue(QLatin1String("Palette/inactive"), inactcg);
-        settings.setValue(QLatin1String("Palette/disabled"), discg);
+        settings.setValue(QLatin1String("Qt/font"), font.toString());
+        settings.setValue(QLatin1String("Qt/Palette/active"), actcg);
+        settings.setValue(QLatin1String("Qt/Palette/inactive"), inactcg);
+        settings.setValue(QLatin1String("Qt/Palette/disabled"), discg);
 
-        settings.setValue(QLatin1String("fontPath"), fontpaths);
-        settings.setValue(QLatin1String("embedFonts"), ui->fontEmbeddingCheckBox->isChecked());
-        settings.setValue(QLatin1String("style"),
+        settings.setValue(QLatin1String("Qt/fontPath"), fontpaths);
+        settings.setValue(QLatin1String("Qt/embedFonts"), ui->fontEmbeddingCheckBox->isChecked());
+        settings.setValue(QLatin1String("Qt/style"),
                           overrideDesktopSettings ? ui->guiStyleCombo->currentText() : QString());
 
-        settings.setValue(QLatin1String("doubleClickInterval"), ui->doubleClickIntervalSpinBox->value());
-        settings.setValue(QLatin1String("cursorFlashTime"),
+        settings.setValue(QLatin1String("Qt/doubleClickInterval"), ui->doubleClickIntervalSpinBox->value());
+        settings.setValue(QLatin1String("Qt/cursorFlashTime"),
                           ui->cursorFlashTimeSpinBox->value() == 9 ? 0 : ui->cursorFlashTimeSpinBox->value());
-        settings.setValue(QLatin1String("wheelScrollLines"), ui->wheelScrollLinesSpinBox->value());
-        settings.setValue(QLatin1String("resolveSymlinks"), ui->resolveLinksCheckBox->isChecked());
+        settings.setValue(QLatin1String("Qt/wheelScrollLines"), ui->wheelScrollLinesSpinBox->value());
+        settings.setValue(QLatin1String("Qt/resolveSymlinks"), ui->resolveLinksCheckBox->isChecked());
 
         QSize strut(ui->strutWidthSpinBox->value(), ui->strutHeightSpinBox->value());
-        settings.setValue(QLatin1String("globalStrut/width"), strut.width());
-        settings.setValue(QLatin1String("globalStrut/height"), strut.height());
+        settings.setValue(QLatin1String("Qt/globalStrut/width"), strut.width());
+        settings.setValue(QLatin1String("Qt/globalStrut/height"), strut.height());
 
-        settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensionsCheckBox->isChecked());
+        settings.setValue(QLatin1String("Qt/useRtlExtensions"), ui->rtlExtensionsCheckBox->isChecked());
 
         QStringList effects;
         if (ui->effectsCheckBox->isChecked()) {
@@ -450,18 +446,15 @@ void MainWindow::fileSave()
             }
         } else
             effects << QLatin1String("none");
-        settings.setValue(QLatin1String("GUIEffects"), effects);
+        settings.setValue(QLatin1String("Qt/GUIEffects"), effects);
 
         QStringList familysubs = QFont::substitutions();
         QStringList::Iterator fit = familysubs.begin();
-        settings.beginGroup(QLatin1String("Font Substitutions"));
         while (fit != familysubs.end()) {
             QStringList subs = QFont::substitutes(*fit);
-            settings.setValue(*fit, subs);
+            settings.setValue(QLatin1String("Qt/Font Substitutions/") + *fit, subs);
             fit++;
         }
-        settings.endGroup(); // Font Substitutions
-        settings.endGroup(); // Qt
     }
 
 #if defined(Q_WS_X11)
diff --git a/tests/auto/qsettings/.gitattributes b/tests/auto/qsettings/.gitattributes
deleted file mode 100644 (file)
index a4ad8d7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-resourcefile.ini  -crlf
-resourcefile2.ini -crlf
-resourcefile3.ini -crlf
-resourcefile4.ini -crlf
-resourcefile5.ini -crlf
index 32236da..6a63e1a 100644 (file)
@@ -1,5 +1,3 @@
 katie_gui_test(tst_qsettings
     ${CMAKE_CURRENT_SOURCE_DIR}/tst_qsettings.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/qsettings.qrc
 )
-
diff --git a/tests/auto/qsettings/qsettings.qrc b/tests/auto/qsettings/qsettings.qrc
deleted file mode 100644 (file)
index 587c22e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
-    <file>resourcefile.ini</file>
-    <file>resourcefile2.ini</file>
-    <file>resourcefile3.ini</file>
-    <file>resourcefile4.ini</file>
-    <file>resourcefile5.ini</file>
-</qresource>
-</RCC>
diff --git a/tests/auto/qsettings/resourcefile.ini b/tests/auto/qsettings/resourcefile.ini
deleted file mode 100644 (file)
index 608d1b7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-[Field%201]
-Bottom=89
-Flags=MULTILINE|VSCROLL|READONLY
-Left=4
-Right=296
-State=No license agreement file found. Please contact support.
-Top=14
-Type=Text
-
-[Field%202]
-Bottom=8
-Left=4
-Right=294
-Text=Press Page Down to see the rest of the agreement.
-Top=0
-Type=Label
-
-[Field%203]
-Bottom=111
-Left=4
-Right=297
-Text=If you accept the terms of the agreement, select the first option below. You must accept the agreement to install this software. Click Next to continue.
-Top=92
-Type=Label
-
-[Field%204]
-Bottom=129
-Flags=GROUP|NOTIFY
-Left=4
-Right=299
-Text=I &accept the terms in the License Agreement
-Top=120
-Type=RadioButton
-
-[Field%205]
-Bottom=140
-Flags=NOTIFY
-Left=4
-Right=300
-State=1
-Text=I &do not accept the terms in the License Agreement
-Top=129
-Type=RadioButton
-
-[Settings]
-NumFields=5
diff --git a/tests/auto/qsettings/resourcefile2.ini b/tests/auto/qsettings/resourcefile2.ini
deleted file mode 100644 (file)
index cd06b3b..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-[Field%202]
-Flags=MULTILINE|VSCROLL|READONLY
-Left=4
-Right=296
-State=No license agreement file found. Please contact support.
-Bottom=89
-Top=14
-Type=Text
-
-[Field%201]
-Left=4
-Text=Press Page Down to see the rest of the agreement.
-Bottom=8
-Top=0
-Right=294
-Type=Label
-
-[Field%203]
-Bottom=111
-Left=4
-Right=297
-Text=If you accept the terms of the agreement, select the first option below. You must accept the agreement to install this software. Click Next to continue.
-Top=92
-Type=Label
-
-[Field%204]
-Bottom=129
-Flags=GROUP|NOTIFY
-Left=4
-Right=299
-Text=I &accept the terms in the License Agreement
-Top=120
-Type=RadioButton
-
-[Field%205]
-Bottom=140
-Flags=NOTIFY
-Left=4
-Right=300
-State=1
-Text=I &do not accept the terms in the License Agreement
-Top=129
-Type=RadioButton
-
-[Settings]
-NumFields=5
diff --git a/tests/auto/qsettings/resourcefile3.ini b/tests/auto/qsettings/resourcefile3.ini
deleted file mode 100644 (file)
index ee54cfb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-[Field%202]
-Flags=MULTILINE|VSCROLL|READONLY
-Left=4
-Right=296
-State=No license agreement file found. Please contact support.
-Bottom=89
-Top=14
-Type=Text
-
-[Field%201]
-Left=4
-Text=Press Page Down to see the rest of the agreement.
-Bottom=90
-Top=0
-Right=294
-Type=Label
-x=1
-y=1
-width=1
-height=1
-
-[Field%203]
-Bottom=111
-Left=4
-Right=297
-Text=If you accept the terms of the agreement, select the first option below. You must accept the agreement to install this software. Click Next to continue.
-Top=92
-Type=Label
-
-[Field%204]
-Bottom=129
-Flags=GROUP|NOTIFY
-Left=4
-Right=299
-Text=I &accept the terms in the License Agreement
-Top=120
-Type=RadioButton
-
-[Field%205]
-Bottom=140
-Flags=NOTIFY
-Left=4
-Right=300
-State=1
-Text=I &do not accept the terms in the License Agreement
-Top=129
-Type=RadioButton
-
-[Settings]
-NumFields=5
diff --git a/tests/auto/qsettings/resourcefile4.ini b/tests/auto/qsettings/resourcefile4.ini
deleted file mode 100644 (file)
index 09c21b1..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-[Fa%E7ade]
-QU%C9BEC=Façade/QUÉBEC
diff --git a/tests/auto/qsettings/resourcefile5.ini b/tests/auto/qsettings/resourcefile5.ini
deleted file mode 100644 (file)
index d2d2103..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-[Fa%E7ade]
-QU%C9BEC=Façade/QUÉBEC
index 537599e..ad6e573 100644 (file)
 ****************************************************************************/
 
 
-#include <qdebug.h>
 #include <QtTest/QtTest>
+#include <QtCore/QtCore>
 
-#include <QSettings>
-#include <qsettings_p.h>
-//#include <QApplication>
-#include <QCoreApplication>
-#include <QMetaType>
-#include <QtDebug>
-#include <QString>
-#include <QColor>
-#include <QKeySequence>
-#include <QTemporaryFile>
-#include <QPixmap>
-#include <qdir.h>
-#include <qregexp.h>
-#include <qthread.h>
-#include "../../shared/util.h"
-
-#include <cctype>
-#include <stdlib.h>
-#include <unistd.h>
-
+//TESTED_CLASS=
 //TESTED_FILES=
 
+Q_DECLARE_METATYPE(QSettings::Format)
+
 class tst_QSettings : public QObject
 {
     Q_OBJECT
 
 public:
-    tst_QSettings();
+    QString m_nativename;
+    QString m_ininame;
 
 public slots:
+    void initTestCase();
+    void cleanupTestCase();
     void init();
     void cleanup();
+
 private slots:
-    void getSetCheck();
-    void ctor_data();
-    void ctor();
-    void beginGroup();
-    void setValue();
-    void remove();
-    void contains();
+    void value_data();
+    void value();
+    void sync_data();
     void sync();
-    void setFallbacksEnabled();
-    void setFallbacksEnabled_data();
-    void fromFile_data();
-    void fromFile();
-    void setIniCodec();
-    void testArrays_data();
-    void testArrays();
-    void testEscapes();
-    void testCaseSensitivity_data();
-    void testCaseSensitivity();
-    void testErrorHandling_data();
-    void testErrorHandling();
-    void testIniParsing_data();
-    void testIniParsing();
-    void testChildKeysAndGroups_data();
-    void testChildKeysAndGroups();
-    void testUpdateRequestEvent();
-    void testThreadSafety();
-    void testNormalizedKey_data();
-    void testNormalizedKey();
-    void testEmptyData();
-    void testResourceFiles();
-    void isWritable_data();
-    void isWritable();
-    void childGroups_data();
-    void childGroups();
-    void childKeys_data();
-    void childKeys();
-    void allKeys_data();
-    void allKeys();
-    void registerFormat();
-    void setPath();
-    void setDefaultFormat();
-    void dontCreateNeedlessPaths();
-    void dontReorderIniKeysNeedlessly();
-
-    void testVariantTypes_data();
-    void testVariantTypes();
-    void rainersSyncBugOnMac_data();
-    void rainersSyncBugOnMac();
-    void recursionBug();
-
-    void testByteArray_data();
-    void testByteArray();
-    void iniCodec();
-
-private:
-    void oldWriteEntry_data();
-    void oldReadEntry_data();
-    void oldWriteEntryHelper(QSettings &settings);
-    void oldReadEntryHelper(QSettings &settings);
+    void variant_data();
+    void variant();
 };
 
-// Testing get/set functions
-void tst_QSettings::getSetCheck()
-{
-    QSettings obj1;
-    // bool QSettings::fallbacksEnabled()
-    // void QSettings::setFallbacksEnabled(bool)
-    obj1.setFallbacksEnabled(false);
-    QCOMPARE(false, obj1.fallbacksEnabled());
-    obj1.setFallbacksEnabled(true);
-    QCOMPARE(true, obj1.fallbacksEnabled());
-}
-
-Q_DECLARE_METATYPE(QSettings::Format)
-
-static QString settingsPath(const char *path = "")
-{
-    // Temporary path for files that are specified explictly in the constructor.
-    QString tempPath = QDir::tempPath();
-    if (tempPath.endsWith("/"))
-       tempPath.truncate(tempPath.size() - 1);
-    return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path));
-}
-
-static bool readCustom1File(QIODevice &device, QSettings::SettingsMap &map)
-{
-    QDataStream in(&device);
-    quint32 magic;
-    in >> magic;
-    in >> map;
-    return (magic == 0x01010101 && in.status() == QDataStream::Ok);
-}
-
-static bool writeCustom1File(QIODevice &device, const QSettings::SettingsMap &map)
-{
-    QDataStream out(&device);
-    out << quint32(0x01010101);
-    out << map;
-    return out.status() == QDataStream::Ok;
-}
-
-static bool readCustom2File(QIODevice &device, QSettings::SettingsMap &map)
-{
-    QDataStream in(&device);
-    quint64 magic;
-    in >> magic;
-    in >> map;
-    return (magic == Q_UINT64_C(0x0202020202020202) && in.status() == QDataStream::Ok);
-}
-
-static bool writeCustom2File(QIODevice &device, const QSettings::SettingsMap &map)
-{
-    QDataStream out(&device);
-    out << Q_UINT64_C(0x0202020202020202);
-    out << map;
-    return out.status() == QDataStream::Ok;
-}
-
-static bool readCustom3File(QIODevice &device, QSettings::SettingsMap &map)
-{
-    QTextStream in(&device);
-    QString tag;
-    in >> tag;
-    if (tag == "OK") {
-        map.insert("retval", "OK");
-        return true;
-    } else {
-        return false;
-    }
-}
-
-static bool writeCustom3File(QIODevice &device, const QSettings::SettingsMap &map)
-{
-    QTextStream out(&device);
-    if (map.value("retval") != "OK")
-        return false;
-
-    out << "OK";
-    return true;
-}
-
-static void populateWithFormats()
+void tst_QSettings::initTestCase()
 {
-    QTest::addColumn<QSettings::Format>("format");
-
-    QTest::newRow("native") << QSettings::NativeFormat;
-    QTest::newRow("ini") << QSettings::IniFormat;
-    QTest::newRow("custom1") << QSettings::CustomFormat1;
-    QTest::newRow("custom2") << QSettings::CustomFormat2;
+    const QString filename = QDir::tempPath() + QLatin1String("/tst_qsettings_")
+        + QString::number(qrand());
+    m_nativename = filename + QLatin1String(".json");
+    m_ininame = filename + QLatin1String(".ini");
 }
 
-tst_QSettings::tst_QSettings()
+void tst_QSettings::cleanupTestCase()
 {
-    QSettings::Format custom1 = QSettings::registerFormat("custom1", readCustom1File, writeCustom1File);
-    QSettings::Format custom2 = QSettings::registerFormat("custom2", readCustom2File, writeCustom2File
-#ifndef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
-                                                          , Qt::CaseInsensitive
-#endif
-                                                          );
-    QVERIFY(custom1 == QSettings::CustomFormat1);
-    QVERIFY(custom2 == QSettings::CustomFormat2);
+    QFile::remove(m_nativename);
+    QFile::remove(m_ininame);
 }
 
 void tst_QSettings::init()
 {
-    QSettings::setSystemIniPath(settingsPath("__system__"));
-    QSettings::setUserIniPath(settingsPath("__user__"));
-
-    system(QString("chmod -R u+rw %1 2> /dev/null").arg(settingsPath()).toLatin1());
-    system(QString("rm -fr %1 2> /dev/null").arg(settingsPath()).toLatin1());
-
-    QFile::remove("foo");
 }
 
 void tst_QSettings::cleanup()
 {
-    init();
-}
-
-/*
-    Test the constructors and the assignment operator.
-*/
-
-void tst_QSettings::ctor_data()
-{
-    populateWithFormats();
-}
-
-void tst_QSettings::ctor()
-{
-    QFETCH(QSettings::Format, format);
-
-    {
-        QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QSettings settings2(format, QSettings::UserScope, "software.org");
-        QSettings settings3(format, QSettings::SystemScope, "software.org", "KillerAPP");
-        QSettings settings4(format, QSettings::SystemScope, "software.org");
-
-        QSettings settings5(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QSettings settings6(format, QSettings::UserScope, "software.org");
-        QSettings settings7(format, QSettings::SystemScope, "software.org", "KillerAPP");
-        QSettings settings8(format, QSettings::SystemScope, "software.org");
-
-        // test QSettings::format() while we're at it
-        QVERIFY(settings1.format() == format);
-        QVERIFY(settings2.format() == format);
-        QVERIFY(settings3.format() == format);
-        QVERIFY(settings4.format() == format);
-
-        // test QSettings::scope() while we're at it
-        QVERIFY(settings1.scope() == QSettings::UserScope);
-        QVERIFY(settings2.scope() == QSettings::UserScope);
-        QVERIFY(settings3.scope() == QSettings::SystemScope);
-        QVERIFY(settings4.scope() == QSettings::SystemScope);
-
-        // test QSettings::organizationName() while we're at it
-        QVERIFY(settings1.organizationName() == "software.org");
-        QVERIFY(settings2.organizationName() == "software.org");
-        QVERIFY(settings3.organizationName() == "software.org");
-        QVERIFY(settings4.organizationName() == "software.org");
-
-        // test QSettings::applicationName() while we're at it
-        QCOMPARE(settings1.applicationName(), QString("KillerAPP"));
-        QVERIFY(settings2.applicationName().isEmpty());
-        QVERIFY(settings3.applicationName() == "KillerAPP");
-        QVERIFY(settings4.applicationName().isEmpty());
-
-        /*
-            Go forwards.
-        */
-        settings4.setValue("key 1", QString("doodah"));
-        QCOMPARE(settings1.value("key 1").toString(), QString("doodah"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("doodah"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-        settings3.setValue("key 1", QString("blah"));
-        QCOMPARE(settings1.value("key 1").toString(), QString("blah"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-        settings2.setValue("key 1", QString("whoa"));
-        QCOMPARE(settings1.value("key 1").toString(), QString("whoa"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-        settings1.setValue("key 1", QString("gurgle"));
-        QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-        /*
-            Test the copies.
-        */
-        QCOMPARE(settings5.value("key 1").toString(), settings1.value("key 1").toString());
-        QCOMPARE(settings6.value("key 1").toString(), settings2.value("key 1").toString());
-        QCOMPARE(settings7.value("key 1").toString(), settings3.value("key 1").toString());
-        QCOMPARE(settings8.value("key 1").toString(), settings4.value("key 1").toString());
-
-        /*
-            Go backwards.
-        */
-
-        settings2.setValue("key 1", QString("bilboh"));
-        QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("bilboh"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-        settings3.setValue("key 1", QString("catha"));
-        QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("bilboh"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("catha"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-        settings4.setValue("key 1", QString("quirko"));
-        QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("bilboh"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("catha"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("quirko"));
-
-        /*
-            Test the copies again.
-        */
-        QCOMPARE(settings5.value("key 1").toString(), settings1.value("key 1").toString());
-        QCOMPARE(settings6.value("key 1").toString(), settings2.value("key 1").toString());
-        QCOMPARE(settings7.value("key 1").toString(), settings3.value("key 1").toString());
-        QCOMPARE(settings8.value("key 1").toString(), settings4.value("key 1").toString());
-
-        /*
-            "General" is a problem key for .ini files.
-        */
-        settings1.setValue("General", 1);
-        settings1.setValue("%General", 2);
-        settings1.setValue("alpha", 3);
-        settings1.setValue("General/alpha", 4);
-        settings1.setValue("%General/alpha", 5);
-        settings1.setValue("alpha/General", 6);
-        settings1.setValue("alpha/%General", 7);
-        settings1.setValue("General/General", 8);
-        settings1.setValue("General/%General", 9);
-        settings1.setValue("%General/General", 10);
-        settings1.setValue("%General/%General", 11);
-    }
-
-    {
-        /*
-            Test that the data was stored on disk after all instances
-            of QSettings are destroyed.
-        */
-
-        QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QSettings settings2(format, QSettings::UserScope, "software.org");
-        QSettings settings3(format, QSettings::SystemScope, "software.org", "KillerAPP");
-        QSettings settings4(format, QSettings::SystemScope, "software.org");
-
-        QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
-        QCOMPARE(settings2.value("key 1").toString(), QString("bilboh"));
-        QCOMPARE(settings3.value("key 1").toString(), QString("catha"));
-        QCOMPARE(settings4.value("key 1").toString(), QString("quirko"));
-
-        /*
-            Test problem keys.
-        */
-
-        QCOMPARE(settings1.value("General").toInt(), 1);
-        QCOMPARE(settings1.value("%General").toInt(), 2);
-        QCOMPARE(settings1.value("alpha").toInt(), 3);
-        QCOMPARE(settings1.value("General/alpha").toInt(), 4);
-        QCOMPARE(settings1.value("%General/alpha").toInt(), 5);
-        QCOMPARE(settings1.value("alpha/General").toInt(), 6);
-        QCOMPARE(settings1.value("alpha/%General").toInt(), 7);
-        QCOMPARE(settings1.value("General/General").toInt(), 8);
-        QCOMPARE(settings1.value("General/%General").toInt(), 9);
-        QCOMPARE(settings1.value("%General/General").toInt(), 10);
-        QCOMPARE(settings1.value("%General/%General").toInt(), 11);
-
-        /*
-            Test that the organization and product parameters is
-            case-insensitive on Windows and Mac, case-sensitive on
-            Unix.
-        */
-        QSettings settings5(format, QSettings::UserScope, "SoftWare.ORG", "killerApp");
-        QVERIFY(!settings5.contains("key 1"));
-    }
-
-    {
-        QSettings settings1(settingsPath("custom/custom.conf"), QSettings::IniFormat);
-        settings1.beginGroup("alpha/beta");
-        settings1.setValue("geometry", -7);
-        settings1.setValue("geometry/x", 1);
-        settings1.setValue("geometry/y", 2);
-        QSettings settings2(settingsPath("custom/custom.conf"), QSettings::IniFormat);
-        settings1.setValue("geometry/width", 3);
-        settings2.setValue("alpha/beta/geometry/height", 4);
-        settings2.setValue("alpha/gamma/splitter", 5);
-        settings1.endGroup();
-
-        // test QSettings::scope() while we're at it
-        QVERIFY(settings1.scope() == QSettings::UserScope);
-
-        // test QSettings::organizationName() while we're at it
-        QVERIFY(settings1.organizationName().isEmpty());
-
-        // test QSettings::applicationName() while we're at it
-        QVERIFY(settings1.organizationName().isEmpty());
-
-        QSettings settings3(settingsPath("custom/custom2.conf"), QSettings::IniFormat);
-        settings3.beginGroup("doodley/beta");
-        settings3.setValue("geometry", -7);
-        settings3.setValue("geometry/x", 1);
-        settings3.setValue("geometry/y", 2);
-        settings3.setValue("geometry/width", 3);
-        settings3.setValue("geometry/height", 4);
-        settings3.endGroup();
-        settings3.setValue("alpha/gamma/splitter", 5);
-
-        QCOMPARE(settings1.value("alpha/beta/geometry").toInt(), -7);
-        QCOMPARE(settings1.value("alpha/beta/geometry/x").toInt(), 1);
-        QCOMPARE(settings1.value("alpha/beta/geometry/y").toInt(), 2);
-        QCOMPARE(settings1.value("alpha/beta/geometry/width").toInt(), 3);
-        QCOMPARE(settings1.value("alpha/beta/geometry/height").toInt(), 4);
-        QCOMPARE(settings1.value("alpha/gamma/splitter").toInt(), 5);
-        QCOMPARE(settings1.allKeys().count(), 6);
-
-        QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), -7);
-        QCOMPARE(settings2.value("alpha/beta/geometry/x").toInt(), 1);
-        QCOMPARE(settings2.value("alpha/beta/geometry/y").toInt(), 2);
-        QCOMPARE(settings2.value("alpha/beta/geometry/width").toInt(), 3);
-        QCOMPARE(settings2.value("alpha/beta/geometry/height").toInt(), 4);
-        QCOMPARE(settings2.value("alpha/gamma/splitter").toInt(), 5);
-        QCOMPARE(settings2.allKeys().count(), 6);
-    }
-
-    {
-        QSettings settings1(settingsPath("custom/custom.conf"), QSettings::IniFormat);
-        QCOMPARE(settings1.value("alpha/beta/geometry").toInt(), -7);
-        QCOMPARE(settings1.value("alpha/beta/geometry/x").toInt(), 1);
-        QCOMPARE(settings1.value("alpha/beta/geometry/y").toInt(), 2);
-        QCOMPARE(settings1.value("alpha/beta/geometry/width").toInt(), 3);
-        QCOMPARE(settings1.value("alpha/beta/geometry/height").toInt(), 4);
-        QCOMPARE(settings1.value("alpha/gamma/splitter").toInt(), 5);
-        QCOMPARE(settings1.allKeys().count(), 6);
-    }
-
-    {
-        // QSettings's default constructor is native by default
-        if (format == QSettings::NativeFormat) {
-            QCoreApplication::instance()->setOrganizationName("");
-            QCoreApplication::instance()->setApplicationName("");
-            QSettings settings;
-            QCOMPARE(settings.status(), QSettings::AccessError);
-            QCoreApplication::instance()->setOrganizationName("software.org");
-            QCoreApplication::instance()->setApplicationName("KillerAPP");
-            QSettings settings2;
-            QCOMPARE(settings2.status(), QSettings::NoError);
-            QSettings settings3("software.org", "KillerAPP");
-            QCOMPARE(settings2.fileName(), settings3.fileName());
-            QCoreApplication::instance()->setOrganizationName("");
-            QCoreApplication::instance()->setApplicationName("");
-        }
-
-        QSettings settings(format, QSettings::UserScope, "", "");
-        QCOMPARE(settings.status(), QSettings::AccessError);
-        QSettings settings2(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QCOMPARE(settings2.status(), QSettings::NoError);
-
-        // test QSettings::format() while we're at it
-        QVERIFY(settings.format() == format);
-        QVERIFY(settings2.format() == format);
-
-        // test QSettings::scope() while we're at it
-        QVERIFY(settings.scope() == QSettings::UserScope);
-        QVERIFY(settings2.scope() == QSettings::UserScope);
-
-        // test QSettings::organizationName() while we're at it
-        QVERIFY(settings.organizationName().isEmpty());
-        QVERIFY(settings2.organizationName() == "software.org");
-
-        // test QSettings::applicationName() while we're at it
-        QVERIFY(settings.applicationName().isEmpty());
-        QVERIFY(settings2.applicationName() == "KillerAPP");
-    }
-}
-
-void tst_QSettings::testByteArray_data()
-{
-    QTest::addColumn<QByteArray>("data");
-
-    QByteArray bytes("Hello world!");
-
-    QTest::newRow("latin1") << bytes;
-    QTest::newRow("compressed") << qCompress(bytes);
-    QTest::newRow("with \\0") << bytes + '\0' + bytes;
-}
-
-void tst_QSettings::testByteArray()
-{
-    QFETCH(QByteArray, data);
-
-    // write
-    {
-        QSettings settings("Trolltech", "tst_qsettings");
-        settings.setValue("byteArray", data);
-    }
-    // read
-    {
-        QSettings settings("Trolltech", "tst_qsettings");
-        QByteArray ret = settings.value("byteArray", data).toByteArray();
-        QCOMPARE(ret, data);
-    }
-}
-
-void tst_QSettings::iniCodec()
-{
-    {
-        QSettings settings("QtProject", "tst_qsettings");
-        settings.setIniCodec("cp1251");
-        QByteArray ba;
-        ba.resize(256);
-        for (int i = 0; i < ba.size(); i++)
-            ba[i] = i;
-        settings.setValue("array",ba);
-    }
-    {
-        QSettings settings("QtProject", "tst_qsettings");
-        settings.setIniCodec("cp1251");
-        QByteArray ba = settings.value("array").toByteArray();
-        QCOMPARE(ba.size(), 256);
-        for (int i = 0; i < ba.size(); i++)
-            QCOMPARE((uchar)ba.at(i), (uchar)i);
-    }
-
-}
-
-void tst_QSettings::testErrorHandling_data()
-{
-    QTest::addColumn<int>("filePerms"); // -1 means file should not exist
-    QTest::addColumn<int>("dirPerms");
-    QTest::addColumn<int>("statusAfterCtor");
-    QTest::addColumn<bool>("shouldBeEmpty");
-    QTest::addColumn<int>("statusAfterGet");
-    QTest::addColumn<int>("statusAfterSetAndSync");
-
-    //                         file    dir     afterCtor                      empty     afterGet                      afterSetAndSync
-    QTest::newRow("0600 0700") << 0600 << 0700 << (int)QSettings::NoError     << false << (int)QSettings::NoError     << (int)QSettings::NoError;
-
-    QTest::newRow("0400 0700") << 0400 << 0700 << (int)QSettings::NoError
-        << false << (int)QSettings::NoError     << (int)QSettings::AccessError;
-    QTest::newRow("0200 0700") << 0200 << 0700 << (int)QSettings::AccessError
-        << true  << (int)QSettings::AccessError << (int)QSettings::AccessError;
-
-    QTest::newRow("  -1 0700") <<   -1 << 0700 << (int)QSettings::NoError     << true  << (int)QSettings::NoError     << (int)QSettings::NoError;
-
-    QTest::newRow("  -1 0000") <<   -1 << 0000 << (int)QSettings::NoError     << true  << (int)QSettings::NoError     << (int)QSettings::AccessError;
-    QTest::newRow("  -1 0100") <<   -1 << 0100 << (int)QSettings::NoError     << true  << (int)QSettings::NoError     << (int)QSettings::AccessError;
-    QTest::newRow("0600 0100") << 0600 << 0100 << (int)QSettings::NoError     << false << (int)QSettings::NoError     << (int)QSettings::NoError;
-    QTest::newRow("  -1 0300") <<   -1 << 0300 << (int)QSettings::NoError     << true  << (int)QSettings::NoError     << (int)QSettings::NoError;
-    QTest::newRow("0600 0300") << 0600 << 0300 << (int)QSettings::NoError     << false << (int)QSettings::NoError     << (int)QSettings::NoError;
-    QTest::newRow("  -1 0500") <<   -1 << 0500 << (int)QSettings::NoError     << true  << (int)QSettings::NoError     << (int)QSettings::AccessError;
-    QTest::newRow("0600 0500") << 0600 << 0500 << (int)QSettings::NoError     << false << (int)QSettings::NoError     << (int)QSettings::NoError;
-}
-
-void tst_QSettings::testErrorHandling()
-{
-#if defined(Q_OS_UNIX)
-    if (::getuid() == 0)
-        QSKIP("Running this test as root doesn't work, since file perms do not bother him", SkipAll);
-#else
-    QFETCH(int, filePerms);
-    QFETCH(int, dirPerms);
-    QFETCH(int, statusAfterCtor);
-    QFETCH(bool, shouldBeEmpty);
-    QFETCH(int, statusAfterGet);
-    QFETCH(int, statusAfterSetAndSync);
-
-    system(QString("chmod 700 %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1());
-    system(QString("chmod -R u+rwx %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1());
-    system(QString("rm -fr %1").arg(settingsPath("someDir")).toLatin1());
-
-    // prepare a file with some settings
-    if (filePerms != -1) {
-        QSettings settings(settingsPath("someDir/someSettings.ini"), QSettings::IniFormat);
-        QCOMPARE((int) settings.status(), (int) QSettings::NoError);
-
-        settings.beginGroup("alpha/beta");
-        settings.setValue("geometry", -7);
-        settings.setValue("geometry/x", 1);
-        settings.setValue("geometry/y", 2);
-        settings.setValue("geometry/width", 3);
-        settings.setValue("geometry/height", 4);
-        settings.endGroup();
-        settings.setValue("alpha/gamma/splitter", 5);
-    } else {
-        system(QString("mkdir -p %1").arg(settingsPath("someDir")).toLatin1());
-    }
-
-    if (filePerms != -1) {
-        system(QString("chmod %1 %2")
-                    .arg(QString::number(filePerms, 8))
-                    .arg(settingsPath("someDir/someSettings.ini"))
-                    .toLatin1());
-    }
-    system(QString("chmod %1 %2")
-                .arg(QString::number(dirPerms, 8))
-                .arg(settingsPath("someDir"))
-                .toLatin1());
-
-    // the test
-    {
-        QConfFile::clearCache();
-        QSettings settings(settingsPath("someDir/someSettings.ini"), QSettings::IniFormat);
-        QCOMPARE((int)settings.status(), statusAfterCtor);
-        if (shouldBeEmpty) {
-            QCOMPARE(settings.allKeys().count(), 0);
-        } else {
-            QVERIFY(settings.allKeys().count() > 0);
-        }
-        settings.value("alpha/beta/geometry");
-        QCOMPARE((int)settings.status(), statusAfterGet);
-        settings.setValue("alpha/beta/geometry", 100);
-        QCOMPARE((int)settings.status(), statusAfterGet);
-        QCOMPARE(settings.value("alpha/beta/geometry").toInt(), 100);
-        settings.sync();
-        QCOMPARE(settings.value("alpha/beta/geometry").toInt(), 100);
-        QCOMPARE((int)settings.status(), statusAfterSetAndSync);
-    }
-#endif // Q_OS_UNIX
-}
-
-Q_DECLARE_METATYPE(QVariant)
-Q_DECLARE_METATYPE(QSettings::SettingsStatus)
-
-void tst_QSettings::testIniParsing_data()
-{
-    QTest::addColumn<QByteArray>("inicontent");
-    QTest::addColumn<QString>("key");
-    QTest::addColumn<QVariant>("expect");
-    QTest::addColumn<QSettings::SettingsStatus>("status");
-
-    // Test "forgiving" parsing of entries not terminated with newline or unterminated strings
-    QTest::newRow("good1")    << QByteArray("v=1\n")          << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("good2")    << QByteArray("v=1\\\n2")       << "v" << QVariant(12) << QSettings::NoError;
-    QTest::newRow("good3")    << QByteArray("v=1\\\r2")       << "v" << QVariant(12) << QSettings::NoError;
-    QTest::newRow("good4")    << QByteArray("v=1\\\n\r2")     << "v" << QVariant(12) << QSettings::NoError;
-    QTest::newRow("good5")    << QByteArray("v=1\\\r\n2")     << "v" << QVariant(12) << QSettings::NoError;
-    QTest::newRow("good6")    << QByteArray("v  \t = \t 1\\\r\n2")     << "v" << QVariant(12) << QSettings::NoError;
-    QTest::newRow("garbage1") << QByteArray("v")              << "v" << QVariant() << QSettings::FormatError;
-    QTest::newRow("nonterm1") << QByteArray("v=str")          << "v" << QVariant("str") << QSettings::NoError;
-    QTest::newRow("nonterm2") << QByteArray("v=\"str\"")      << "v" << QVariant("str") << QSettings::NoError;
-    QTest::newRow("nonterm3") << QByteArray("v=\"str")        << "v" << QVariant("str") << QSettings::NoError;
-    QTest::newRow("nonterm4") << QByteArray("v=\\")           << "v" << QVariant("") << QSettings::NoError;
-    QTest::newRow("nonterm5") << QByteArray("u=s\nv=\"str")   << "v" << QVariant("str") << QSettings::NoError;
-    QTest::newRow("nonterm6") << QByteArray("v=\"str\nw=ok")  << "v" << QVariant("str\nw=ok") << QSettings::NoError;
-    QTest::newRow("nonterm7") << QByteArray("v=")             << "v" << QVariant("") << QSettings::NoError;
-    QTest::newRow("nonterm8") << QByteArray("v=\"str\njnk")   << "v" << QVariant("str\njnk") << QSettings::NoError;
-    QTest::newRow("nonterm9") << QByteArray("v=1\\")          << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm10") << QByteArray("v=1\\\n")       << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm11") << QByteArray("v=1\\\r")       << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm12") << QByteArray("v=1\\\n\r")     << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm13") << QByteArray("v=1\\\r\n")     << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm14") << QByteArray("v=1\\\n\nx=2")  << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm15") << QByteArray("v=1\\\r\rx=2")  << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm16") << QByteArray("v=1\\\n\n\nx=2") << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm17") << QByteArray("; foo\nv=1") << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm18") << QByteArray("; foo\n\nv=1") << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm19") << QByteArray("\nv=1;foo") << "v" << QVariant(1) << QSettings::NoError;
-    QTest::newRow("nonterm20") << QByteArray("v=x ") << "v" << QVariant("x") << QSettings::NoError;
-    QTest::newRow("nonterm21") << QByteArray("v=x ;") << "v" << QVariant("x") << QSettings::NoError;
-}
-
-void tst_QSettings::testIniParsing()
-{
-#ifdef QT_BUILD_INTERNAL
-    qRegisterMetaType<QVariant>("QVariant");
-    qRegisterMetaType<QSettings::SettingsStatus>("QSettings::SettingsStatus");
-
-    QDir dir(settingsPath());
-    QVERIFY(dir.mkpath("someDir"));
-    QFile f(dir.path()+"/someDir/someSettings.ini");
-
-    QFETCH(QByteArray, inicontent);
-    QFETCH(QString, key);
-    QFETCH(QVariant, expect);
-    QFETCH(QSettings::SettingsStatus, status);
-
-    QVERIFY(f.open(QFile::WriteOnly));
-    f.write(inicontent);
-    f.close();
-
-    QConfFile::clearCache();
-    QSettings settings(settingsPath("someDir/someSettings.ini"), QSettings::IniFormat);
-
-    if ( settings.status() == QSettings::NoError ) { // else no point proceeding
-       QVariant v = settings.value(key);
-       QVERIFY(v.canConvert(expect.type()));
-       // check some types so as to give prettier error messages
-       if ( v.type() == QVariant::String ) {
-           QCOMPARE(v.toString(), expect.toString());
-       } else if ( v.type() == QVariant::Int ) {
-           QCOMPARE(v.toInt(), expect.toInt());
-       } else {
-           QCOMPARE(v, expect);
-       }
-    }
-
-    QCOMPARE(settings.status(), status);
-#endif
-}
-
-/*
-    Tests beginGroup(), endGroup(), and group().
-*/
-void tst_QSettings::beginGroup()
-{
-    QSettings settings1(QSettings::UserScope, "software.org", "KillerAPP");
-    QSettings settings2(QSettings::UserScope, "software.org", "KillerAPP");
-
-    /*
-      Let's start with some back and forthing.
-    */
-
-    settings1.beginGroup("alpha");
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString());
-    settings1.beginGroup("/beta");
-    QCOMPARE(settings1.group(), QString("beta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString());
-
-    settings1.beginGroup("///gamma//");
-    QCOMPARE(settings1.group(), QString("gamma"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString());
-
-    settings1.setValue("geometry", 5);
-    QCOMPARE(settings1.value("geometry").toInt(), 5);
-    QCOMPARE(settings1.value("/geometry///").toInt(), 5);
-    QCOMPARE(settings2.value("geometry").toInt(), 5);
-    QCOMPARE(settings2.value("/geometry///").toInt(), 5);
-
-    /*
-      OK, now start for real.
-    */
-
-    settings1.beginGroup("alpha");
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.setValue("geometry", 66);
-    QCOMPARE(settings1.value("geometry").toInt(), 66);
-    QCOMPARE(settings2.value("geometry").toInt(), 5);
-    QCOMPARE(settings2.value("alpha/geometry").toInt(), 66);
-
-    QSettings settings3(QSettings::UserScope, "software.org", "KillerAPP");
-    settings3.beginGroup("alpha");
-    QCOMPARE(settings3.value("geometry").toInt(), 66);
-
-    settings1.beginGroup("/beta///");
-    QCOMPARE(settings1.group(), QString("alpha/beta"));
-    settings1.setValue("geometry", 777);
-    QCOMPARE(settings1.value("geometry").toInt(), 777);
-    QCOMPARE(settings2.value("geometry").toInt(), 5);
-    QCOMPARE(settings2.value("alpha/geometry").toInt(), 66);
-    QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), 777);
-    QCOMPARE(settings3.value("geometry").toInt(), 66);
-    QCOMPARE(settings3.value("beta/geometry").toInt(), 777);
-
-    settings3.beginGroup("gamma");
-    settings3.setValue("geometry", 8888);
-    QCOMPARE(settings3.value("geometry").toInt(), 8888);
-    QCOMPARE(settings2.value("geometry").toInt(), 5);
-    QCOMPARE(settings2.value("alpha/geometry").toInt(), 66);
-    QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), 777);
-    QCOMPARE(settings2.value("alpha/gamma/geometry").toInt(), 8888);
-    QCOMPARE(settings1.value("geometry").toInt(), 777);
-
-    // endGroup() should do nothing if group() is empty
-    for (int i = 0; i < 10; ++i)
-        settings2.endGroup();
-    QCOMPARE(settings2.value("geometry").toInt(), 5);
-    QCOMPARE(settings2.value("alpha/geometry").toInt(), 66);
-    QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), 777);
-    QCOMPARE(settings2.value("alpha/gamma/geometry").toInt(), 8888);
-
-    QCOMPARE(settings1.group(), QString("alpha/beta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString());
-    QCOMPARE(settings1.value("geometry").toInt(), 5);
-    QCOMPARE(settings1.value("alpha/geometry").toInt(), 66);
-    QCOMPARE(settings1.value("alpha/beta/geometry").toInt(), 777);
-    QCOMPARE(settings1.value("alpha/gamma/geometry").toInt(), 8888);
-
-    settings1.beginGroup("delta");
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.beginGroup("");
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.beginGroup("/");
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.beginGroup("////");
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.beginGroup("////omega///epsilon zeta eta  theta/ / /");
-    QCOMPARE(settings1.group(), QString("delta/omega/epsilon zeta eta  theta/ / "));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("delta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString());
 }
 
-/*
-    Tests setValue() and getXxx().
-*/
-void tst_QSettings::setValue()
+void tst_QSettings::value_data()
 {
-    QSettings settings(QSettings::UserScope, "software.org", "KillerAPP");
-
-    settings.setValue("key 2", (int)0x7fffffff);
-    QCOMPARE(settings.value("key 2").toInt(), (int)0x7fffffff);
-    QCOMPARE(settings.value("key 2").toString(), QString::number((int)0x7fffffff));
-    settings.setValue("key 2", -1);
-    QCOMPARE(settings.value("key 2").toInt(), -1);
-    QCOMPARE(settings.value("key 2").toString(), QString("-1"));
-    settings.setValue("key 2", (int)0x80000000);
-    QCOMPARE(settings.value("key 2").toInt(), (int)0x80000000);
-    settings.setValue("key 2", (int)0);
-    QCOMPARE(settings.value("key 2", 123).toInt(), (int)0);
-    settings.setValue("key 2", (int)12345);
-    QCOMPARE(settings.value("key 2").toInt(), (int)12345);
-    QCOMPARE(settings.value("no such key", 1234).toInt(), (int)1234);
-    QCOMPARE(settings.value("no such key").toInt(), (int)0);
-
-    settings.setValue("key 2", true);
-    QCOMPARE(settings.value("key 2").toBool(), true);
-    settings.setValue("key 2", false);
-    QCOMPARE(settings.value("key 2", true).toBool(), false);
-    settings.setValue("key 2", (int)1);
-    QCOMPARE(settings.value("key 2").toBool(), true);
-    settings.setValue("key 2", (int)-1);
-    QCOMPARE(settings.value("key 2").toBool(), true);
-    settings.setValue("key 2", (int)0);
-    QCOMPARE(settings.value("key 2", true).toBool(), false);
-    settings.setValue("key 2", QString("true"));
-    QCOMPARE(settings.value("key 2").toBool(), true);
-    settings.setValue("key 2", QString("false"));
-    QCOMPARE(settings.value("key 2", true).toBool(), false);
-/*
-    settings.setValue("key 2", "true");
-    QCOMPARE(settings.value("key 2").toBool(), true);
-    settings.setValue("key 2", "false");
-    QCOMPARE(settings.value("key 2", true).toBool(), false);
-    settings.setValue("key 2", "");
-    QCOMPARE(settings.value("key 2", true).toBool(), true);
-    settings.setValue("key 2", "");
-    QCOMPARE(settings.value("key 2", false).toBool(), false);
-    settings.setValue("key 2", "0.000e-00"); // cannot convert double to a bool
-    QCOMPARE(settings.value("key 2", true).toBool(), true);
-    settings.setValue("key 2", "0.000e-00");
-    QCOMPARE(settings.value("key 2", false).toBool(), false);
-
-*/
-    settings.setValue("key 2", QStringList());
-    QCOMPARE(settings.value("key 2").toStringList(), QStringList());
-    settings.setValue("key 2", QStringList(""));
-    QCOMPARE(settings.value("key 2").toStringList(), QStringList(""));
-    settings.setValue("key 2", QStringList() << "" << "");
-    QCOMPARE(settings.value("key 2").toStringList(), QStringList() << "" << "");
-    settings.setValue("key 2", QStringList() << "" << "a" << "" << "bc" << "");
-    QCOMPARE(settings.value("key 2").toStringList(), QStringList() << "" << "a" << "" << "bc" << "");
-
-    settings.setValue("key 3", QList<QVariant>());
-    QCOMPARE(settings.value("key 3").toList(), QList<QVariant>());
-    settings.setValue("key 3", QList<QVariant>() << 1 << QString("a"));
-    QCOMPARE(settings.value("key 3").toList(), QList<QVariant>() << 1 << QString("a"));
-
-    QList<QVariant> outerList;
-    outerList << 1 << QString("b");
-    QList<QVariant> innerList = outerList;
-    outerList.append(QVariant(innerList));
-    outerList.append(QVariant(innerList));
-    outerList << 2 << QString("c");
-    innerList = outerList;
-    outerList.append(QVariant(innerList));
-    // outerList: [1, "b", [1, "b"], [1, "b"], 2, "c", [1, "b", [1, "b"], [1, "b"], 2, "c"]]
-
-    settings.setValue("key 3", outerList);
-    QCOMPARE(settings.value("key 3").toList(), outerList);
-    QCOMPARE(settings.value("key 3").toList().size(), 7);
-
-    QMap<QString, QVariant> map;
-    map.insert("1", "one");
-    map.insert("2", "two");
-    map.insert("3", outerList);
-    map.insert("5", "cinco");
-    map.insert("10", "zehn");
-    settings.setValue("key 4", map);
-    QCOMPARE(settings.value("key 4").toMap(), map);
-}
+    QTest::addColumn<QString>("filename");
+    QTest::addColumn<QSettings::Format>("format");
 
-void tst_QSettings::testVariantTypes_data()
-{
-    populateWithFormats();
+    QTest::newRow("native") << m_nativename << QSettings::NativeFormat;
+    QTest::newRow("ini") << m_ininame << QSettings::IniFormat;
 }
 
-void tst_QSettings::testVariantTypes()
+void tst_QSettings::value()
 {
-#ifdef QT_BUILD_INTERNAL
-#define testVal(key, val, tp, rtype) \
-    { \
-        QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \
-        settings1.setValue(key, qVariantFromValue(val)); \
-    } \
-    QConfFile::clearCache(); \
-    { \
-        QSettings settings2(format, QSettings::UserScope, "software.org", "KillerAPP"); \
-        QVariant v = settings2.value(key); \
-        QVERIFY(qvariant_cast<tp >(v) == val); \
-        QVERIFY(v.type() == QVariant::rtype); \
-    }
-
-    typedef QMap<QString, QVariant> TestVariantMap;
-
+    QFETCH(QString, filename);
     QFETCH(QSettings::Format, format);
 
-    TestVariantMap m2;
-    m2.insert("ene", "due");
-    m2.insert("rike", "fake");
-    m2.insert("borba", "dorba");
-    testVal("key2", m2, TestVariantMap, Map);
-
-    QStringList l2;
-
-    l2 << "ene" << "due" << "@Point(1 2)" << "@fake";
-    testVal("key3", l2, QStringList, StringList);
-
-    l2.clear();
-    l2 << "ene" << "due" << "rike" << "fake";
-    testVal("key3", l2, QStringList, StringList);
-
-    QList<QVariant> l3;
-    QDate date = QDate::currentDate();
-    QTime time = QTime::currentTime();
-    l3 << QString("ene") << 10 << qVariantFromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4))
-        << QVariant(QSize(4, 56)) << QVariant(QPoint(4, 2)) << true << false << date << time;
-    testVal("key3", l3, QVariantList, List);
-
-    testVal("key4", QString("hello"), QString, String);
-    testVal("key5", QColor(1, 2, 3), QColor, Color);
-    testVal("key6", QRect(1, 2, 3, 4), QRect, Rect);
-    testVal("key7", QSize(4, 56), QSize, Size);
-    testVal("key8", QPoint(4, 2), QPoint, Point);
-    testVal("key10", date, QDate, Date);
-    testVal("key11", time, QTime, Time);
-    testVal("key12", QByteArray("foo bar"), QByteArray, ByteArray);
-
-    {
-        QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QVERIFY(!settings.contains("key99"));
-        QCOMPARE(settings.value("key99"), QVariant());
-
-        settings.setValue("key99", QVariant());
-        QVERIFY(settings.contains("key99"));
-        QCOMPARE(settings.value("key99"), QVariant());
-
-        settings.setValue("key99", QVariant(1));
-        QVERIFY(settings.contains("key99"));
-        QCOMPARE(settings.value("key99"), QVariant(1));
-
-        settings.setValue("key99", QVariant());
-        QVERIFY(settings.contains("key99"));
-        QCOMPARE(settings.value("key99"), QVariant());
-
-        settings.remove("key99");
-        QVERIFY(!settings.contains("key99"));
-        QCOMPARE(settings.value("key99"), QVariant());
-    }
-
-    QList<QVariant> l4;
-    l4 << QVariant(m2) << QVariant(l2) << QVariant(l3);
-    testVal("key13", l4, QVariantList, List);
-
-    // We store key sequences as strings instead of binary variant blob, for improved
-    // readability in the resulting format.
-    if (format >= QSettings::InvalidFormat) {
-        testVal("keysequence", QKeySequence(Qt::ControlModifier + Qt::Key_F1), QKeySequence, KeySequence);
-    } else {
-        testVal("keysequence", QKeySequence(Qt::ControlModifier + Qt::Key_F1).toString(), QString, String);
-    }
-
-#undef testVal
-#endif
-}
-
-void tst_QSettings::remove()
-{
-    QSettings settings0(QSettings::UserScope, "software.org", "KillerAPP");
-    int initialNumKeys = settings0.allKeys().size();
-    QCOMPARE(settings0.value("key 1", "123").toString(), QString("123"));
-    settings0.remove("key 1");
-    QCOMPARE(settings0.value("key 1", "456").toString(), QString("456"));
-
-    settings0.setValue("key 1", "bubloo");
-    QCOMPARE(settings0.value("key 1").toString(), QString("bubloo"));
-    settings0.remove("key 2");
-    QCOMPARE(settings0.value("key 1").toString(), QString("bubloo"));
-    settings0.remove("key 1");
-    QCOMPARE(settings0.value("key 1", "789").toString(), QString("789"));
-
-    /*
-      Make sure that removing a key removes all the subkeys.
-    */
-    settings0.setValue("alpha/beta/geometry", -7);
-    settings0.setValue("alpha/beta/geometry/x", 1);
-    settings0.setValue("alpha/beta/geometry/y", 2);
-    settings0.setValue("alpha/beta/geometry/width", 3);
-    settings0.setValue("alpha/beta/geometry/height", 4);
-    settings0.setValue("alpha/gamma/splitter", 5);
-
-    settings0.remove("alpha/beta/geometry/x");
-    QCOMPARE(settings0.value("alpha/beta/geometry").toInt(), -7);
-    QCOMPARE(settings0.value("alpha/beta/geometry/x", 999).toInt(), 999);
-    QCOMPARE(settings0.value("alpha/beta/geometry/y").toInt(), 2);
-    QCOMPARE(settings0.value("alpha/beta/geometry/width").toInt(), 3);
-    QCOMPARE(settings0.value("alpha/beta/geometry/height").toInt(), 4);
-    QCOMPARE(settings0.value("alpha/gamma/splitter").toInt(), 5);
-
-    settings0.remove("alpha/beta/geometry");
-    QCOMPARE(settings0.value("alpha/beta/geometry", 777).toInt(), 777);
-    QCOMPARE(settings0.value("alpha/beta/geometry/x", 111).toInt(), 111);
-    QCOMPARE(settings0.value("alpha/beta/geometry/y", 222).toInt(), 222);
-    QCOMPARE(settings0.value("alpha/beta/geometry/width", 333).toInt(), 333);
-    QCOMPARE(settings0.value("alpha/beta/geometry/height", 444).toInt(), 444);
-    QCOMPARE(settings0.value("alpha/gamma/splitter").toInt(), 5);
-
-    settings0.setValue("alpha/beta/geometry", -7);
-    settings0.setValue("alpha/beta/geometry/x", 1);
-    settings0.setValue("alpha/beta/geometry/y", 2);
-    settings0.setValue("alpha/beta/geometry/width", 3);
-    settings0.setValue("alpha/beta/geometry/height", 4);
-    settings0.setValue("alpha/gamma/splitter", 5);
-    QCOMPARE(settings0.allKeys().size(), initialNumKeys + 6);
-
-    settings0.beginGroup("alpha/beta/geometry");
-    settings0.remove("");
-    settings0.endGroup();
-    QVERIFY(!settings0.contains("alpha/beta/geometry"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/x"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/y"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/width"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/height"));
-    QVERIFY(settings0.contains("alpha/gamma/splitter"));
-    QCOMPARE(settings0.allKeys().size(), initialNumKeys + 1);
-
-    settings0.beginGroup("alpha/beta");
-    settings0.remove("");
-    settings0.endGroup();
-    QVERIFY(!settings0.contains("alpha/beta/geometry"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/x"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/y"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/width"));
-    QVERIFY(!settings0.contains("alpha/beta/geometry/height"));
-    QVERIFY(settings0.contains("alpha/gamma/splitter"));
-    QCOMPARE(settings0.allKeys().size(), initialNumKeys + 1);
-
-    settings0.remove("");
-    QVERIFY(!settings0.contains("alpha/gamma/splitter"));
-    QCOMPARE(settings0.allKeys().size(), initialNumKeys);
-
-    /*
-      Do it again, but this time let's use setGroup().
-    */
-
-    settings0.setValue("alpha/beta/geometry", -7);
-    settings0.setValue("alpha/beta/geometry/x", 1);
-    settings0.setValue("alpha/beta/geometry/y", 2);
-    settings0.setValue("alpha/beta/geometry/width", 3);
-    settings0.setValue("alpha/beta/geometry/height", 4);
-    settings0.setValue("alpha/gamma/splitter", 5);
-
-    settings0.beginGroup("foo/bar/baz/doesn't");
-    settings0.remove("exist");
-    settings0.endGroup();
-    QCOMPARE(settings0.value("alpha/beta/geometry").toInt(), -7);
-    QCOMPARE(settings0.value("alpha/beta/geometry/x").toInt(), 1);
-    QCOMPARE(settings0.value("alpha/beta/geometry/y").toInt(), 2);
-    QCOMPARE(settings0.value("alpha/beta/geometry/width").toInt(), 3);
-    QCOMPARE(settings0.value("alpha/beta/geometry/height").toInt(), 4);
-    QCOMPARE(settings0.value("alpha/gamma/splitter").toInt(), 5);
-
-    settings0.beginGroup("alpha/beta/geometry");
-    settings0.remove("x");
-    settings0.endGroup();
-    QCOMPARE(settings0.value("alpha/beta/geometry").toInt(), -7);
-    QCOMPARE(settings0.value("alpha/beta/geometry/x", 999).toInt(), 999);
-    QCOMPARE(settings0.value("alpha/beta/geometry/y").toInt(), 2);
-    QCOMPARE(settings0.value("alpha/beta/geometry/width").toInt(), 3);
-    QCOMPARE(settings0.value("alpha/beta/geometry/height").toInt(), 4);
-    QCOMPARE(settings0.value("alpha/gamma/splitter").toInt(), 5);
-
-    settings0.remove("alpha/beta");
-    QCOMPARE(settings0.value("alpha/beta/geometry", 777).toInt(), 777);
-    QCOMPARE(settings0.value("alpha/beta/geometry/x", 111).toInt(), 111);
-    QCOMPARE(settings0.value("alpha/beta/geometry/y", 222).toInt(), 222);
-    QCOMPARE(settings0.value("alpha/beta/geometry/width", 333).toInt(), 333);
-    QCOMPARE(settings0.value("alpha/beta/geometry/height", 444).toInt(), 444);
-    QCOMPARE(settings0.value("alpha/gamma/splitter").toInt(), 5);
-
-    settings0.clear();
-    QCOMPARE(settings0.value("alpha/gamma/splitter", 888).toInt(), 888);
-
-    /*
-      OK, now let's check what happens if settings are spread across
-      multiple files (user vs. global, product-specific vs.
-      company-wide).
-    */
-
-    QSettings settings1(QSettings::UserScope, "software.org", "KillerAPP");
-    QSettings settings2(QSettings::UserScope, "software.org");
-    QSettings settings3(QSettings::SystemScope, "software.org", "KillerAPP");
-    QSettings settings4(QSettings::SystemScope, "software.org");
-
-    settings4.setValue("key 1", "doodah");
-    settings3.setValue("key 1", "blah");
-    settings2.setValue("key 1", "whoa");
-    settings1.setValue("key 1", "gurgle");
-    QCOMPARE(settings1.value("key 1").toString(), QString("gurgle"));
-    QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
-
-    QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
-    QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-    settings1.remove("key 1");
-    QCOMPARE(settings1.value("key 1").toString(), QString("whoa"));
-    QCOMPARE(settings2.value("key 1").toString(), QString("whoa"));
-    QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
-    QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-    settings2.remove("key 1");
-    QCOMPARE(settings1.value("key 1").toString(), QString("blah"));
-    QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
-    QCOMPARE(settings3.value("key 1").toString(), QString("blah"));
-    QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-    settings3.remove("key 1");
-    QCOMPARE(settings1.value("key 1").toString(), QString("doodah"));
-    QCOMPARE(settings2.value("key 1").toString(), QString("doodah"));
-    QCOMPARE(settings3.value("key 1").toString(), QString("doodah"));
-    QCOMPARE(settings4.value("key 1").toString(), QString("doodah"));
-
-    settings4.remove("key 1");
-    QVERIFY(!settings1.contains("key 1"));
-    QVERIFY(!settings2.contains("key 1"));
-    QVERIFY(!settings3.contains("key 1"));
-    QVERIFY(!settings4.contains("key 1"));
-
-    /*
-      Get ready for the next part of the test.
-    */
+    QSettings settings(filename, format);
 
-    settings1.clear();
-    settings2.clear();
-    settings3.clear();
-    settings4.clear();
+    settings.setValue("a", "1");
+    QVERIFY(settings.contains("a"));
+    QCOMPARE(settings.value("a"), QVariant("1"));
 
-    settings1.sync();
-    settings2.sync();
-    settings3.sync();
-    settings4.sync();
+    settings.setValue("a/with/separator", "2");
+    QCOMPARE(settings.value("a/with/separator"), QVariant("2"));
 
-    /*
-      Check that recursive removes work correctly when some of the
-      keys are loaded from the file and others have been modified in
-      memory (corresponds to originalKeys vs. addedKeys in the
-      QSettingsFile code).
-    */
+    settings.remove("a");
+    QVERIFY(!settings.contains("a"));
+    QVERIFY(settings.value("a").isNull());
 
-    settings1.setValue("alpha/beta/geometry", -7);
-    settings1.setValue("alpha/beta/geometry/x", 1);
-    settings1.setValue("alpha/beta/geometry/y", 2);
-    settings1.setValue("alpha/gamma/splitter", 5);
-    settings1.sync();
-
-    settings1.setValue("alpha/beta/geometry/width", 3);
-    settings1.setValue("alpha/beta/geometry/height", 4);
-
-    settings1.remove("alpha/beta/geometry/y");
-    QVERIFY(settings1.contains("alpha/beta/geometry"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/x"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/y"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/width"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/height"));
-    QCOMPARE(settings1.allKeys().size(), initialNumKeys + 5);
-
-    settings1.remove("alpha/beta/geometry/y");
-    QCOMPARE(settings1.allKeys().size(), initialNumKeys + 5);
-
-    settings1.remove("alpha/beta/geometry/height");
-    QVERIFY(settings1.contains("alpha/beta/geometry"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/x"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/y"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/width"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/height"));
-    QCOMPARE(settings1.allKeys().size(), initialNumKeys + 4);
-
-    settings1.remove("alpha/beta/geometry");
-    QVERIFY(!settings1.contains("alpha/beta/geometry"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/x"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/y"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/width"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/height"));
-    QVERIFY(settings1.contains("alpha/gamma/splitter"));
-    QCOMPARE(settings1.allKeys().size(), initialNumKeys + 1);
-
-    settings1.sync();
-    QVERIFY(!settings1.contains("alpha/beta/geometry"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/x"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/y"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/width"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/height"));
-    QVERIFY(settings1.contains("alpha/gamma/splitter"));
-    QCOMPARE(settings1.allKeys().size(), initialNumKeys + 1);
+    const QVariant fallback(true);
+    QCOMPARE(settings.value("a", fallback), fallback);
 }
 
-/*
-    Tests contains() and keys().
-*/
-void tst_QSettings::contains()
+void tst_QSettings::sync_data()
 {
-    QSettings settings1(QSettings::UserScope, "software.org", "KillerAPP");
-    int initialNumKeys = settings1.allKeys().size(); // 0 on all platforms but Mac OS X.
-    settings1.setValue("alpha/beta/geometry", -7);
-    settings1.setValue("alpha/beta/geometry/x", 1);
-    settings1.setValue("alpha/beta/geometry/y", 2);
-    settings1.setValue("alpha/beta/geometry/width", 3);
-    settings1.setValue("alpha/beta/geometry/height", 4);
-    settings1.setValue("alpha/gamma/splitter", 5);
-    settings1.setValue("alpha/gamma/splitter/ /", 5);
-
-    QVERIFY(!settings1.contains("alpha"));
-    QVERIFY(!settings1.contains("alpha/beta"));
-    QVERIFY(!settings1.contains("///alpha///beta///"));
-    QVERIFY(settings1.contains("alpha/beta/geometry"));
-    QVERIFY(settings1.contains("///alpha///beta//geometry//"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/x"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/y"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/width"));
-    QVERIFY(settings1.contains("alpha/beta/geometry/height"));
-    QVERIFY(!settings1.contains("alpha/beta/geometry/height/foo/bar/doesn't/exist"));
-    QVERIFY(!settings1.contains("alpha/gamma"));
-    QVERIFY(settings1.contains("alpha/gamma/splitter"));
-    QVERIFY(settings1.contains("alpha/gamma/splitter/ "));
-    QVERIFY(settings1.contains("////alpha/gamma/splitter// ////"));
-
-    settings1.beginGroup("alpha");
-    QVERIFY(!settings1.contains("beta"));
-    QVERIFY(!settings1.contains("/////beta///"));
-    QVERIFY(settings1.contains("beta/geometry"));
-    QVERIFY(settings1.contains("/////beta//geometry//"));
-    QVERIFY(settings1.contains("beta/geometry/x"));
-    QVERIFY(settings1.contains("beta/geometry/y"));
-    QVERIFY(settings1.contains("beta/geometry/width"));
-    QVERIFY(settings1.contains("beta/geometry/height"));
-    QVERIFY(!settings1.contains("beta/geometry/height/foo/bar/doesn't/exist"));
-    QVERIFY(!settings1.contains("gamma"));
-    QVERIFY(settings1.contains("gamma/splitter"));
-    QVERIFY(settings1.contains("gamma/splitter/ "));
-    QVERIFY(settings1.contains("////gamma/splitter// ////"));
-
-    settings1.beginGroup("beta/geometry");
-    QVERIFY(settings1.contains("x"));
-    QVERIFY(settings1.contains("y"));
-    QVERIFY(settings1.contains("width"));
-    QVERIFY(settings1.contains("height"));
-    QVERIFY(!settings1.contains("height/foo/bar/doesn't/exist"));
-
-    QStringList keys = settings1.allKeys();
-    QStringList expectedResult = QStringList() << "x" << "y" << "width" << "height";
-    keys.sort();
-    expectedResult.sort();
-    int i;
-    QCOMPARE(keys, expectedResult);
-    for (i = 0; i < keys.size(); ++i) {
-        QVERIFY(settings1.contains(keys.at(i)));
-    }
-
-    settings1.endGroup();
-    QVERIFY(settings1.group() == "alpha");
-    keys = settings1.allKeys();
-    QCOMPARE(keys.size(), expectedResult.size() + 3);
-    for (i = 0; i < keys.size(); ++i) {
-        QVERIFY(settings1.contains(keys.at(i)));
-    }
-
-    settings1.endGroup();
-    QVERIFY(settings1.group().isEmpty());
-    keys = settings1.allKeys();
-
-    QCOMPARE(keys.size(), initialNumKeys + 7);
-    for (i = 0; i < keys.size(); ++i) {
-        QVERIFY(settings1.contains(keys.at(i)));
-    }
+    tst_QSettings::value_data();
 }
 
 void tst_QSettings::sync()
 {
-    /*
-        What we're trying to test here is the case where two
-        instances of the same application access the same preference
-        files. We want to make sure that the results are 'merged',
-        rather than having the last application overwrite settings
-        set by the first application (like in Qt 3).
-
-        This is only applicable to the INI format. The Windows
-        registry and Mac's CFPreferences API should take care of this
-        by themselves.
-    */
-
-    QSettings settings1(QSettings::IniFormat, QSettings::UserScope, "software.org");
-    settings1.setValue("alpha/beta/geometry", -7);
-    settings1.setValue("alpha/beta/geometry/x", 1);
-    settings1.setValue("alpha/beta/geometry/y", 2);
-    settings1.setValue("alpha/beta/geometry/width", 3);
-    settings1.setValue("alpha/beta/geometry/height", 4);
-    settings1.setValue("alpha/gamma/splitter", 5);
-    settings1.sync(); // and it all goes into the file
-
-    QSettings settings2(QSettings::IniFormat, QSettings::UserScope, "other.software.org");
-    settings2.setValue("alpha/beta/geometry/x", 8);
-    settings2.sync();
-
-    settings2.setValue("moo/beta/geometry", -7);
-    settings2.setValue("moo/beta/geometry/x", 1);
-    settings2.setValue("moo/beta/geometry/y", 2);
-    settings2.setValue("moo/beta/geometry/width", 3);
-    settings2.setValue("moo/beta/geometry/height", 4);
-    settings2.setValue("moo/gamma/splitter", 5);
-    settings2.setValue("alpha/gamma/splitter", 15);
-    settings2.remove("alpha/beta/geometry/x");
-    settings2.remove("alpha/beta/geometry/y"); // should do nothing
-
-    // Now "some other app" will change other.software.org.ini
-    QString userConfDir = settingsPath("__user__") + QDir::separator();
-    QFile::remove(userConfDir + "other.software.org.ini");
-    QFile::rename(userConfDir + "software.org.ini" , userConfDir + "other.software.org.ini");
-
-    settings2.sync();
-
-    // And voila, we should be merged
-
-    QCOMPARE(settings2.value("alpha/beta/geometry").toInt(), -7);
-    QVERIFY(!settings2.contains("alpha/beta/geometry/x")); // <----- removed by settings2
-    QCOMPARE(settings2.value("alpha/beta/geometry/y").toInt(), 2);
-    QCOMPARE(settings2.value("alpha/beta/geometry/width").toInt(), 3);
-    QCOMPARE(settings2.value("alpha/beta/geometry/height").toInt(), 4);
-    QCOMPARE(settings2.value("alpha/gamma/splitter").toInt(), 15); // <---- set by settings2
-    QCOMPARE(settings2.value("moo/beta/geometry").toInt(), -7);
-    QCOMPARE(settings2.value("moo/beta/geometry/x").toInt(), 1);
-    QCOMPARE(settings2.value("moo/beta/geometry/y").toInt(), 2);
-    QCOMPARE(settings2.value("moo/beta/geometry/width").toInt(), 3);
-    QCOMPARE(settings2.value("moo/beta/geometry/height").toInt(), 4);
-    QCOMPARE(settings2.value("moo/gamma/splitter").toInt(), 5);
-    QCOMPARE(settings2.allKeys().count(), 11);
+    QFETCH(QString, filename);
+    QFETCH(QSettings::Format, format);
 
-    // Now, software.org.ini no longer exists, this is same as another app
-    // clearing all settings.
-    settings1.sync();
-    QCOMPARE(settings1.allKeys().count(), 0);
+    QSettings settings(filename, format);
+    QSettings settings2(filename, format);
 
-/*
-    // Now "some other app" will change software.org.conf
-    unlink((userConfDir + "software.org.ini").toLatin1());
-    rename((userConfDir + "other.software.org.ini").toLatin1(),
-            (userConfDir + "software.org.ini").toLatin1());
+    settings.setValue("a", "1");
+    QCOMPARE(settings.value("a"), QVariant("1"));
+    QCOMPARE(settings2.value("a"), QVariant("1"));
 
-    settings1.sync();
-    QCOMPARE(settings1.value("alpha/beta/geometry").toInt(), -7);
-    QCOMPARE(settings1.value("alpha/beta/geometry/y").toInt(), 2);
-    QCOMPARE(settings1.value("alpha/beta/geometry/width").toInt(), 3);
-    QCOMPARE(settings1.value("alpha/beta/geometry/height").toInt(), 4);
-    QCOMPARE(settings1.value("alpha/gamma/splitter").toInt(), 15);
-    QCOMPARE(settings1.value("moo/beta/geometry").toInt(), -7);
-    QCOMPARE(settings1.value("moo/beta/geometry/x").toInt(), 1);
-    QCOMPARE(settings1.value("moo/beta/geometry/y").toInt(), 2);
-    QCOMPARE(settings1.value("moo/beta/geometry/width").toInt(), 3);
-    QCOMPARE(settings1.value("moo/beta/geometry/height").toInt(), 4);
-    QCOMPARE(settings1.value("moo/gamma/splitter").toInt(), 5);
-    QCOMPARE(settings1.allKeys().count(), 11);
-*/
+    settings2.setValue("b", "2");
+    QCOMPARE(settings.value("b"), QVariant("2"));
+    QCOMPARE(settings2.value("b"), QVariant("2"));
 }
 
-void tst_QSettings::setFallbacksEnabled_data()
-{
-    populateWithFormats();
-}
 
-void tst_QSettings::setFallbacksEnabled()
+void tst_QSettings::variant_data()
 {
-    QFETCH(QSettings::Format, format);
-
-    QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
-    QSettings settings2(format, QSettings::UserScope, "software.org");
-    QSettings settings3(format, QSettings::SystemScope, "software.org", "KillerAPP");
-    QSettings settings4(format, QSettings::SystemScope, "software.org");
-
-    settings1.setValue("key 1", "alpha");
-    settings2.setValue("key 1", "beta");
-    settings3.setValue("key 1", "gamma");
-    settings4.setValue("key 1", "delta");
-
-    settings1.setValue("key 2", "alpha");
-    settings2.setValue("key 2", "beta");
-    settings3.setValue("key 2", "gamma");
-
-    settings1.setValue("key 3", "alpha");
-    settings3.setValue("key 3", "gamma");
-    settings4.setValue("key 3", "delta");
-
-    settings1.setValue("key 4", "alpha");
-    settings2.setValue("key 4", "beta");
-    settings4.setValue("key 4", "delta");
-
-    settings2.setValue("key 5", "beta");
-    settings3.setValue("key 5", "gamma");
-    settings4.setValue("key 5", "delta");
-
-    QVERIFY(settings1.fallbacksEnabled());
-    QVERIFY(settings2.fallbacksEnabled());
-    QVERIFY(settings3.fallbacksEnabled());
-    QVERIFY(settings4.fallbacksEnabled());
-
-    settings1.setFallbacksEnabled(false);
-    settings2.setFallbacksEnabled(false);
-    settings3.setFallbacksEnabled(false);
-    settings4.setFallbacksEnabled(false);
-
-    QVERIFY(!settings1.fallbacksEnabled());
-    QVERIFY(!settings2.fallbacksEnabled());
-    QVERIFY(!settings3.fallbacksEnabled());
-    QVERIFY(!settings4.fallbacksEnabled());
-
-    /*
-        Make sure that the QSettings objects can still access their
-        main associated file when fallbacks are turned off.
-    */
-
-    QCOMPARE(settings1.value("key 1").toString(), QString("alpha"));
-    QCOMPARE(settings2.value("key 1").toString(), QString("beta"));
-    QCOMPARE(settings3.value("key 1").toString(), QString("gamma"));
-    QCOMPARE(settings4.value("key 1").toString(), QString("delta"));
-
-    QCOMPARE(settings1.value("key 2").toString(), QString("alpha"));
-    QCOMPARE(settings2.value("key 2").toString(), QString("beta"));
-    QCOMPARE(settings3.value("key 2").toString(), QString("gamma"));
-    QVERIFY(!settings4.contains("key 2"));
-
-    QCOMPARE(settings1.value("key 3").toString(), QString("alpha"));
-    QCOMPARE(settings3.value("key 3").toString(), QString("gamma"));
-    QCOMPARE(settings4.value("key 3").toString(), QString("delta"));
-    QVERIFY(!settings2.contains("key 3"));
-
-    QCOMPARE(settings1.value("key 4").toString(), QString("alpha"));
-    QCOMPARE(settings2.value("key 4").toString(), QString("beta"));
-    QCOMPARE(settings4.value("key 4").toString(), QString("delta"));
-    QVERIFY(!settings3.contains("key 4"));
-
-    QCOMPARE(settings2.value("key 5").toString(), QString("beta"));
-    QCOMPARE(settings3.value("key 5").toString(), QString("gamma"));
-    QCOMPARE(settings4.value("key 5").toString(), QString("delta"));
-    QVERIFY(!settings1.contains("key 5"));
-
-    QCOMPARE(settings1.value("key 1").toString(), QString("alpha"));
-    QCOMPARE(settings1.value("key 5").toString(), QString(""));
-    QVERIFY(settings1.contains("key 1"));
-    QVERIFY(!settings1.contains("key 5"));
+    tst_QSettings::value_data();
 }
 
-void tst_QSettings::testChildKeysAndGroups_data()
-{
-    populateWithFormats();
-}
+#define QVARIANT_TEST(V) \
+    settings.setValue("variant_" #V, V); \
+    QCOMPARE(settings.value("variant_" #V), QVariant(V));
 
-void tst_QSettings::testChildKeysAndGroups()
+void tst_QSettings::variant()
 {
+    QFETCH(QString, filename);
     QFETCH(QSettings::Format, format);
 
-    QSettings settings1(format, QSettings::UserScope, "software.org");
-    settings1.setFallbacksEnabled(false);
-    settings1.setValue("alpha/beta/geometry", -7);
-    settings1.setValue("alpha/beta/geometry/x", 1);
-    settings1.setValue("alpha/beta/geometry/y", 2);
-    settings1.setValue("alpha/beta/geometry/width", 3);
-    settings1.setValue("alpha/beta/geometry/height", 4);
-    settings1.setValue("alpha/gamma/splitter", 5);
-
-    QCOMPARE(settings1.childKeys(), QStringList());
-    QCOMPARE(settings1.childGroups(), QStringList() << "alpha");
-
-    settings1.beginGroup("/alpha");
-    QCOMPARE(settings1.childKeys(), QStringList());
-    QCOMPARE(settings1.childGroups(), QStringList() << "beta" << "gamma");
-
-    settings1.beginGroup("/beta");
-    QCOMPARE(settings1.childKeys(), QStringList() << "geometry");
-    QCOMPARE(settings1.childGroups(), QStringList() << "geometry");
-
-    settings1.beginGroup("/geometry");
-    QCOMPARE(settings1.childKeys(), QStringList()  << "height" << "width" << "x" << "y");
-    QCOMPARE(settings1.childGroups(), QStringList());
-
-    settings1.beginGroup("/width");
-    QCOMPARE(settings1.childKeys(), QStringList());
-    QCOMPARE(settings1.childGroups(), QStringList());
+    QSettings settings(filename, format);
+
+    const QPoint qpoint(1, 2);
+    const QRect qrect(1, 2, 3, 4);
+    const QSize qsize(1, 2);
+    const QByteArray qbytearray("abc");
+    const QByteArray qstring("mÃ¥ndag");
+    const QStringList qstringlist = QStringList() << "a" << "b" << "c";
+    const QDate qdate = QDate::currentDate();
+    const QColor qcolor(1, 2, 3);
+    const QFont qfont = QApplication::font();
+
+    QVARIANT_TEST(qpoint);
+    QVARIANT_TEST(qrect);
+    QVARIANT_TEST(qsize);
+    QVARIANT_TEST(qbytearray);
+    QVARIANT_TEST(qstring);
+    QVARIANT_TEST(qstringlist);
+    QVARIANT_TEST(qdate);
+    QVARIANT_TEST(qcolor);
+    QVARIANT_TEST(qfont);
+}
+#undef QVARIANT_TEST
 
-    settings1.endGroup();
-    settings1.endGroup();
-    settings1.endGroup();
-    settings1.endGroup();
-
-    { // task 53792
-        QSettings settings2("other.software.org");
-        settings2.setValue("viewbar/foo/test1", "1");
-        settings2.setValue("viewbar/foo/test2", "2");
-        settings2.setValue("viewbar/foo/test3", "3");
-        settings2.setValue("viewbar/foo/test4", "4");
-        settings2.setValue("viewbar/foo/test5", "5");
-        settings2.setValue("viewbar/bar/test1", "1");
-        settings2.setValue("viewbar/bar/test2", "2");
-        settings2.setValue("viewbar/bar/test3", "3");
-        settings2.setValue("viewbar/bar/test4", "4");
-        settings2.setValue("viewbar/bar/test5", "5");
-
-        settings2.beginGroup("viewbar");
-        QStringList l = settings2.childGroups();
-        settings2.endGroup();
-        l.sort();
-        QCOMPARE(l, QStringList() << "bar" << "foo");
-    }
-}
-
-void tst_QSettings::testUpdateRequestEvent()
-{
-    QFile::remove("foo");
-    QVERIFY(!QFile::exists("foo"));
-
-    QSettings settings1("foo", QSettings::IniFormat);
-    QVERIFY(!QFile::exists("foo"));
-    QVERIFY(QFileInfo("foo").size() == 0);
-    settings1.setValue("key1", 1);
-    QVERIFY(QFileInfo("foo").size() == 0);
-
-    QTRY_VERIFY(QFileInfo("foo").size() > 0);
-
-    settings1.remove("key1");
-    QVERIFY(QFileInfo("foo").size() > 0);
-
-    QTRY_VERIFY(QFileInfo("foo").size() == 0);
-
-    settings1.setValue("key2", 2);
-    QVERIFY(QFileInfo("foo").size() == 0);
-
-    QTRY_VERIFY(QFileInfo("foo").size() > 0);
-
-    settings1.clear();
-    QVERIFY(QFileInfo("foo").size() > 0);
-
-    QTRY_VERIFY(QFileInfo("foo").size() == 0);
-}
-
-const int NumIterations = 5;
-const int NumThreads = 4;
-
-class SettingsThread : public QThread
-{
-public:
-    void run();
-    void start(int n) { param = n; QThread::start(); }
-
-private:
-    int param;
-};
-
-void SettingsThread::run()
-{
-    for (int i = 0; i < NumIterations; ++i) {
-        QSettings settings("software.org", "KillerAPP");
-        settings.setValue(QString::number((param * NumIterations) + i), param);
-        settings.sync();
-        QCOMPARE((int)settings.status(), (int)QSettings::NoError);
-    }
-}
-
-void tst_QSettings::testThreadSafety()
-{
-    SettingsThread threads[NumThreads];
-    int i, j;
-
-    for (i = 0; i < NumThreads; ++i)
-        threads[i].start(i + 1);
-    for (i = 0; i < NumThreads; ++i)
-        threads[i].wait();
-
-    QSettings settings("software.org", "KillerAPP");
-    for (i = 0; i < NumThreads; ++i) {
-        int param = i + 1;
-        for (j = 0; j < NumIterations; ++j) {
-            QCOMPARE(settings.value(QString::number((param * NumIterations) + j)).toInt(), param);
-        }
-    }
-}
-
-void tst_QSettings::testNormalizedKey_data()
-{
-    QTest::addColumn<QString>("inKey");
-    QTest::addColumn<QString>("outKey");
-
-    QTest::newRow("empty1") << "" << "";
-    QTest::newRow("empty2") << "/" << "";
-    QTest::newRow("empty3") << "//" << "";
-    QTest::newRow("empty4") << "///" << "";
-
-    QTest::newRow("a1") << "a" << "a";
-    QTest::newRow("a2") << "/a" << "a";
-    QTest::newRow("a3") << "a/" << "a";
-    QTest::newRow("a4") << "//a" << "a";
-    QTest::newRow("a5") << "a//" << "a";
-    QTest::newRow("a6") << "///a" << "a";
-    QTest::newRow("a7") << "a///" << "a";
-    QTest::newRow("a8") << "///a/" << "a";
-    QTest::newRow("a9") << "/a///" << "a";
-
-    QTest::newRow("ab1") << "aaa/bbb" << "aaa/bbb";
-    QTest::newRow("ab2") << "/aaa/bbb" << "aaa/bbb";
-    QTest::newRow("ab3") << "aaa/bbb/" << "aaa/bbb";
-    QTest::newRow("ab4") << "/aaa/bbb/" << "aaa/bbb";
-    QTest::newRow("ab5") << "aaa///bbb" << "aaa/bbb";
-    QTest::newRow("ab6") << "aaa///bbb/" << "aaa/bbb";
-    QTest::newRow("ab7") << "/aaa///bbb/" << "aaa/bbb";
-    QTest::newRow("ab8") << "////aaa///bbb////" << "aaa/bbb";
-}
-
-void tst_QSettings::testNormalizedKey()
-{
-#ifdef QT_BUILD_INTERNAL
-    QFETCH(QString, inKey);
-    QFETCH(QString, outKey);
-
-    inKey.detach();
-
-    QString result = QSettingsPrivate::normalizedKey(inKey);
-    QCOMPARE(result, outKey);
-
-    /*
-        If the key is already normalized, we verify that outKey is
-        just a shallow copy of the input string. This is an important
-        optimization that shouldn't be removed accidentally.
-    */
-    if (inKey == outKey) {
-        QVERIFY(!result.isDetached());
-    } else {
-        if (!result.isEmpty()) {
-            QVERIFY(result.isDetached());
-        }
-    }
-#endif
-}
-
-void tst_QSettings::testEmptyData()
-{
-    QString filename(QDir::tempPath() + "/empty.ini");
-    QFile::remove(filename);
-    QVERIFY(!QFile::exists(filename));
-
-    QString nullString;
-    QString emptyString("");
-    QStringList emptyList;
-    QStringList list;
-    QStringList list2;
-
-    QVariantList emptyVList;
-    QVariantList vList, vList2, vList3;
-
-    list << emptyString << nullString;
-    list2 << emptyString;
-    vList << emptyString;
-    vList2 << emptyString << nullString;
-    vList3 << QString("foo");
-
-    {
-        QSettings settings(filename, QSettings::IniFormat);
-        settings.setValue("nullString", nullString);
-        settings.setValue("emptyString", emptyString);
-        settings.setValue("emptyList", emptyList);
-        settings.setValue("list", list);
-        settings.setValue("list2", list2);
-        settings.setValue("emptyVList", emptyVList);
-        settings.setValue("vList", vList);
-        settings.setValue("vList2", vList2);
-        settings.setValue("vList3", vList3);
-        QVERIFY(settings.status() == QSettings::NoError);
-    }
-    {
-        QSettings settings(filename, QSettings::IniFormat);
-        QCOMPARE(settings.value("nullString").toString(), nullString);
-        QCOMPARE(settings.value("emptyString").toString(), emptyString);
-        QCOMPARE(settings.value("emptyList").toStringList(), emptyList);
-        QCOMPARE(settings.value("list").toStringList(), list);
-        QCOMPARE(settings.value("list2").toStringList(), list2);
-        QCOMPARE(settings.value("emptyVList").toList(), emptyVList);
-        QCOMPARE(settings.value("vList").toList(), vList);
-        QCOMPARE(settings.value("vList2").toList(), vList2);
-        QCOMPARE(settings.value("vList3").toList(), vList3);
-        QVERIFY(settings.status() == QSettings::NoError);
-    }
-
-    {
-        QSettings settings("Trolltech", "tst_qsettings");
-        settings.setValue("nullString", nullString);
-        settings.setValue("emptyString", emptyString);
-        settings.setValue("emptyList", emptyList);
-        settings.setValue("list", list);
-        settings.setValue("list2", list2);
-        settings.setValue("emptyVList", emptyVList);
-        settings.setValue("vList", vList);
-        settings.setValue("vList2", vList2);
-        settings.setValue("vList3", vList3);
-        QVERIFY(settings.status() == QSettings::NoError);
-    }
-    {
-        QSettings settings("Trolltech", "tst_qsettings");
-        QCOMPARE(settings.value("nullString").toString(), nullString);
-        QCOMPARE(settings.value("emptyString").toString(), emptyString);
-        QCOMPARE(settings.value("emptyList").toStringList(), emptyList);
-        QCOMPARE(settings.value("list").toStringList(), list);
-        QCOMPARE(settings.value("list2").toStringList(), list2);
-        QCOMPARE(settings.value("emptyVList").toList(), emptyVList);
-        QCOMPARE(settings.value("vList").toList(), vList);
-        QCOMPARE(settings.value("vList2").toList(), vList2);
-        QCOMPARE(settings.value("vList3").toList(), vList3);
-        QVERIFY(settings.status() == QSettings::NoError);
-    }
-    QFile::remove(filename);
-}
-
-void tst_QSettings::testResourceFiles()
-{
-    QSettings settings(":/resourcefile.ini", QSettings::IniFormat);
-    QVERIFY(settings.status() == QSettings::NoError);
-    QVERIFY(!settings.isWritable());
-    QCOMPARE(settings.value("Field 1/Bottom").toInt(), 89);
-    settings.setValue("Field 1/Bottom", 90);
-
-    // the next two lines check the statu quo; another behavior would be possible
-    QVERIFY(settings.status() == QSettings::NoError);
-    QCOMPARE(settings.value("Field 1/Bottom").toInt(), 90);
-
-    settings.sync();
-    QVERIFY(settings.status() == QSettings::AccessError);
-    QCOMPARE(settings.value("Field 1/Bottom").toInt(), 90);
-}
-
-void tst_QSettings::fromFile_data()
-{
-    populateWithFormats();
-}
-
-void tst_QSettings::fromFile()
-{
-    QFETCH(QSettings::Format, format);
-
-    QFile::remove("foo");
-    QVERIFY(!QFile::exists("foo"));
-
-    QString path = "foo";
-
-    QStringList strList = QStringList() << "hope" << "destiny" << "chastity";
-
-    {
-        QSettings settings1(path, format);
-        QVERIFY(settings1.allKeys().isEmpty());
-
-        settings1.setValue("alpha", 1);
-        settings1.setValue("alpha", 2);
-        settings1.setValue("beta", strList);
-
-        QSettings settings2(path, format);
-        QCOMPARE(settings2.value("alpha").toInt(), 2);
-
-        settings1.sync();
-        QVERIFY(QFile::exists("foo"));
-        QCOMPARE(settings1.value("alpha").toInt(), 2);
-        QCOMPARE(settings2.value("alpha").toInt(), 2);
-
-        settings2.setValue("alpha", 3);
-        settings2.setValue("gamma/foo.bar", 4);
-        QCOMPARE(settings1.value("alpha").toInt(), 3);
-        QCOMPARE(settings2.value("alpha").toInt(), 3);
-        QCOMPARE(settings1.value("beta").toStringList(), strList);
-        QCOMPARE(settings2.value("beta").toStringList(), strList);
-        QCOMPARE(settings1.value("gamma/foo.bar").toInt(), 4);
-        QCOMPARE(settings2.value("gamma/foo.bar").toInt(), 4);
-    }
-
-    {
-        QSettings settings1(path, format);
-        QCOMPARE(settings1.value("alpha").toInt(), 3);
-        QCOMPARE(settings1.value("beta").toStringList(), strList);
-        QCOMPARE(settings1.value("gamma/foo.bar").toInt(), 4);
-        QCOMPARE(settings1.allKeys().size(), 3);
-    }
-}
-
-void tst_QSettings::setIniCodec()
-{
-#ifdef QT_BUILD_INTERNAL
-    QByteArray expeContents4, expeContents5;
-    QByteArray actualContents4, actualContents5;
-
-    {
-    QFile inFile(":/resourcefile4.ini");
-    inFile.open(QIODevice::ReadOnly);
-    expeContents4 = inFile.readAll();
-    inFile.close();
-    }
-
-    {
-    QFile inFile(":/resourcefile5.ini");
-    inFile.open(QIODevice::ReadOnly);
-    expeContents5 = inFile.readAll();
-    inFile.close();
-    }
-
-    {
-    QSettings settings4(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP");
-    settings4.setIniCodec("UTF-8");
-    settings4.setValue(QLatin1String("Fa\xe7" "ade/QU\xc9" "BEC"), QLatin1String("Fa\xe7" "ade/QU\xc9" "BEC"));
-    settings4.sync();
-
-    QSettings settings5(QSettings::IniFormat, QSettings::UserScope, "other.software.org", "KillerAPP");
-    settings5.setIniCodec("ISO 8859-1");
-    settings5.setValue(QLatin1String("Fa\xe7" "ade/QU\xc9" "BEC"), QLatin1String("Fa\xe7" "ade/QU\xc9" "BEC"));
-    settings5.sync();
-
-    {
-    QFile inFile(settings4.fileName());
-    inFile.open(QIODevice::ReadOnly);
-    actualContents4 = inFile.readAll();
-    inFile.close();
-    }
-
-    {
-    QFile inFile(settings5.fileName());
-    inFile.open(QIODevice::ReadOnly);
-    actualContents5 = inFile.readAll();
-    inFile.close();
-    }
-    }
-
-    QConfFile::clearCache();
-
-    QCOMPARE(actualContents4, expeContents4);
-    QCOMPARE(actualContents5, expeContents5);
-
-    QSettings settings4(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP");
-    settings4.setIniCodec("UTF-8");
-    QSettings settings5(QSettings::IniFormat, QSettings::UserScope, "other.software.org", "KillerAPP");
-    settings5.setIniCodec("Latin-1");
-
-    QCOMPARE(settings4.allKeys().count(), 1);
-    QCOMPARE(settings5.allKeys().count(), 1);
-
-    QCOMPARE(settings4.allKeys().first(), settings5.allKeys().first());
-    QCOMPARE(settings4.value(settings4.allKeys().first()).toString(),
-             settings5.value(settings5.allKeys().first()).toString());
-#endif
-}
-
-static bool containsSubList(QStringList mom, QStringList son)
-{
-    for (int i = 0; i < son.size(); ++i) {
-        if (!mom.contains(son.at(i)))
-            return false;
-    }
-    return true;
-}
-
-void tst_QSettings::testArrays_data()
-{
-    populateWithFormats();
-}
-
-/*
-    Tests beginReadArray(), beginWriteArray(), endArray(), and
-    setArrayIndex().
-*/
-void tst_QSettings::testArrays()
-{
-    QFETCH(QSettings::Format, format);
-
-    {
-        QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
-
-        settings1.beginWriteArray("foo/bar", 3);
-        settings1.setValue("bip", 1);
-        settings1.setArrayIndex(0);
-        settings1.setValue("ene", 2);
-        settings1.setValue("due", 3);
-        settings1.setValue("rike", 4);
-        settings1.setArrayIndex(1);
-        settings1.setValue("ene", 5);
-        settings1.setValue("due", 6);
-        settings1.setValue("rike", 7);
-        settings1.setArrayIndex(2);
-        settings1.setValue("ene", 8);
-        settings1.setValue("due", 9);
-        settings1.setValue("rike", 10);
-        settings1.endArray();
-
-        QStringList expectedList;
-        expectedList
-            << "foo/bar/bip"
-            << "foo/bar/size"
-            << "foo/bar/1/ene"
-            << "foo/bar/1/due"
-            << "foo/bar/1/rike"
-            << "foo/bar/2/ene"
-            << "foo/bar/2/due"
-            << "foo/bar/2/rike"
-            << "foo/bar/3/ene"
-            << "foo/bar/3/due"
-            << "foo/bar/3/rike";
-        expectedList.sort();
-
-        QStringList actualList = settings1.allKeys();
-        actualList.sort();
-        QVERIFY(containsSubList(actualList, expectedList));
-
-        QCOMPARE(settings1.value("/foo/bar/bip").toInt(), 1);
-        QCOMPARE(settings1.value("/foo/bar/1/ene").toInt(), 2);
-        QCOMPARE(settings1.value("/foo/bar/1/due").toInt(), 3);
-        QCOMPARE(settings1.value("/foo/bar/1/rike").toInt(), 4);
-        QCOMPARE(settings1.value("/foo/bar/2/ene").toInt(), 5);
-        QCOMPARE(settings1.value("/foo/bar/2/due").toInt(), 6);
-        QCOMPARE(settings1.value("/foo/bar/2/rike").toInt(), 7);
-        QCOMPARE(settings1.value("/foo/bar/3/ene").toInt(), 8);
-        QCOMPARE(settings1.value("/foo/bar/3/due").toInt(), 9);
-        QCOMPARE(settings1.value("/foo/bar/3/rike").toInt(), 10);
-
-        settings1.beginGroup("/foo");
-        int count = settings1.beginReadArray("bar");
-        QCOMPARE(count, 3);
-        QCOMPARE(settings1.value("bip").toInt(), 1);
-        settings1.setArrayIndex(0);
-        QCOMPARE(settings1.value("ene").toInt(), 2);
-        QCOMPARE(settings1.value("due").toInt(), 3);
-        QCOMPARE(settings1.value("rike").toInt(), 4);
-        QCOMPARE(settings1.allKeys().count(), 3);
-        settings1.setArrayIndex(1);
-        QCOMPARE(settings1.value("ene").toInt(), 5);
-        QCOMPARE(settings1.value("due").toInt(), 6);
-        QCOMPARE(settings1.value("rike").toInt(), 7);
-        QCOMPARE(settings1.allKeys().count(), 3);
-        settings1.setArrayIndex(2);
-        QCOMPARE(settings1.value("ene").toInt(), 8);
-        QCOMPARE(settings1.value("due").toInt(), 9);
-        QCOMPARE(settings1.value("rike").toInt(), 10);
-        QCOMPARE(settings1.allKeys().count(), 3);
-
-        settings1.endArray();
-        settings1.endGroup();
-    }
-    /*
-        Check that we get the arrays right when we load them again
-    */
-
-    {
-        QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
-
-        QStringList expectedList;
-        expectedList
-            << "foo/bar/bip"
-            << "foo/bar/size"
-            << "foo/bar/1/ene"
-            << "foo/bar/1/due"
-            << "foo/bar/1/rike"
-            << "foo/bar/2/ene"
-            << "foo/bar/2/due"
-            << "foo/bar/2/rike"
-            << "foo/bar/3/ene"
-            << "foo/bar/3/due"
-            << "foo/bar/3/rike";
-        expectedList.sort();
-
-        QStringList actualList = settings1.allKeys();
-        actualList.sort();
-        QVERIFY(containsSubList(actualList, expectedList));
-
-        QCOMPARE(settings1.value("/foo/bar/bip").toInt(), 1);
-        QCOMPARE(settings1.value("/foo/bar/1/ene").toInt(), 2);
-        QCOMPARE(settings1.value("/foo/bar/1/due").toInt(), 3);
-        QCOMPARE(settings1.value("/foo/bar/1/rike").toInt(), 4);
-        QCOMPARE(settings1.value("/foo/bar/2/ene").toInt(), 5);
-        QCOMPARE(settings1.value("/foo/bar/2/due").toInt(), 6);
-        QCOMPARE(settings1.value("/foo/bar/2/rike").toInt(), 7);
-        QCOMPARE(settings1.value("/foo/bar/3/ene").toInt(), 8);
-        QCOMPARE(settings1.value("/foo/bar/3/due").toInt(), 9);
-        QCOMPARE(settings1.value("/foo/bar/3/rike").toInt(), 10);
-
-        settings1.beginGroup("/foo");
-        int count = settings1.beginReadArray("bar");
-        QCOMPARE(count, 3);
-        QCOMPARE(settings1.value("bip").toInt(), 1);
-        settings1.setArrayIndex(0);
-        QCOMPARE(settings1.value("ene").toInt(), 2);
-        QCOMPARE(settings1.value("due").toInt(), 3);
-        QCOMPARE(settings1.value("rike").toInt(), 4);
-        QCOMPARE(settings1.allKeys().count(), 3);
-        settings1.setArrayIndex(1);
-        QCOMPARE(settings1.value("ene").toInt(), 5);
-        QCOMPARE(settings1.value("due").toInt(), 6);
-        QCOMPARE(settings1.value("rike").toInt(), 7);
-        QCOMPARE(settings1.allKeys().count(), 3);
-        settings1.setArrayIndex(2);
-        QCOMPARE(settings1.value("ene").toInt(), 8);
-        QCOMPARE(settings1.value("due").toInt(), 9);
-        QCOMPARE(settings1.value("rike").toInt(), 10);
-        QCOMPARE(settings1.allKeys().count(), 3);
-
-        settings1.endArray();
-        settings1.endGroup();
-    }
-    /*
-        This code generates lots of warnings, but that's on purpose.
-        Basically, we check that endGroup() can be used instead of
-        endArray() and vice versa. This is not documented, but this
-        is the behavior that we have chosen.
-    */
-    QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP");
-    settings1.clear();
-    settings1.beginGroup("/alpha");
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.setArrayIndex(0);
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.setArrayIndex(1);
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.setArrayIndex(2);
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.beginGroup("/beta");
-    QCOMPARE(settings1.group(), QString("alpha/beta"));
-    settings1.beginGroup("");
-    QCOMPARE(settings1.group(), QString("alpha/beta"));
-    settings1.beginWriteArray("DO", 4);
-    QCOMPARE(settings1.value("size").toInt(), 4);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO"));
-    settings1.setArrayIndex(0);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/1"));
-    settings1.setArrayIndex(1);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2"));
-    settings1.beginGroup("1");
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2/1"));
-    settings1.setArrayIndex(3);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2/1"));
-    settings1.setArrayIndex(4);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2/1"));
-    settings1.beginWriteArray("RE");
-    QVERIFY(!settings1.contains("size"));
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2/1/RE"));
-    settings1.setArrayIndex(0);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2/1/RE/1"));
-    settings1.setArrayIndex(1);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2/1/RE/2"));
-    settings1.endArray();
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2/1"));
-    settings1.endArray();
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/2"));
-    settings1.setArrayIndex(2);
-    QCOMPARE(settings1.group(), QString("alpha/beta/DO/3"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("alpha/beta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("alpha/beta"));
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString("alpha"));
-    settings1.endArray();
-    QCOMPARE(settings1.group(), QString());
-    settings1.endGroup();
-    QCOMPARE(settings1.group(), QString());
-
-    /*
-        Now, let's make sure that things work well if an array
-        is spread across multiple files.
-    */
-    int i;
-
-    settings1.clear();
-    QSettings settings2(format, QSettings::UserScope, "software.org");
-
-    QStringList threeStrings;
-    threeStrings << "Uno" << "Dos" << "Tres";
-
-    QStringList fiveStrings;
-    fiveStrings << "alpha" << "beta" << "gamma" << "delta" << "epsilon";
-
-    settings1.beginWriteArray("strings");
-    for (i = threeStrings.size() - 1; i >= 0; --i) {
-        settings1.setArrayIndex(i);
-        settings1.setValue("fileName", threeStrings.at(i));
-    }
-    settings1.endArray();
-
-    settings2.beginWriteArray("strings");
-    for (i = fiveStrings.size() - 1; i >= 0; --i) {
-        settings2.setArrayIndex(i);
-        settings2.setValue("fileName", fiveStrings.at(i));
-    }
-    settings2.endArray();
-
-    int size1 = settings1.beginReadArray("strings");
-    QCOMPARE(size1, 3);
-    QCOMPARE(settings1.value("size").toInt(), 3);
-
-    for (i = 0; i < size1; ++i) {
-        settings1.setArrayIndex(i);
-        QString str = settings1.value("fileName").toString();
-        QCOMPARE(str, threeStrings.at(i));
-    }
-    settings1.endArray();
-
-    int size2 = settings2.beginReadArray("strings");
-    QCOMPARE(size2, 5);
-    QCOMPARE(settings2.value("size").toInt(), 5);
-
-    for (i = 0; i < size2; ++i) {
-        settings2.setArrayIndex(i);
-        QString str = settings2.value("fileName").toString();
-        QCOMPARE(str, fiveStrings.at(i));
-    }
-    settings2.endArray();
-
-    size1 = settings1.beginReadArray("strings");
-    QCOMPARE(size1, 3);
-
-    // accessing entries beyond the end of settings1 goes to settings2
-    for (i = size1; i < size2; ++i) {
-        settings1.setArrayIndex(i);
-        QString str = settings1.value("fileName").toString();
-        QCOMPARE(str, fiveStrings.at(i));
-    }
-    settings1.endArray();
-}
-
-#ifdef QT_BUILD_INTERNAL
-static QByteArray iniEscapedKey(const QString &str)
-{
-    QByteArray result;
-    QSettingsPrivate::iniEscapedKey(str, result);
-    return result;
-}
-
-static QString iniUnescapedKey(const QByteArray &ba)
-{
-    QString result;
-    QSettingsPrivate::iniUnescapedKey(ba, 0, ba.size(), result);
-    return result;
-}
-
-static QByteArray iniEscapedStringList(const QStringList &strList)
-{
-    QByteArray result;
-    QSettingsPrivate::iniEscapedStringList(strList, result, 0);
-    return result;
-}
-
-static QStringList iniUnescapedStringList(const QByteArray &ba)
-{
-    QStringList result;
-    QString str;
-    bool isStringList = QSettingsPrivate::iniUnescapedStringList(ba, 0, ba.size(), str, result , 0);
-    if (!isStringList)
-        result = QStringList(str);
-    return result;
-}
-#endif
-
-QString escapeWeirdChars(const QString &s)
-{
-    QString result;
-    bool escapeNextDigit = false;
-
-    for (int i = 0; i < s.length(); ++i) {
-        QChar c = s.at(i);
-        if (c.unicode() < ' ' || c.unicode() > '~'
-            || (escapeNextDigit && c.unicode() >= '0' && c.unicode() <= 'f')) {
-            result += QString("\\x%1").arg(c.unicode(), 0, 16);
-            escapeNextDigit = true;
-        } else {
-            result += c;
-            escapeNextDigit = false;
-        }
-    }
-
-    return result;
-}
-
-void tst_QSettings::testEscapes()
-{
-#ifdef QT_BUILD_INTERNAL
-    QSettings settings(QSettings::UserScope, "software.org", "KillerAPP");
-
-#define testEscapedKey(plainKey, escKey) \
-    QCOMPARE(iniEscapedKey(plainKey), QByteArray(escKey)); \
-    QCOMPARE(iniUnescapedKey(escKey), QString(plainKey));
-
-#define testUnescapedKey(escKey, plainKey, reescKey) \
-    QCOMPARE(iniUnescapedKey(escKey), QString(plainKey)); \
-    QCOMPARE(iniEscapedKey(plainKey), QByteArray(reescKey)); \
-    QCOMPARE(iniUnescapedKey(reescKey), QString(plainKey));
-
-#define testEscapedStringList(plainStrList, escStrList) \
-    { \
-        QStringList plainList(plainStrList); \
-        QByteArray escList(escStrList); \
-        QCOMPARE(iniEscapedStringList(plainList), escList); \
-        QCOMPARE(iniUnescapedStringList(escList), plainList); \
-    } \
-
-
-#define testUnescapedStringList(escStrList, plainStrList, reescStrList) \
-    { \
-        QStringList plainList(plainStrList); \
-        QByteArray escList(escStrList); \
-        QByteArray reescList(reescStrList); \
-        QCOMPARE(iniUnescapedStringList(escList), plainList); \
-        QCOMPARE(iniEscapedStringList(plainList), reescList); \
-        QCOMPARE(iniUnescapedStringList(reescList), plainList); \
-    } \
-
-
-#define testVariant(val, escStr, func) \
-    { \
-        QVariant v(val); \
-        QString s = QSettingsPrivate::variantToString(v); \
-        /*qDebug() << QString("testVariant(): reference=\"%1\" result=\"%2\"").arg(escStr).arg(s); */\
-        QCOMPARE(s, escStr); \
-        QCOMPARE(QVariant(QSettingsPrivate::stringToVariant(escStr)), v); \
-        QVERIFY((val) == v.func()); \
-    }
-
-#define testBadEscape(escStr, vStr) \
-    { \
-        QVariant v = QSettingsPrivate::stringToVariant(QString(escStr)); \
-        QCOMPARE(v.toString(), QString(vStr)); \
-    }
-
-    testEscapedKey("", "");
-    testEscapedKey(" ", "%20");
-    testEscapedKey(" 0123 abcd ", "%200123%20abcd%20");
-    testEscapedKey("~!@#$%^&*()_+.-/\\=", "%7E%21%40%23%24%25%5E%26%2A%28%29_%2B.-\\%5C%3D");
-    testEscapedKey(QString() + QChar(0xabcd) + QChar(0x1234) + QChar(0x0081), "%UABCD%U1234%81");
-    testEscapedKey(QString() + QChar(0xFE) + QChar(0xFF) + QChar(0x100) + QChar(0x101), "%FE%FF%U0100%U0101");
-
-    testUnescapedKey("", "", "");
-    testUnescapedKey("%20", " ", "%20");
-    testUnescapedKey("/alpha/beta", "/alpha/beta", "\\alpha\\beta");
-    testUnescapedKey("\\alpha\\beta", "/alpha/beta", "\\alpha\\beta");
-    testUnescapedKey("%5Calpha%5Cbeta", "\\alpha\\beta", "%5Calpha%5Cbeta");
-    testUnescapedKey("%", "%", "%25");
-    testUnescapedKey("%f%!%%%%1x%x1%U%Uz%U123%U1234%1234%", QString("%f%!%%%%1x%x1%U%Uz%U123") + QChar(0x1234) + "\x12" + "34%",
-                     "%25f%25%21%25%25%25%251x%25x1%25U%25Uz%25U123%U1234%1234%25");
-
-    testEscapedStringList("", "");
-    testEscapedStringList(" ", "\" \"");
-    testEscapedStringList(";", "\";\"");
-    testEscapedStringList(",", "\",\"");
-    testEscapedStringList("=", "\"=\"");
-    testEscapedStringList("abc-def", "abc-def");
-    testEscapedStringList(QChar(0) + QString("0"), "\\0\\x30");
-    testEscapedStringList("~!@#$%^&*()_+.-/\\=", "\"~!@#$%^&*()_+.-/\\\\=\"");
-    testEscapedStringList("~!@#$%^&*()_+.-/\\", "~!@#$%^&*()_+.-/\\\\");
-    testEscapedStringList(QString("\x7F") + "12aFz", "\\x7f\\x31\\x32\\x61\\x46z");
-    testEscapedStringList(QString("   \t\n\\n") + QChar(0x123) + QChar(0x4567), "\"   \\t\\n\\\\n\\x123\\x4567\"");
-    testEscapedStringList(QString("\a\b\f\n\r\t\v'\"?\001\002\x03\x04"), "\\a\\b\\f\\n\\r\\t\\v'\\\"?\\x1\\x2\\x3\\x4");
-    testEscapedStringList(QStringList() << "," << ";" << "a" << "ab,  \tc, d ", "\",\", \";\", a, \"ab,  \\tc, d \"");
-
-    /*
-      Test .ini syntax that cannot be generated by QSettings (but can be entered by users).
-    */
-    testUnescapedStringList("", "", "");
-    testUnescapedStringList("\"\"", "", "");
-    testUnescapedStringList("\"abcdef\"", "abcdef", "abcdef");
-    testUnescapedStringList("\"\\?\\'\\\"\"", "?'\"", "?'\\\"");
-    testUnescapedStringList("\\0\\00\\000\\0000000\\1\\111\\11111\\x\\x0\\xABCDEFGH\\x0123456\\",
-                            QString() + QChar(0) + QChar(0) + QChar(0) + QChar(0) + QChar(1)
-                            + QChar(0111) + QChar(011111) + QChar(0) + QChar(0xCDEF) + "GH"
-                            + QChar(0x3456),
-                            "\\0\\0\\0\\0\\x1I\\x1249\\0\\xcdefGH\\x3456");
-    testUnescapedStringList(QByteArray("\\c\\d\\e\\f\\g\\$\\*\\\0", 16), "\f", "\\f");
-    testUnescapedStringList("\"a\",  \t\"bc \", \"  d\" , \"ef  \" ,,g,   hi  i,,, ,",
-                            QStringList() << "a" << "bc " << "  d" << "ef  " << "" << "g" << "hi  i"
-                                          << "" << "" << "" << "",
-                            "a, \"bc \", \"  d\", \"ef  \", , g, hi  i, , , , ");
-    testUnescapedStringList("a ,  b   ,   c   d   , efg   ",
-                            QStringList() << "a" << "b" << "c   d" << "efg",
-                            "a, b, c   d, efg");
-
-    // streaming qvariant into a string
-    testVariant(QString("Hello World!"), QString("Hello World!"), toString);
-    testVariant(QString("Hello, World!"), QString("Hello, World!"), toString);
-    testVariant(QString("@Hello World!"), QString("@@Hello World!"), toString);
-    testVariant(QString("@@Hello World!"), QString("@@@Hello World!"), toString);
-    testVariant(QByteArray("Hello World!"), QString("@ByteArray(Hello World!)"), toString);
-    testVariant(QByteArray("@Hello World!"), QString("@ByteArray(@Hello World!)"), toString);
-    testVariant(QVariant(100), QString("100"), toString);
-    testVariant(QStringList() << "ene" << "due" << "rike", QString::fromLatin1("@Variant(\x0\x0\x0\xb\x0\x0\x0\x3\x0\x0\x0\x6\x0\x65\x0n\x0\x65\x0\x0\x0\x6\x0\x64\x0u\x0\x65\x0\x0\x0\x8\x0r\x0i\x0k\x0\x65)", 50), toStringList);
-    testVariant(QRect(1, 2, 3, 4), QString("@Rect(1 2 3 4)"), toRect);
-    testVariant(QSize(5, 6), QString("@Size(5 6)"), toSize);
-    testVariant(QPoint(7, 8), QString("@Point(7 8)"), toPoint);
-
-    testBadEscape("", "");
-    testBadEscape("@", "@");
-    testBadEscape("@@", "@");
-    testBadEscape("@@@", "@@");
-    testBadEscape(" ", " ");
-    testBadEscape("@Rect", "@Rect");
-    testBadEscape("@Rect(", "@Rect(");
-    testBadEscape("@Rect()", "@Rect()");
-    testBadEscape("@Rect)", "@Rect)");
-    testBadEscape("@Rect(1 2 3)", "@Rect(1 2 3)");
-    testBadEscape("@@Rect(1 2 3)", "@Rect(1 2 3)");
-#endif
-}
-
-void tst_QSettings::testCaseSensitivity_data()
-{
-    populateWithFormats();
-}
-
-void tst_QSettings::testCaseSensitivity()
-{
-    QFETCH(QSettings::Format, format);
-
-    for (int pass = 0; pass < 2; ++pass) {
-        QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP");
-        settings.beginGroup("caseSensitivity");
-
-        bool cs = true;
-#ifndef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
-        switch (format) {
-        case QSettings::NativeFormat:
-            cs = false;
-            break;
-        case QSettings::IniFormat:
-            cs = false;
-            break;
-        case QSettings::CustomFormat1:
-            cs = true;
-            break;
-        case QSettings::CustomFormat2:
-            cs = false;
-            break;
-        default:
-            ;
-        }
-#endif
-
-        if (pass == 0) {
-            settings.setValue("key 1", 1);
-            settings.setValue("KEY 1", 2);
-            settings.setValue("key 2", 3);
-        }
-
-        for (int i = 0; i < 2; ++i) {
-            QVERIFY(settings.contains("key 1"));
-            QVERIFY(settings.contains("KEY 1"));
-            QCOMPARE(settings.value("KEY 1").toInt(), 2);
-/*            QVERIFY(settings.allKeys().contains("/KEY 1"));
-            QVERIFY(settings.allKeys().contains("/key 2")); */
-
-            if (cs) {
-                QVERIFY(!settings.contains("kEy 1"));
-                QCOMPARE(settings.value("key 1").toInt(), 1);
-                QCOMPARE(settings.allKeys().size(), 3);
-                QVERIFY(settings.allKeys().contains("key 1"));
-            } else {
-                QVERIFY(settings.contains("kEy 1"));
-                QCOMPARE(settings.value("kEy 1").toInt(), 2);
-                QCOMPARE(settings.value("key 1").toInt(), 2);
-                QCOMPARE(settings.allKeys().size(), 2);
-            }
-
-            settings.sync();
-        }
-
-        settings.remove("KeY 1");
-
-        if (cs) {
-            QVERIFY(!settings.contains("KeY 1"));
-            QVERIFY(settings.contains("key 1"));
-            QVERIFY(settings.contains("KEY 1"));
-            QCOMPARE(settings.value("key 1").toInt(), 1);
-            QCOMPARE(settings.value("KEY 1").toInt(), 2);
-            QCOMPARE(settings.allKeys().size(), 3);
-        } else {
-            QVERIFY(!settings.contains("KeY 1"));
-            QVERIFY(!settings.contains("key 1"));
-            QVERIFY(!settings.contains("KEY 1"));
-            QCOMPARE(settings.allKeys().size(), 1);
-        }
-        settings.setValue("KEY 1", 2);
-    }
-}
-
-void tst_QSettings::isWritable_data()
-{
-    populateWithFormats();
-}
-
-void tst_QSettings::isWritable()
-{
-    QFETCH(QSettings::Format, format);
-
-    {
-        QSettings s1(format, QSettings::UserScope, "software.org", "KillerAPP");
-        s1.setValue("foo", 1);
-        s1.sync();
-        // that should create the file
-    }
-
-    {
-        QSettings s1(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QVERIFY(s1.isWritable());
-    }
-
-    {
-        QSettings s1(format, QSettings::SystemScope, "software.org", "KillerAPP");
-        s1.setValue("foo", 1);
-        s1.sync();
-        // that should create the file, *if* we have the permissions
-    }
-
-    {
-        QSettings s1(format, QSettings::SystemScope, "software.org", "KillerAPP");
-        QSettings s2(format, QSettings::SystemScope, "software.org", "Something Different");
-        QSettings s3(format, QSettings::SystemScope, "foo.org", "Something Different");
-        if (s1.contains("foo")) {
-            QVERIFY(s1.isWritable());
-            QVERIFY(s2.isWritable());
-            QVERIFY(s3.isWritable());
-        } else {
-            QVERIFY(!s1.isWritable());
-            QVERIFY(!s2.isWritable());
-            QVERIFY(!s3.isWritable());
-        }
-    }
-}
-
-void tst_QSettings::childGroups_data()
-{
-    populateWithFormats();
-}
-
-void tst_QSettings::childGroups()
-{
-#ifdef QT_BUILD_INTERNAL
-    QFETCH(QSettings::Format, format);
-
-    {
-        QSettings settings(format, QSettings::SystemScope, "software.org");
-        settings.setValue("alpha", "1");
-        settings.setValue("alpha/a", "2");
-        settings.setValue("alpha/b", "3");
-        settings.setValue("alpha/c", "4");
-        settings.setValue("beta", "5");
-        settings.setValue("gamma", "6");
-        settings.setValue("gamma/d", "7");
-        settings.setValue("gamma/d/e", "8");
-        settings.setValue("gamma/f/g", "9");
-        settings.setValue("omicron/h/i/j/x", "10");
-        settings.setValue("omicron/h/i/k/y", "11");
-        settings.setValue("zeta/z", "12");
-    }
-
-    for (int pass = 0; pass < 3; ++pass) {
-        QConfFile::clearCache();
-        QSettings settings(format, QSettings::SystemScope, "software.org");
-        settings.setFallbacksEnabled(false);
-        if (pass == 1) {
-            settings.value("gamma/d");
-        } else if (pass == 2) {
-            settings.value("gamma");
-        }
-
-        settings.beginGroup("gamma");
-        QCOMPARE(settings.childGroups(), QStringList() << "d" << "f");
-        settings.beginGroup("d");
-        QCOMPARE(settings.childGroups(), QStringList());
-        settings.endGroup();
-        settings.endGroup();
-
-        settings.beginGroup("alpha");
-        QCOMPARE(settings.childGroups(), QStringList());
-        settings.endGroup();
-
-        settings.beginGroup("d");
-        QCOMPARE(settings.childGroups(), QStringList());
-        settings.endGroup();
-
-        settings.beginGroup("/omicron///h/i///");
-        QCOMPARE(settings.childGroups(), QStringList() << "j" << "k");
-        settings.endGroup();
-
-        settings.beginGroup("////");
-        QCOMPARE(settings.childGroups(), QStringList() << "alpha" << "gamma" << "omicron" << "zeta");
-        settings.endGroup();
-
-        QCOMPARE(settings.childGroups(), QStringList() << "alpha" << "gamma" << "omicron" << "zeta");
-    }
-#endif
-}
-
-void tst_QSettings::childKeys_data()
-{
-    populateWithFormats();
-}
-
-void tst_QSettings::childKeys()
-{
-#ifdef QT_BUILD_INTERNAL
-    QFETCH(QSettings::Format, format);
-
-    {
-        QSettings settings(format, QSettings::SystemScope, "software.org");
-        settings.setValue("alpha", "1");
-        settings.setValue("alpha/a", "2");
-        settings.setValue("alpha/b", "3");
-        settings.setValue("alpha/c", "4");
-        settings.setValue("beta", "5");
-        settings.setValue("gamma", "6");
-        settings.setValue("gamma/d", "7");
-        settings.setValue("gamma/d/e", "8");
-        settings.setValue("gamma/f/g", "9");
-        settings.setValue("omicron/h/i/j/x", "10");
-        settings.setValue("omicron/h/i/k/y", "11");
-        settings.setValue("zeta/z", "12");
-    }
-
-    for (int pass = 0; pass < 3; ++pass) {
-        QConfFile::clearCache();
-        QSettings settings(format, QSettings::SystemScope, "software.org");
-        settings.setFallbacksEnabled(false);
-        if (pass == 1) {
-            settings.value("gamma/d");
-        } else if (pass == 2) {
-            settings.value("gamma");
-        }
-
-        settings.beginGroup("gamma");
-        QCOMPARE(settings.childKeys(), QStringList() << "d");
-        settings.beginGroup("d");
-        QCOMPARE(settings.childKeys(), QStringList() << "e");
-        settings.endGroup();
-        settings.endGroup();
-
-        settings.beginGroup("alpha");
-        QCOMPARE(settings.childKeys(), QStringList() << "a" << "b" << "c");
-        settings.endGroup();
-
-        settings.beginGroup("d");
-        QCOMPARE(settings.childKeys(), QStringList());
-        settings.endGroup();
-
-        settings.beginGroup("/omicron///h/i///");
-        QCOMPARE(settings.childKeys(), QStringList());
-        settings.endGroup();
-
-        settings.beginGroup("////");
-        QCOMPARE(settings.childKeys(), QStringList() << "alpha" << "beta" << "gamma");
-        settings.endGroup();
-
-        QCOMPARE(settings.childKeys(), QStringList() << "alpha" << "beta" << "gamma");
-    }
-#endif
-}
-
-void tst_QSettings::allKeys_data()
-{
-    populateWithFormats();
-}
-
-void tst_QSettings::allKeys()
-{
-#ifdef QT_BUILD_INTERNAL
-    QFETCH(QSettings::Format, format);
-
-    QStringList allKeys;
-    allKeys << "alpha" << "alpha/a" << "alpha/b" << "alpha/c" << "beta" << "gamma" << "gamma/d"
-            << "gamma/d/e" << "gamma/f/g" << "omicron/h/i/j/x" << "omicron/h/i/k/y" << "zeta/z";
-
-    {
-        QSettings settings(format, QSettings::SystemScope, "software.org");
-        for (int i = 0; i < allKeys.size(); ++i)
-            settings.setValue(allKeys.at(i), QString::number(i + 1));
-    }
-
-    for (int pass = 0; pass < 3; ++pass) {
-        QConfFile::clearCache();
-        QSettings settings(format, QSettings::SystemScope, "software.org");
-        settings.setFallbacksEnabled(false);
-
-        if (pass == 1) {
-            settings.value("gamma/d");
-        } else if (pass == 2) {
-            settings.value("gamma");
-        }
-
-        settings.beginGroup("gamma");
-        QCOMPARE(settings.allKeys(), QStringList() << "d" << "d/e" << "f/g");
-        settings.beginGroup("d");
-        QCOMPARE(settings.allKeys(), QStringList() << "e");
-        settings.endGroup();
-        settings.endGroup();
-
-        settings.beginGroup("alpha");
-        QCOMPARE(settings.allKeys(), QStringList() << "a" << "b" << "c");
-        settings.endGroup();
-
-        settings.beginGroup("d");
-        QCOMPARE(settings.allKeys(), QStringList());
-        settings.endGroup();
-
-        settings.beginGroup("/omicron///h/i///");
-        QCOMPARE(settings.allKeys(), QStringList() << "j/x" << "k/y");
-        settings.endGroup();
-
-        settings.beginGroup("////");
-        QCOMPARE(settings.allKeys(), allKeys);
-        settings.endGroup();
-
-        QCOMPARE(settings.allKeys(), allKeys);
-    }
-#endif
-}
-
-void tst_QSettings::registerFormat()
-{
-    QSettings settings1(QSettings::IniFormat, QSettings::UserScope, "software.org", "KillerAPP");
-    QSettings settings2(QSettings::CustomFormat1, QSettings::UserScope, "software.org", "KillerAPP");
-
-    QString fileName = settings1.fileName();
-    fileName.chop(3); // "ini";
-    fileName.append("custom1");
-    QCOMPARE(settings2.fileName(), fileName);
-
-    // OK, let's see if it can read a generated file of a custom type
-    // Beware: readCustom3File() and writeCustom3File() have unintuitive behavior
-    // so we can test error handling
-
-    QSettings::Format custom3 = QSettings::registerFormat("custom3", readCustom3File, writeCustom3File);
-    QVERIFY(custom3 == QSettings::CustomFormat3);
-
-    QDir dir(settingsPath());
-    QVERIFY(dir.mkpath("someDir"));
-    QFile f(dir.path()+"/someDir/someSettings.custom3");
-
-    QVERIFY(f.open(QFile::WriteOnly));
-    f.write("OK");
-    f.close();
-
-    {
-    QSettings settings(settingsPath("someDir/someSettings.custom3"), QSettings::CustomFormat3);
-    QCOMPARE(settings.status(), QSettings::NoError);
-    QCOMPARE(settings.value("retval").toString(), QString("OK"));
-    QVERIFY(settings.isWritable());
-    }
-
-    QVERIFY(f.open(QFile::WriteOnly));
-    f.write("NotOK");
-    f.close();
-
-    {
-    QSettings settings(settingsPath("someDir/someSettings.custom3"), QSettings::CustomFormat3);
-    QCOMPARE(settings.status(), QSettings::FormatError);
-    QCOMPARE(settings.value("retval").toString(), QString());
-    QVERIFY(settings.isWritable());
-    }
-
-    QVERIFY(f.open(QFile::WriteOnly));
-    f.write("OK");
-    f.close();
-
-    {
-    QSettings settings(settingsPath("someDir/someSettings.custom3"), QSettings::CustomFormat3);
-    QCOMPARE(settings.status(), QSettings::NoError);
-    settings.setValue("zzz", "bar");
-    settings.sync();
-    QCOMPARE(settings.status(), QSettings::NoError);
-
-    settings.setValue("retval", "NotOK");
-    settings.sync();
-    QCOMPARE(settings.status(), QSettings::AccessError);
-
-    QCOMPARE(settings.value("retval").toString(), QString("NotOK"));
-    QVERIFY(settings.isWritable());
-    }
-
-    {
-    QSettings settings(settingsPath("someDir/someSettings.custom3"), QSettings::CustomFormat4);
-    QCOMPARE(settings.status(), QSettings::AccessError);
-    QVERIFY(!settings.isWritable());
-    }
-}
-
-void tst_QSettings::setPath()
-{
-#define TEST_PATH(doSet, ext, format, scope, path) \
-    { \
-    if (doSet) \
-        QSettings::setPath(QSettings::format, QSettings::scope, settingsPath(path)); \
-    QSettings settings1(QSettings::format, QSettings::scope, "software.org", "KillerAPP"); \
-    QCOMPARE(QDir(settings1.fileName()), QDir(settingsPath(path) + QDir::separator() + "software.org" \
-                                  + QDir::separator() + "KillerAPP." + ext)); \
-    }
-
-    /*
-        The first pass checks that setPath() works; the second
-        path checks that it has no bad side effects.
-    */
-    for (int i = 0; i < 2; ++i) {
-        TEST_PATH(i == 0, "conf", NativeFormat, UserScope, "alpha")
-        TEST_PATH(i == 0, "conf", NativeFormat, SystemScope, "beta")
-        TEST_PATH(i == 0, "ini", IniFormat, UserScope, "gamma")
-        TEST_PATH(i == 0, "ini", IniFormat, SystemScope, "omicron")
-        TEST_PATH(i == 0, "custom1", CustomFormat1, UserScope, "epsilon")
-        TEST_PATH(i == 0, "custom1", CustomFormat1, SystemScope, "zeta")
-        TEST_PATH(i == 0, "custom2", CustomFormat2, UserScope, "eta")
-        TEST_PATH(i == 0, "custom2", CustomFormat2, SystemScope, "iota")
-    }
-}
-
-void tst_QSettings::setDefaultFormat()
-{
-    QVERIFY(QSettings::defaultFormat() == QSettings::NativeFormat);
-
-    QSettings::setDefaultFormat(QSettings::CustomFormat1);
-    QSettings settings1("org", "app");
-    QSettings settings2(QSettings::SystemScope, "org", "app");
-    QSettings settings3;
-
-    QVERIFY(settings1.format() == QSettings::NativeFormat);
-    QVERIFY(settings2.format() == QSettings::NativeFormat);
-    QVERIFY(settings3.format() == QSettings::CustomFormat1);
-
-    QSettings::setDefaultFormat(QSettings::NativeFormat);
-    QVERIFY(QSettings::defaultFormat() == QSettings::NativeFormat);
-
-    QVERIFY(settings1.format() == QSettings::NativeFormat);
-    QVERIFY(settings2.format() == QSettings::NativeFormat);
-    QVERIFY(settings3.format() == QSettings::CustomFormat1);
-}
-
-void tst_QSettings::dontCreateNeedlessPaths()
-{
-    QString path;
-    {
-        QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Hello", "Test");
-        QVariant val = settings.value("foo", "bar");
-        path = settings.fileName();
-    }
-
-    QFileInfo fileInfo(path);
-    QVERIFY(!fileInfo.dir().exists());
-}
-
-void tst_QSettings::dontReorderIniKeysNeedlessly()
-{
-#ifdef  QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER
-    QSKIP("This Qt build does not preserve ordering, as a code size optimization.", SkipAll);
-#endif
-
-    /*
-        This is a very strong test. It asserts that modifying
-        resourcefile2.ini will lead to the exact contents of
-        resourcefile3.ini. Right now it's run only on Unix
-        systems, but that should be enough since the INI
-        code (unlike this test) is platform-agnostic.
-
-        Things that are tested:
-
-            * keys are written in the same order that they were
-              read in
-
-            * new keys are put at the end of their respective
-              sections
-    */
-
-    QFile inFile(":/resourcefile2.ini");
-    inFile.open(QIODevice::ReadOnly);
-    QByteArray contentsBefore = inFile.readAll();
-    inFile.close();
-
-    QByteArray expectedContentsAfter;
-
-    {
-        QFile inFile(":/resourcefile3.ini");
-        inFile.open(QIODevice::ReadOnly);
-        expectedContentsAfter = inFile.readAll();
-        inFile.close();
-    }
-
-    QString outFileName;
-    QString outFileName2;
-
-    QTemporaryFile outFile;
-    outFile.open();
-    outFile.write(contentsBefore);
-    outFileName = outFile.fileName();
-    outFile.close();
-
-    QSettings settings(outFileName, QSettings::IniFormat);
-    QVERIFY(settings.status() == QSettings::NoError);
-    QVERIFY(settings.isWritable());
-
-    settings.setValue("Field 1/Bottom", 90);
-    settings.setValue("Field 1/x", 1);
-    settings.setValue("Field 1/y", 1);
-    settings.setValue("Field 1/width", 1);
-    settings.setValue("Field 1/height", 1);
-    settings.sync();
-
-    QFile outFile2(outFileName);
-    QVERIFY(outFile2.open(QIODevice::ReadOnly));
-    QCOMPARE(outFile2.readAll(), expectedContentsAfter);
-    outFile2.close();
-}
-
-void tst_QSettings::rainersSyncBugOnMac_data()
-{
-    ctor_data();
-}
-
-void tst_QSettings::rainersSyncBugOnMac()
-{
-    QFETCH(QSettings::Format, format);
-
-    QString fileName;
-
-    {
-        QSettings s1(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QCOMPARE(s1.value("key1", 5).toInt(), 5);
-        fileName = s1.fileName();
-    }
-
-    {
-        QSettings s2(fileName, format);
-        s2.setValue("key1", 25);
-    }
-
-    {
-        QSettings s3(format, QSettings::UserScope, "software.org", "KillerAPP");
-        QCOMPARE(s3.value("key1", 30).toInt(), 25);
-    }
-}
-
-void tst_QSettings::recursionBug()
-{
-    QPixmap pix(10,10);
-    pix.fill("blue");
-
-    {
-        QSettings settings(settingsPath("starrunner.ini"), QSettings::IniFormat);
-        settings.setValue("General/Pixmap", pix );
-    }
-}
-
-/*
-// Not tested at the moment.
-void tst_QSettings::oldSubkeyList()
-{
-    QVERIFY( TRUE );
-}
-*/
-
-QTEST_MAIN(tst_QSettings)
+QTEST_MAIN(tst_QSettings)
 
 #include "moc_tst_qsettings.cpp"
-#include "qrc_qsettings.cpp"
-
-// foo