Skycoder42
6 years ago
8 changed files with 163 additions and 23 deletions
@ -1,3 +1,53 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<Settings name="TestSettings"> |
|||
<Settings name="TestSettings" |
|||
prefix="SOME_EXPORT" |
|||
baseKey="tests"> |
|||
<Include>QtCore/QDateTime</Include> |
|||
<Include local="false">QtCore/QUrl</Include> |
|||
<Include local="true">testbackend.h</Include> |
|||
|
|||
<Backend class="TestBackend"> |
|||
<Param type="QString" asStr="true">Test Backend</Param> |
|||
<Param type="int">42</Param> |
|||
</Backend> |
|||
|
|||
<TypeMapping key="range" type="int"/> |
|||
|
|||
<Node key="emptyNode"/> |
|||
<Entry key="emptyEntry" |
|||
type="bool"/> |
|||
<Entry key="advancedEntry" |
|||
type="QString" |
|||
qmlGroupKey="qmlAdvancedEntry" |
|||
default="Hello World" |
|||
tr="true" |
|||
trContext="some_context"/> |
|||
<Entry key="codeEntry" |
|||
type="QUrl"> |
|||
<Code>QUrl::fromLocalFile(QStringLiteral("/path/to/something"))</Code> |
|||
</Entry> |
|||
|
|||
<Node key="parentNode"> |
|||
<Node key="emptyChildNode"/> |
|||
<Node key="fullChildNode"> |
|||
<Entry key="replaceEntry" |
|||
type="range" |
|||
default="42"/> |
|||
</Node> |
|||
<Entry key="parentEntry" |
|||
type="bool"> |
|||
<Node key="subNode"/> |
|||
<Entry key="nodeWithCodeEntry" |
|||
type="int"> |
|||
<Node key="someNode"/> |
|||
<Code> |
|||
qRound(42.5) |
|||
</Code> |
|||
</Entry> |
|||
<Entry key="leafEntry" |
|||
type="QString" |
|||
default="translate me" |
|||
tr="true"/> |
|||
</Entry> |
|||
</Node> |
|||
</Settings> |
|||
|
@ -0,0 +1,29 @@ |
|||
#include "testbackend.h" |
|||
|
|||
TestBackend::TestBackend(QString name, int code, QObject *parent) : |
|||
ISettingsAccessor{parent}, |
|||
_name{std::move(name)}, |
|||
_code{code} |
|||
{} |
|||
|
|||
bool TestBackend::contains(const QString &key) const |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
QVariant TestBackend::load(const QString &key, const QVariant &defaultValue) const |
|||
{ |
|||
return {}; |
|||
} |
|||
|
|||
void TestBackend::save(const QString &key, const QVariant &value) |
|||
{ |
|||
} |
|||
|
|||
void TestBackend::remove(const QString &key) |
|||
{ |
|||
} |
|||
|
|||
void TestBackend::sync() |
|||
{ |
|||
} |
@ -0,0 +1,30 @@ |
|||
#ifndef TESTBACKEND_H |
|||
#define TESTBACKEND_H |
|||
|
|||
#include <QtMvvmCore/ISettingsAccessor> |
|||
|
|||
class TestBackend : public QtMvvm::ISettingsAccessor |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
explicit TestBackend(QString name, int code, QObject *parent = nullptr); |
|||
|
|||
// ISettingsAccessor interface
|
|||
public: |
|||
bool contains(const QString &key) const override; |
|||
QVariant load(const QString &key, const QVariant &defaultValue) const override; |
|||
void save(const QString &key, const QVariant &value) override; |
|||
void remove(const QString &key) override; |
|||
|
|||
public slots: |
|||
void sync() override; |
|||
|
|||
public: |
|||
QString _name; |
|||
int _code; |
|||
}; |
|||
|
|||
#define SOME_EXPORT |
|||
|
|||
#endif // TESTBACKEND_H
|
Loading…
Reference in new issue