QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
Signals | Public Member Functions | Properties | List of all members
de::skycoder42::QtDataSync::DataStore Class Reference

The QML binding of QtDataSync::DataStore. More...

#include <qqmldatastore.h>

+ Inheritance diagram for de::skycoder42::QtDataSync::DataStore:

Signals

void setupNameChanged (const QString &setupName)
 NOTIFY accessor for AccountManager::setupName.
 
void validChanged (bool valid)
 NOTIFY accessor for AccountManager::valid.
 
- Signals inherited from QtDataSync::DataStore
void dataChanged (int metaTypeId, const QString &key, bool deleted, QPrivateSignal)
 Is emitted whenever a dataset has been changed. More...
 
Q_DECL_DEPRECATED void dataCleared (int metaTypeId, QPrivateSignal)
 Is emitted when a datatypes has been cleared. More...
 
void dataResetted (QPrivateSignal)
 Is emitted when the store is resetted due to an account reset. More...
 

Public Member Functions

Q_INVOKABLE qint64 count (const QString &typeName) const
 Counts the number of datasets for the given type. More...
 
Q_INVOKABLE QStringList keys (const QString &typeName) const
 Returns all saved keys for the given type. More...
 
Q_INVOKABLE QVariantList loadAll (const QString &typeName) const
 Loads all existing datasets for the given type. More...
 
Q_INVOKABLE QT_DATASYNC_REVISION_2 bool contains (const QString &typeName, const QString &key) const
 Checks if a dataset exists in the store for the given key. More...
 
Q_INVOKABLE QVariant load (const QString &typeName, const QString &key) const
 Loads the dataset with the given key for the given type. More...
 
Q_INVOKABLE void save (const QString &typeName, const QVariant &value)
 Saves the given dataset in the store. More...
 
Q_INVOKABLE bool remove (const QString &typeName, const QString &key)
 Removes the dataset with the given key for the given type. More...
 
Q_INVOKABLE QVariantList search (const QString &typeName, const QString &query, DataStore::SearchMode mode=DataStore::RegexpMode) const
 Searches the store for datasets of the given type where the key matches the query. More...
 
Q_INVOKABLE void clear (const QString &typeName)
 Removes all datasets of the given type from the store. More...
 
Q_INVOKABLE QString typeName (int typeId) const
 Returns the name of the type identified by the given type id. More...
 
- Public Member Functions inherited from QtDataSync::DataStore
 DataStore (QObject *parent=nullptr)
 Default constructor, uses the default setup. More...
 
 DataStore (const QString &setupName, QObject *parent=nullptr)
 Constructor with an explicit setup. More...
 
QString setupName () const
 Returns the name of the setup this class operates on. More...
 
qint64 count (int metaTypeId) const
 Counts the number of datasets for the given type. More...
 
QStringList keys (int metaTypeId) const
 Returns all saved keys for the given type. More...
 
QVariantList loadAll (int metaTypeId) const
 Loads all existing datasets for the given type. More...
 
bool contains (int metaTypeId, const QString &key) const
 Checks if a dataset exists in the store for the given key. More...
 
bool contains (int metaTypeId, const QVariant &key) const
 Checks if a dataset exists in the store for the given key. More...
 
QVariant load (int metaTypeId, const QString &key) const
 Loads the dataset with the given key for the given type. More...
 
QVariant load (int metaTypeId, const QVariant &key) const
 Loads the dataset with the given key for the given type. More...
 
void save (int metaTypeId, QVariant value)
 Saves the given dataset in the store. More...
 
bool remove (int metaTypeId, const QString &key)
 Removes the dataset with the given key for the given type. More...
 
bool remove (int metaTypeId, const QVariant &key)
 Removes the dataset with the given key for the given type. More...
 
void update (int metaTypeId, QObject *object) const
 Loads the dataset with the given key for the given type into the existing object by updating it's properties. More...
 
QVariantList search (int metaTypeId, const QString &query, SearchMode mode=RegexpMode) const
 Searches the store for datasets of the given type where the key matches the query. More...
 
void iterate (int metaTypeId, const std::function< bool(QVariant)> &iterator) const
 Iterates over all existing datasets of the given types. More...
 
void iterate (int metaTypeId, const std::function< bool(QVariant)> &iterator, bool skipBroken) const
 Iterates over all existing datasets of the given types. More...
 
void clear (int metaTypeId)
 Removes all datasets of the given type from the store. More...
 
template<typename T >
quint64 count () const
 Counts the number of datasets for the given type. More...
 
template<typename T >
QStringList keys () const
 Returns all saved keys for the given type. More...
 
template<typename T , typename K >
QList< K > keys () const
 Returns all saved keys for the given type. More...
 
template<typename T >
QList< T > loadAll () const
 Loads all existing datasets for the given type. More...
 
template<typename T >
bool contains (const QString &key) const
 Checks if a dataset exists in the store for the given key. More...
 
template<typename T , typename K >
bool contains (const K &key) const
 Checks if a dataset exists in the store for the given key. More...
 
template<typename T >
load (const QString &key) const
 Loads the dataset with the given key for the given type. More...
 
template<typename T , typename K >
load (const K &key) const
 Loads the dataset with the given key for the given type. More...
 
template<typename T >
void save (const T &value)
 Saves the given dataset in the store. More...
 
template<typename T >
bool remove (const QString &key)
 Removes the dataset with the given key for the given type. More...
 
template<typename T , typename K >
bool remove (const K &key)
 Removes the dataset with the given key for the given type. More...
 
template<typename T >
void update (T object) const
 Loads the dataset with the given key for the given type into the existing object by updating it's properties. More...
 
