A settings accessor implementation that allows to store and sync settings via datasync. More...
#include <datasyncsettingsaccessor.h>
Public Slots | |
void | sync () override |
Synchronizes the settings to the disk or whatever is needed to permanently store them. More... | |
Public Slots inherited from QtMvvm::ISettingsAccessor | |
virtual void | sync ()=0 |
Synchronizes the settings to the disk or whatever is needed to permanently store them. More... | |
Public Member Functions | |
Q_INVOKABLE | DataSyncSettingsAccessor (QObject *parent=nullptr) |
Default Constructor. | |
DataSyncSettingsAccessor (const QString &setupName, QObject *parent=nullptr) | |
Constructor, with the name of the datasync setup to use. | |
DataSyncSettingsAccessor (QtDataSync::DataStore *store, QObject *parent=nullptr) | |
Constructor, with the store to use for access. Does not take ownership. | |
DataSyncSettingsAccessor (QtDataSync::DataTypeStore< DataSyncSettingsEntry > *store, QObject *parent=nullptr) | |
Constructor, with the store to use for access. Does not take ownership. | |
bool | contains (const QString &key) const override |
Checks if a value is stored for the given key. More... | |
QVariant | load (const QString &key, const QVariant &defaultValue) const override |
Loads the value for the given key from the settings. More... | |
void | save (const QString &key, const QVariant &value) override |
Stores the given value under the given key in the settings. More... | |
void | remove (const QString &key) override |
Removes the key and all its subkeys from the settings. More... | |
Public Member Functions inherited from QtMvvm::ISettingsAccessor | |
ISettingsAccessor (QObject *parent=nullptr) | |
Constructor. | |
Public Member Functions inherited from QObject | |
virtual const QMetaObject * | metaObject () const const |
virtual void * | qt_metacast (const char *) |
virtual int | qt_metacall (QMetaObject::Call, int, void **) |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Additional Inherited Members | |
Signals inherited from QtMvvm::ISettingsAccessor | |
void | entryChanged (const QString &key, const QVariant &value) |
Is emitted whenever a settings value was changed, at least via this instance. | |
void | entryRemoved (const QString &key) |
Is emitted whenever a settings value was removed, at least via this instance. | |
Static Public Member Functions inherited from QtMvvm::ISettingsAccessor | |
template<typename T > | |
static void | setDefaultAccessor () |
static void | setDefaultAccessor (int typeId) |
static ISettingsAccessor * | createDefaultAccessor (QObject *parent=nullptr) |
Create a new instance of the default accessor type. More... | |
Static Public Member Functions inherited from QObject | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
Protected Member Functions inherited from QObject | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
Properties inherited from QObject | |
objectName | |
A settings accessor implementation that allows to store and sync settings via datasync.
The data is stored by using the DataSyncSettingsEntry class to wrap the key value pairs into a serializable datatype.
Definition at line 15 of file datasyncsettingsaccessor.h.
|
overridevirtual |
Checks if a value is stored for the given key.
key | The key of the settings entry to be checked for existance |
This should only check for values, not for groups, i.e. if key referes to a group that has child keys, but no value by itself, you should still return false.
Implements QtMvvm::ISettingsAccessor.
|
overridevirtual |
Loads the value for the given key from the settings.
key | The key of the settings entry to be loaded |
defaultValue | A alternative value to be returned if there is no data stored for that key |
If the given value does exist, it should be loaded and returned. If the is on data stored for that key, simply return whatever is passed as the default value.
Implements QtMvvm::ISettingsAccessor.
|
overridevirtual |
Removes the key and all its subkeys from the settings.
key | The key of the settings entry to be removed |
This method should remove the given key and all of its subkeys. If for example the settings contained the values group/subgroup
and group/subgroup/key
, after this method, both must have been removed. Permanent storing is done asynchronously, but can be forced via sync().
Any implementation of this method must emit the entryRemoved() signal for all the removed entries. I.e. for the example above, it must be emitted for both, group/subgroup
and group/subgroup/key
.
Implements QtMvvm::ISettingsAccessor.
|
overridevirtual |
Stores the given value under the given key in the settings.
key | The key of the settings entry to be saved |
value | The data to be stored under that key |
Should simply store the passed data under the given key. You dont have to check if the variant is actually serializable, as the meta system will automatically warn the user if thats not the case. Permanent storing is done asynchronously, but can be forced via sync().
Any implementation of this method must emit the entryChanged() signal with the passed data and key.
Implements QtMvvm::ISettingsAccessor.
|
overrideslot |
Synchronizes the settings to the disk or whatever is needed to permanently store them.
You can call this method to immediatly store any changed data to permanent store. This exists because typically, calls to save() and remove() only "cache" the changes, and then later write them to the permanent store in a single transaction, as this can be an expensive operation. Normally, you don't have to care about this, as this happens automatically, but sometimes you might want to manually perform this step. Thats what this method is for.