blob: c7ce483d0a16c0c1b6b01688893bc13777b579dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "utils_global.h"
#include <QVariant>
namespace Utils::SettingsDatabase {
QTCREATOR_UTILS_EXPORT void setValue(const QString &key, const QVariant &value);
QTCREATOR_UTILS_EXPORT QVariant value(const QString &key, const QVariant &defaultValue = {});
QTCREATOR_UTILS_EXPORT bool contains(const QString &key);
QTCREATOR_UTILS_EXPORT void remove(const QString &key);
QTCREATOR_UTILS_EXPORT void beginGroup(const QString &prefix);
QTCREATOR_UTILS_EXPORT void endGroup();
QTCREATOR_UTILS_EXPORT QString group();
QTCREATOR_UTILS_EXPORT QStringList childKeys();
QTCREATOR_UTILS_EXPORT void beginTransaction();
QTCREATOR_UTILS_EXPORT void endTransaction();
QTCREATOR_UTILS_EXPORT void destroy();
template<typename T>
void setValueWithDefault(const QString &key, const T &val, const T &defaultValue = T())
{
if (val == defaultValue)
remove(key);
else
setValue(key, QVariant::fromValue(val));
}
} // Utils::SettingsDatabase
|