WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. | Zuble QML Types | Zuble C++ Classes | Zuble Overview |
Zuble
0.1
Zuble Framework C++/QML extension API
|
A hierarchical map object for creating scopes. More...
#include <ZScopedMap.h>
Public Slots | |
void | set (const QString &key, const QJsonValue &value) |
Sets the specified key in the map to the specified value. Existing values are overwritten. More... | |
bool | setMap (QVariantMap map) |
Inserts a set of key/value pairs into the map. Existing values are overwritten. More... | |
bool | setScopedMap (QObject *map) |
Inserts a set of key/value pairs into the map. Existing values are overwritten. More... | |
bool | remove (const QString &key) |
Removes the specified key from the map. More... | |
void | clear () |
Remove all key/value pairs from the map. More... | |
void | loadJSON (const QString &jsonString) |
Parses the supplied JSON string and writes the contained key/value pairs to the map. More... | |
Signals | |
void | itemChanged (const QString key, QVariant value) |
void | mapChanged (QVariantMap newValues) |
void | reset () |
Public Member Functions | |
ZScopedMap (QObject *parent=0) | |
int | getSize () const |
Obtain number of items in the map. More... | |
Q_INVOKABLE bool | has (const QString &key) const |
Returns true if the map contains the specified key. More... | |
Q_INVOKABLE QVariant | get (const QString &key) const |
Returns the value associated with a specified key in the map. More... | |
Q_INVOKABLE QVariantList | keys () const |
Obtain the key names in the map. More... | |
Q_INVOKABLE void | invalidate () |
Issue a scopeChanged signal. All clients should query their values. More... | |
Q_INVOKABLE QString | toJSON () const |
Obtain a JSON string representation of the map. More... | |
Static Public Member Functions | |
static void | registerType () |
Register ZMailbox as a QML type. More... | |
Protected Member Functions | |
ZBL_DECLARE_LOGGED_OBJECT QString | getInitializer () const |
Return the JSON string used to initialize this object. More... | |
void | setOuterScope (QObject *outerScope) |
Set the enclosing scope to which unresolved name lookups will be forwarded. More... | |
QObject * | getOuterScope () |
Get the enclosing scope. May be null if this is outermost scope. More... | |
bool | isValidType (const QJsonValue &value) |
Test if a value has a type that can be stored in the scope. More... | |
bool | isValidType (const QVariant &value) |
Test if a value has a type that can be stored in the scope. More... | |
bool | setValue (QVariantMap &map, const QString &key, QVariant value, bool emitSignal=false) |
Sets the specified key in the map to the specified value. Existing values are overwritten. More... | |
Protected Attributes | |
ZScopedMap * | m_outerScope |
The scope enclosing this scope, or null if this is outermost scope. More... | |
QVariantMap | m_map |
A dictionary of scoped objects. More... | |
QString | m_JSON |
JSON string used to initialize this scope. More... | |
Properties | |
int | size |
The number of items in the map. More... | |
QObject | outerScope |
The number of items in the map. More... | |
const QString | initializer |
A JSON string containing initial key/value pairs for this scope. More... | |
A hierarchical map object for creating scopes.
This class contains a map of named items. It also may optionally hold a reference to an outer scope. When an outer scope is present name lookups that can't be resolved within this scope are forwarded to the outer scope.
Items in the scope can be modified individually, such that a change notification is issued for each item that changed, or in a batch mode where multiple items can be changed in a single function call and a single notification is issued containing a map of all changed items when the batch is complete.
If this scope has an outer scope it listens for change notifications from the outer scope and propagates those notifications to current listeners only if the names can't be resolved in this scope.
This algorithm allows items defined in this scope to mask items of the same name in ancestor scopes and for listeners of this scope to receive only relevant notifications from ancestor scopes.
Zuble uses this mechanism to define and propagate UI style information.
Definition at line 36 of file ZScopedMap.h.
|
explicit |
Definition at line 34 of file ZScopedMap.cpp.
|
slot |
Remove all key/value pairs from the map.
Definition at line 232 of file ZScopedMap.cpp.
QVariant Zbl::ZScopedMap::get | ( | const QString & | key | ) | const |
Returns the value associated with a specified key in the map.
key | Key for which a value will be obtained |
Definition at line 162 of file ZScopedMap.cpp.
Referenced by get().
|
protected |
Return the JSON string used to initialize this object.
Definition at line 143 of file ZScopedMap.cpp.
|
protected |
Get the enclosing scope. May be null if this is outermost scope.
Definition at line 70 of file ZScopedMap.cpp.
int Zbl::ZScopedMap::getSize | ( | ) | const |
Obtain number of items in the map.
Definition at line 149 of file ZScopedMap.cpp.
bool Zbl::ZScopedMap::has | ( | const QString & | key | ) | const |
Returns true if the map contains the specified key.
key | The key to test |
Definition at line 154 of file ZScopedMap.cpp.
Referenced by has().
void Zbl::ZScopedMap::invalidate | ( | ) |
Issue a scopeChanged signal. All clients should query their values.
Definition at line 323 of file ZScopedMap.cpp.
|
protected |
Test if a value has a type that can be stored in the scope.
value | The value to test |
Definition at line 237 of file ZScopedMap.cpp.
Referenced by loadJSON(), set(), and setMap().
|
protected |
Test if a value has a type that can be stored in the scope.
value | The value to test |
Definition at line 255 of file ZScopedMap.cpp.
|
signal |
Referenced by setValue().
QVariantList Zbl::ZScopedMap::keys | ( | ) | const |
Obtain the key names in the map.
Definition at line 207 of file ZScopedMap.cpp.
|
slot |
Parses the supplied JSON string and writes the contained key/value pairs to the map.
Existing values are overwritten.
jsonString | A JSON string containing key/value pairs to be written |
Definition at line 75 of file ZScopedMap.cpp.
|
signal |
Referenced by setMap().
|
static |
Register ZMailbox as a QML type.
Definition at line 39 of file ZScopedMap.cpp.
Referenced by Zbl::Zblcore::registerTypes().
|
slot |
Removes the specified key from the map.
key | The key that will be removed. |
Definition at line 202 of file ZScopedMap.cpp.
|
signal |
Referenced by invalidate(), and setOuterScope().
|
slot |
Sets the specified key in the map to the specified value. Existing values are overwritten.
Any previous value for the specified key will be overwritten with the new value. An itemChanged will be issued after the value is changed.
key | The key for which a value will be set |
value | The value to set in the map. |
Definition at line 172 of file ZScopedMap.cpp.
|
slot |
Inserts a set of key/value pairs into the map. Existing values are overwritten.
This method allows use of native javascript objects to set values in the map. A mapChanged signal will be issued after the values are inserted.
map | a QVariantMap containg the values to insert. |
Definition at line 277 of file ZScopedMap.cpp.
Referenced by setScopedMap().
|
protected |
Set the enclosing scope to which unresolved name lookups will be forwarded.
outerScope | A ZScopedMap object |
Definition at line 46 of file ZScopedMap.cpp.
|
slot |
Inserts a set of key/value pairs into the map. Existing values are overwritten.
A mapChanged signal will be issued after the values are inserted.
map | a ZScopedMap object containg the values to insert. |
Definition at line 309 of file ZScopedMap.cpp.
|
protected |
Sets the specified key in the map to the specified value. Existing values are overwritten.
Any previous value for the specified key will be overwritten with the new value.
The value will NOT be wrtten if it was already set to the same value or if it was an invalid data type.
key | The key for which a value will be set |
value | The value to set in the map. |
Definition at line 182 of file ZScopedMap.cpp.
QString Zbl::ZScopedMap::toJSON | ( | ) | const |
Obtain a JSON string representation of the map.
Definition at line 130 of file ZScopedMap.cpp.
|
protected |
JSON string used to initialize this scope.
Definition at line 290 of file ZScopedMap.h.
Referenced by getInitializer(), and loadJSON().
|
protected |
A dictionary of scoped objects.
Definition at line 284 of file ZScopedMap.h.
Referenced by clear(), get(), getSize(), has(), keys(), loadJSON(), remove(), set(), setMap(), setScopedMap(), setValue(), and toJSON().
|
protected |
The scope enclosing this scope, or null if this is outermost scope.
Definition at line 278 of file ZScopedMap.h.
Referenced by get(), getOuterScope(), has(), and setOuterScope().
|
readwrite |
A JSON string containing initial key/value pairs for this scope.
This optional JSON init string is parsed at object creation time and its key/value pairs are added to the scope.
Definition at line 69 of file ZScopedMap.h.
|
readwrite |
The number of items in the map.
Definition at line 60 of file ZScopedMap.h.
Referenced by setOuterScope().
|
read |
The number of items in the map.
Definition at line 54 of file ZScopedMap.h.
Zuble documentation copyright © 2019 Bob Dinitto. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Zuble is a derivative work of Qt version 5. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.