QtMvvm
1.1.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
src
mvvmdatasynccore
datasyncsettingsentry.h
1
#ifndef QTMVVM_DATASYNCSETTINGSENTRY_H
2
#define QTMVVM_DATASYNCSETTINGSENTRY_H
3
4
#include <QtCore/qobject.h>
5
#include <QtCore/qvariant.h>
6
#include <QtCore/qshareddata.h>
7
8
#include "QtMvvmDataSyncCore/qtmvvmdatasynccore_global.h"
9
10
namespace
QtMvvm
{
11
12
class
DataSyncSettingsEntryData;
14
struct
Q_MVVMDATASYNCCORE_EXPORT
DataSyncSettingsEntry
15
{
16
Q_GADGET
17
19
Q_PROPERTY(
QString
key READ key WRITE setKey USER
true
)
21
Q_PROPERTY(
int
dataVersion READ dataVersion WRITE setDataVersion)
23
Q_PROPERTY(
QVariant
value READ value WRITE setValue STORED false)
24
26
Q_PROPERTY(
QByteArray
valueData READ valueData WRITE setValueData)
27
28
public:
29
DataSyncSettingsEntry
();
30
~
DataSyncSettingsEntry
();
32
DataSyncSettingsEntry
(const
DataSyncSettingsEntry
&other);
34
DataSyncSettingsEntry
(
DataSyncSettingsEntry
&&other) noexcept;
36
DataSyncSettingsEntry
&operator=(const
DataSyncSettingsEntry
&other);
38
DataSyncSettingsEntry
&operator=(
DataSyncSettingsEntry
&&other) noexcept;
39
41
DataSyncSettingsEntry
(
QString
key,
QVariant
value);
43
template <typename T>
44
DataSyncSettingsEntry
(
QString
key, const T &value);
45
47
QString
key() const;
49
int
dataVersion() const;
50
52
QVariant
value() const;
54
template <typename T>
55
T value() const;
56
58
void
setKey(
QString
key);
60
void
setDataVersion(
int
dataVersion);
62
void
setValue(
QVariant
value);
63
64
private:
65
QByteArray
valueData() const;
66
void
setValueData(
QByteArray
value);
67
68
QSharedDataPointer
<DataSyncSettingsEntryData> d;
69
};
70
71
// ------------- Generic Implementation -------------
72
73
template<typename T>
74
DataSyncSettingsEntry
::
DataSyncSettingsEntry
(
QString
key, const T &value) :
75
DataSyncSettingsEntry
{std::move(key),
QVariant::fromValue
(value)}
76
{}
77
78
template
<
typename
T>
79
T
DataSyncSettingsEntry::value
()
const
80
{
81
return
value().template value<T>();
82
}
83
84
}
85
86
Q_DECLARE_METATYPE(
QtMvvm::DataSyncSettingsEntry
)
87
88
#endif // QTMVVM_DATASYNCSETTINGSENTRY_H
QtMvvm::DataSyncSettingsEntry::value
QVariant value() const
READ accessor for variantValue.
QByteArray
QString
QVariant::fromValue
QVariant fromValue(const T &value)
QtMvvm::DataSyncSettingsEntry
A class used with the DataSyncSettingsAccessor to store and sync generic settings.
Definition:
datasyncsettingsentry.h:14
QtMvvm
The primary namespace of the QtMvvm library.
Definition:
androidsettingsaccessor.h:9
QSharedDataPointer
QVariant
Generated on Wed Aug 8 2018 19:15:45 for QtMvvm by
1.8.14