blob: 997c0cb110a56512c654d8a3d6cb450235c9653a (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (C) 2017 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qremoteobjectsettingsstore.h"
#include "qremoteobjectnode_p.h"
#include <QtCore/private/qobject_p.h>
#include <QtCore/qsettings.h>
QT_BEGIN_NAMESPACE
/*!
\qmltype SettingsStore
\inqmlmodule QtRemoteObjects
\brief A basic store for persisted properties.
This type provides simple QSettings-based storage for properties marked as PERSISTED. It is used in
conjunction with Node::persistedStore:
\code
Node {
persistedStore: SettingsStore {}
}
\endcode
*/
class QRemoteObjectSettingsStorePrivate : public QRemoteObjectAbstractPersistedStorePrivate
{
public:
QRemoteObjectSettingsStorePrivate();
virtual ~QRemoteObjectSettingsStorePrivate();
QSettings settings;
Q_DECLARE_PUBLIC(QRemoteObjectSettingsStore)
};
QRemoteObjectSettingsStorePrivate::QRemoteObjectSettingsStorePrivate()
{
}
QRemoteObjectSettingsStorePrivate::~QRemoteObjectSettingsStorePrivate()
{
}
QRemoteObjectSettingsStore::QRemoteObjectSettingsStore(QObject *parent)
: QRemoteObjectAbstractPersistedStore(*new QRemoteObjectSettingsStorePrivate, parent)
{
}
QRemoteObjectSettingsStore::~QRemoteObjectSettingsStore()
{
}
QVariantList QRemoteObjectSettingsStore::restoreProperties(const QString &repName, const QByteArray &repSig)
{
Q_D(QRemoteObjectSettingsStore);
d->settings.beginGroup(repName + QLatin1Char('/') + QString::fromLatin1(repSig));
QVariantList values = d->settings.value(QStringLiteral("values")).toList();
d->settings.endGroup();
return values;
}
void QRemoteObjectSettingsStore::saveProperties(const QString &repName, const QByteArray &repSig, const QVariantList &values)
{
Q_D(QRemoteObjectSettingsStore);
d->settings.beginGroup(repName + QLatin1Char('/') + QString::fromLatin1(repSig));
d->settings.setValue(QStringLiteral("values"), values);
d->settings.endGroup();
d->settings.sync();
}
QT_END_NAMESPACE
|