90 Q_INVOKABLE
bool has(const QString& key) const;
101 Q_INVOKABLE QVariant
get(const QString& key) const;
109 Q_INVOKABLE QVariantList
keys() const;
123 Q_INVOKABLE QString
toJSON() const;
132 void itemChanged(const QString key, QVariant value);
153 void set(const QString& key, const QJsonValue& value);
166 bool setMap(QVariantMap map);
187 bool remove(const QString& key);
205 void loadJSON(const QString& jsonString);
270 bool setValue(QVariantMap& map, const QString& key, QVariant value,
bool emitSignal=false);
297 #endif // ZScopedMap_H bool isValidType(const QJsonValue &value)
Test if a value has a type that can be stored in the scope.
ZScopedMap(QObject *parent=0)
QVariantMap m_map
A dictionary of scoped objects.
#define ZBL_DECLARE_LOGGED_OBJECT
int size
The number of items in the map.
QObject outerScope
The number of items in the map.
const QString initializer
A JSON string containing initial key/value pairs for this scope.
int getSize() const
Obtain number of items in the map.
bool setMap(QVariantMap map)
Inserts a set of key/value pairs into the map. Existing values are overwritten.
ZBL_DECLARE_LOGGED_OBJECT QString getInitializer() const
Return the JSON string used to initialize this object.
bool setScopedMap(QObject *map)
Inserts a set of key/value pairs into the map. Existing values are overwritten.
Q_INVOKABLE QVariantList keys() const
Obtain the key names in the map.
void set(const QString &key, const QJsonValue &value)
Sets the specified key in the map to the specified value. Existing values are overwritten.
ZScopedMap * m_outerScope
The scope enclosing this scope, or null if this is outermost scope.
QObject * getOuterScope()
Get the enclosing scope. May be null if this is outermost scope.
Q_INVOKABLE bool has(const QString &key) const
Returns true if the map contains the specified key.
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.
void loadJSON(const QString &jsonString)
Parses the supplied JSON string and writes the contained key/value pairs to the map.
Q_INVOKABLE void invalidate()
Issue a scopeChanged signal. All clients should query their values.
QString m_JSON
JSON string used to initialize this scope.
void clear()
Remove all key/value pairs from the map.
void itemChanged(const QString key, QVariant value)
void mapChanged(QVariantMap newValues)
A hierarchical map object for creating scopes.
Q_INVOKABLE QString toJSON() const
Obtain a JSON string representation of the map.
Q_INVOKABLE QVariant get(const QString &key) const
Returns the value associated with a specified key in the map.
static void registerType()
Register ZMailbox as a QML type.
bool remove(const QString &key)
Removes the specified key from the map.
void setOuterScope(QObject *outerScope)
Set the enclosing scope to which unresolved name lookups will be forwarded.