JsonTreeModel Implementation  v0.1.0
A Qt tree model for visualizing and manipulating a JSON document.
JsonTreeModelListNode Class Reference

JsonTreeModelListNode represents a JSON structure (namely an array or an object) and provides the backbone of the tree model. More...

#include <jsontreemodel.h>

Inheritance diagram for JsonTreeModelListNode:
JsonTreeModelNode JsonTreeModelNamedListNode JsonTreeModelWrapperNode

Public Member Functions

 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
 
JsonTreeModelNodechildAt (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...
 
Type type () const override
 Returns JsonTreeModelNode::Array. More...
 
QJsonValue value () const override
 Returns the JSON structure (array or object) represented by this node. More...
 
- Public Member Functions inherited from JsonTreeModelNode
 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...
 
JsonTreeModelNodeparent () const
 Returns this node's parent. More...
 
void setParent (JsonTreeModelNode *parent)
 Makes this node a child of parent. More...
 

Protected Member Functions

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...
 

Additional Inherited Members

- Public Types inherited from JsonTreeModelNode
enum  Type { Scalar, Object, Array }
 This enum describes the type of data represented by a JsonTreeModelNode. More...
 

Detailed Description

JsonTreeModelListNode represents a JSON structure (namely an array or an object) and provides the backbone of the tree model.

This class can have children. Child nodes manifest as child rows in the JsonTreeModel.

JSON objects are best represented as a JsonTreeModelNamedListNode.

Constructor & Destructor Documentation

◆ JsonTreeModelListNode() [1/2]

JsonTreeModelListNode::JsonTreeModelListNode ( JsonTreeModelNode parent)
inline

Constructs an empty JsonTreeModelListNode under the specified parent.

The new node can be populated later.

◆ JsonTreeModelListNode() [2/2]

JsonTreeModelListNode::JsonTreeModelListNode ( const QJsonArray &  array,
JsonTreeModelNode parent 
)

Constructs a node under the specified parent to represent the specified JSON array.

All array elements will be placed within child nodes and registered.

◆ ~JsonTreeModelListNode()

JsonTreeModelListNode::~JsonTreeModelListNode ( )
inlineoverride

Member Function Documentation

◆ childAt()

JsonTreeModelNode * JsonTreeModelListNode::childAt ( int  i) const
inline

Returns the child node at index i.

Warning
The caller must ensure that 0 <= i < childCount()
See also
childPosition()

◆ childCount()

int JsonTreeModelListNode::childCount ( ) const
inline

Returns the number of child nodes under this row.

This is equivalent to the number of rows in the JsonTreeModel where this node is the parent QModelIndex.

◆ childPosition()

int JsonTreeModelListNode::childPosition ( JsonTreeModelNode child) const
inline

Returns index number of the specified child, or -1 if the child does not belong to this node.

See also
childAt()

◆ deregisterChild()

void JsonTreeModelListNode::deregisterChild ( JsonTreeModelNode child)
protected

Removes the child node from this node's hierarchy.

Note
Only the child's parent can call this function

◆ registerChild()

void JsonTreeModelListNode::registerChild ( JsonTreeModelNode child)
protected

Puts the child node under this node's hierarchy.

Note
Only the child's parent can call this function

◆ type()

Type JsonTreeModelListNode::type ( ) const
inlineoverridevirtual

◆ value()

QJsonValue JsonTreeModelListNode::value ( ) const
overridevirtual

Returns the JSON structure (array or object) represented by this node.

Implements JsonTreeModelNode.

Reimplemented in JsonTreeModelWrapperNode, and JsonTreeModelNamedListNode.


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