template<typename T >
QList< T > search (const QString &query, SearchMode mode=RegexpMode) const
 Searches the store for datasets of the given type where the key matches the query. More...
 
template<typename T >
void iterate (const std::function< bool(T)> &iterator, bool skipBroken=false) const
 Iterates over all existing datasets of the given types. More...
 
template<typename T >
void clear ()
 Removes all datasets of the given type from the store. More...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () 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)
 
QThreadthread () 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)
 
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 &regExp, 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< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 

Properties

QString setupName
 Holds the name of the setup this store operates on. More...
 
bool valid
 Specifies if the object was correctly initialized. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Types inherited from QtDataSync::DataStore
enum  SearchMode {
  RegexpMode, WildcardMode, ContainsMode, StartsWithMode,
  EndsWithMode
}
 Possible pattern modes for the search mechanism. 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
QObjectsender () 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)
 

Detailed Description

The QML binding of QtDataSync::DataStore.

Since
4.0
See also
QtDataSync::DataStore

Definition at line 19 of file qqmldatastore.h.

Member Function Documentation

◆ clear()

Q_INVOKABLE void de::skycoder42::QtDataSync::DataStore::clear ( const QString typeName)

Removes all datasets of the given type from the store.

Parameters
typeNameThe QMetaType type name of the type
See also
QtDataSync::DataStore::clear(int)

◆ contains()

Q_INVOKABLE QT_DATASYNC_REVISION_2 bool de::skycoder42::QtDataSync::DataStore::contains ( const QString typeName,
const QString key 
) const

Checks if a dataset exists in the store for the given key.

Parameters
typeNameThe QMetaType type name of the type
keyThe key of the dataset to be checked for existance
Returns
true if the dataset exists, false if not
See also
QtDataSync::DataStore::contains(int, const QString &) const

◆ count()

Q_INVOKABLE qint64 de::skycoder42::QtDataSync::DataStore::count ( const QString typeName) const

Counts the number of datasets for the given type.

Parameters
typeNameThe QMetaType type name of the type
Returns
The number of datasets of the given type stored
See also
QtDataSync::DataStore::count(int) const

◆ keys()

Q_INVOKABLE QStringList de::skycoder42::QtDataSync::DataStore::keys ( const QString typeName) const

Returns all saved keys for the given type.

Parameters
typeNameThe QMetaType type name of the type
Returns
A list of all keys stored for the given type
See also
QtDataSync::DataStore::keys(int) const

◆ load()

Q_INVOKABLE QVariant de::skycoder42::QtDataSync::DataStore::load ( const QString typeName,
const QString key 
) const

Loads the dataset with the given key for the given type.

Parameters
typeNameThe QMetaType type name of the type
keyThe key of the dataset to be loaded
Returns
The dataset that was found for the given type and key
See also
QtDataSync::DataStore::load(int, const QString &) const

◆ loadAll()

Q_INVOKABLE QVariantList de::skycoder42::QtDataSync::DataStore::loadAll ( const QString typeName) const

Loads all existing datasets for the given type.

Parameters
typeNameThe QMetaType type name of the type
Returns
A list of all datasets stored for the given type
See also
QtDataSync::DataStore::loadAll(int) const

◆ remove()

Q_INVOKABLE bool de::skycoder42::QtDataSync::DataStore::remove ( const QString typeName,
const QString key 
)

Removes the dataset with the given key for the given type.

Parameters
typeNameThe QMetaType type name of the type
keyThe key of the dataset to be removed
Returns
true in case the dataset was removed, false if it did not exist
See also
QtDataSync::DataStore::remove(int, const QString &)

◆ save()

Q_INVOKABLE void de::skycoder42::QtDataSync::DataStore::save ( const QString typeName,
const QVariant value 
)

Saves the given dataset in the store.

Parameters
typeNameThe QMetaType type name of the type
valueThe dataset to be stored
See also
QtDataSync::DataStore::save(int, QVariant)

◆ search()

Q_INVOKABLE QVariantList de::skycoder42::QtDataSync::DataStore::search ( const QString typeName,
const QString query,
DataStore::SearchMode  mode = DataStore::RegexpMode 
) const

Searches the store for datasets of the given type where the key matches the query.

Parameters
typeNameThe QMetaType type name of the type
queryA search query to be used to find fitting datasets. Format depends on mode
modeSpecifies how to interpret the search query See DataStore::SearchMode documentation
Returns
A list with all datasets that keys matched the search query for the given type
See also
QtDataSync::DataStore::search(int, const QString &, DataStore::SearchMode) const

◆ typeName()

Q_INVOKABLE QString de::skycoder42::QtDataSync::DataStore::typeName ( int  typeId) const

Returns the name of the type identified by the given type id.

Parameters
typeIdThe QMetaType type id of the type
Returns
The type name of the type

Property Documentation

◆ setupName

QString de::skycoder42::QtDataSync::DataStore::setupName
readwrite

Holds the name of the setup this store operates on.

Default: QtDataSync::DefaultSetup

Allows you to specify the name of the setup that this store should use

Warning
This property must only ever be set on construction of the object and must not be changed afterwards
Accessors
MEMBERsetupName
NOTIFYsetupNameChanged()
See also
QtDataSync::DataStore::setupName, DataStore::valid

Definition at line 46 of file qqmldatastore.h.

◆ valid

bool de::skycoder42::QtDataSync::DataStore::valid
read

Specifies if the object was correctly initialized.

Default: false

Only becomes true if the given setup name resolves to a valid datasync instance or if the given node is valid

Accessors
MEMBERvalid
NOTIFYvalidChanged()
READ ONLY
See also
DataStore::setupName

Definition at line 62 of file qqmldatastore.h.


The documentation for this class was generated from the following file: