blob: 66a006ab221de593bd380eea0d2f9efe389e9250 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// 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 "filepath.h"
#include <QVariant>
QT_BEGIN_NAMESPACE
class QWidget;
QT_END_NAMESPACE
namespace Utils {
class QTCREATOR_UTILS_EXPORT PersistentSettingsReader
{
public:
PersistentSettingsReader();
QVariant restoreValue(const QString &variable, const QVariant &defaultValue = QVariant()) const;
QVariantMap restoreValues() const;
bool load(const FilePath &fileName);
private:
QMap<QString, QVariant> m_valueMap;
};
class QTCREATOR_UTILS_EXPORT PersistentSettingsWriter
{
public:
PersistentSettingsWriter(const FilePath &fileName, const QString &docType);
bool save(const QVariantMap &data, QString *errorString) const;
#ifdef QT_GUI_LIB
bool save(const QVariantMap &data, QWidget *parent) const;
#endif
FilePath fileName() const;
void setContents(const QVariantMap &data);
private:
bool write(const QVariantMap &data, QString *errorString) const;
const FilePath m_fileName;
const QString m_docType;
mutable QMap<QString, QVariant> m_savedData;
};
} // namespace Utils
|