JsonTreeModel Implementation
v0.1.0
A Qt tree model for visualizing and manipulating a JSON document.
|
JsonTreeModelNamedListNode represents a JSON object. More...
#include <jsontreemodel.h>
Public Member Functions | |
JsonTreeModelNamedListNode (const QJsonObject &object, JsonTreeModelNode *parent) | |
Constructs a node under the specified parent to represent the specified JSON object. More... | |
QString | childListNodeName (JsonTreeModelNode *child) const |
int | namedScalarCount () const |
Returns the number of scalar elements within this node. More... | |
QJsonValue | namedScalarValue (const QString &name) const |
Returns the scalar element in this node which has the given name. More... | |
void | setNamedScalarValue (const QString &name, const QJsonValue &value) |
Adds or updates a scalar element of the JSON object represented by this node. More... | |
Type | type () const override |
Returns JsonTreeModelNode::Object. More... | |
QJsonValue | value () const override |
Returns the JSON object represented by this node. More... | |
![]() | |
JsonTreeModelListNode (JsonTreeModelNode *parent) | |
Constructs an empty JsonTreeModelListNode under the specified parent. More... | |
JsonTreeModelListNode (const QJsonArray &array, JsonTreeModelNode *parent) | |
Constructs a node under the specified parent to represent the specified JSON array. More... | |
~JsonTreeModelListNode () override | |
JsonTreeModelNode * | childAt (int i) const |
Returns the child node at index i. More... | |
int | childCount () const |
Returns the number of child nodes under this row. More... | |
int | childPosition (JsonTreeModelNode *child) const |
Returns index number of the specified child, or -1 if the child does not belong to this node. More... | |
![]() | |
JsonTreeModelNode (JsonTreeModelNode *parent) | |
Constructs a new node with the given parent. More... | |
virtual | ~JsonTreeModelNode () |
Frees the memory held by this node and its children. More... | |
JsonTreeModelNode * | parent () const |
Returns this node's parent. More... | |
void | setParent (JsonTreeModelNode *parent) |
Makes this node a child of parent. More... | |
Additional Inherited Members | |
![]() | |
enum | Type { Scalar, Object, Array } |
This enum describes the type of data represented by a JsonTreeModelNode. More... | |
![]() | |
void | registerChild (JsonTreeModelNode *child) |
Puts the child node under this node's hierarchy. More... | |
void | deregisterChild (JsonTreeModelNode *child) |
Removes the child node from this node's hierarchy. More... | |
JsonTreeModelNamedListNode represents a JSON object.
Scalar members of this node appear in named scalar columns in the JsonTreeModel.
Non-scalar members of this node (arrays and objects) appear as child rows in the JsonTreeModel.
If this node represents a top-level object of a JSON document and it contains scalar members, then this node must be wrapped in a JsonTreeModelWrapperNode.
JsonTreeModelNamedListNode::JsonTreeModelNamedListNode | ( | const QJsonObject & | object, |
JsonTreeModelNode * | parent | ||
) |
Constructs a node under the specified parent to represent the specified JSON object.
|
inline |
|
inline |
Returns the number of scalar elements within this node.
In the JsonTreeModel, these are the elements that appear under the model's scalar columns.
|
inline |
Returns the scalar element in this node which has the given name.
If the underlying JSON object has no member with the given name (or if the member is non-scalar), this function returns an undefined QJsonValue.
|
inline |
Adds or updates a scalar element of the JSON object represented by this node.
|
inlineoverridevirtual |
Returns JsonTreeModelNode::Object.
Reimplemented from JsonTreeModelListNode.
|
overridevirtual |
Returns the JSON object represented by this node.
Reimplemented from JsonTreeModelListNode.