Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
JsonTreeItem Class Reference

#include <jsontreeitem.h>

Collaboration diagram for JsonTreeItem:

Public Member Functions

 JsonTreeItem (const QVector< QVariant > &data, JsonTreeItem *parent=0)
 
 ~JsonTreeItem ()
 
JsonTreeItem * child (int number)
 
int childCount () const
 
int columnCount () const
 
QVariant data (int column) const
 
bool insertChildren (int position, int count, int columns)
 
bool insertColumns (int position, int columns)
 
JsonTreeItem * parent ()
 
bool removeChildren (int position, int count)
 
bool removeColumns (int position, int columns)
 
int childNumber () const
 
bool setData (int column, const QVariant &value)
 

Private Attributes

QList< JsonTreeItem * > childItems
 
QVector< QVariant > itemData
 
JsonTreeItem * parentItem
 

Detailed Description

Definition at line 8 of file jsontreeitem.h.

Constructor & Destructor Documentation

◆ JsonTreeItem()

JsonTreeItem::JsonTreeItem ( const QVector< QVariant > &  data,
JsonTreeItem *  parent = 0 
)

Definition at line 5 of file jsontreeitem.cpp.

6 {
8  itemData = data;
9 }

References data(), itemData, parent(), and parentItem.

Referenced by insertChildren().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~JsonTreeItem()

JsonTreeItem::~JsonTreeItem ( )

Definition at line 11 of file jsontreeitem.cpp.

12 {
13  qDeleteAll(childItems);
14 }

References childItems.

Member Function Documentation

◆ child()

JsonTreeItem * JsonTreeItem::child ( int  number)

Definition at line 16 of file jsontreeitem.cpp.

17 {
18  return childItems.value(number);
19 }

References childItems.

Referenced by JsonTreeModel::index(), insertColumns(), JsonEditorMain::on_Send_clicked(), removeColumns(), JsonTreeModel::setupModelData(), and JsonEditorMain::treeFormat().

Here is the caller graph for this function:

◆ childCount()

int JsonTreeItem::childCount ( ) const

Definition at line 21 of file jsontreeitem.cpp.

22 {
23  return childItems.count();
24 }

References childItems.

Referenced by JsonEditorMain::on_Send_clicked(), JsonTreeModel::rowCount(), JsonTreeModel::setupModelData(), and JsonEditorMain::treeFormat().

Here is the caller graph for this function:

◆ childNumber()

int JsonTreeItem::childNumber ( ) const

Definition at line 26 of file jsontreeitem.cpp.

27 {
28  if (parentItem)
29  return parentItem->childItems.indexOf(const_cast<JsonTreeItem*>(this));
30 
31  return 0;
32 }

References childItems, and parentItem.

Referenced by JsonTreeModel::parent().

Here is the caller graph for this function:

◆ columnCount()

int JsonTreeItem::columnCount ( ) const

Definition at line 34 of file jsontreeitem.cpp.

35 {
36  return itemData.count();
37 }

References itemData.

Referenced by JsonTreeModel::columnCount(), JsonTreeModel::insertRows(), JsonTreeModel::removeColumns(), and JsonTreeModel::setupModelData().

Here is the caller graph for this function:

◆ data()

QVariant JsonTreeItem::data ( int  column) const

Definition at line 39 of file jsontreeitem.cpp.

40 {
41  return itemData.value(column);
42 }

References itemData.

Referenced by JsonTreeModel::data(), JsonTreeModel::headerData(), insertChildren(), JsonTreeItem(), JsonEditorMain::on_Send_clicked(), and JsonEditorMain::treeFormat().

Here is the caller graph for this function:

◆ insertChildren()

bool JsonTreeItem::insertChildren ( int  position,
int  count,
int  columns 
)

Definition at line 44 of file jsontreeitem.cpp.

45 {
46  if (position < 0 || position > childItems.size())
47  return false;
48 
49  for (int row = 0; row < count; ++row) {
50  QVector<QVariant> data(columns);
51  JsonTreeItem *item = new JsonTreeItem(data, this);
52  childItems.insert(position, item);
53  }
54 
55  return true;
56 }

References childItems, data(), and JsonTreeItem().

Referenced by JsonTreeModel::insertRows(), and JsonTreeModel::setupModelData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertColumns()

bool JsonTreeItem::insertColumns ( int  position,
int  columns 
)

Definition at line 58 of file jsontreeitem.cpp.

59 {
60  if (position < 0 || position > itemData.size())
61  return false;
62 
63  for (int column = 0; column < columns; ++column)
64  itemData.insert(position, QVariant());
65 
66  foreach (JsonTreeItem *child, childItems)
67  child->insertColumns(position, columns);
68 
69  return true;
70 }

References child(), childItems, insertColumns(), and itemData.

Referenced by insertColumns(), and JsonTreeModel::insertColumns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parent()

JsonTreeItem * JsonTreeItem::parent ( )

Definition at line 72 of file jsontreeitem.cpp.

73 {
74  return parentItem;
75 }

References parentItem.

Referenced by JsonTreeItem(), and JsonTreeModel::parent().

Here is the caller graph for this function:

◆ removeChildren()

bool JsonTreeItem::removeChildren ( int  position,
int  count 
)

Definition at line 77 of file jsontreeitem.cpp.

78 {
79  if (position < 0 || position + count > childItems.size())
80  return false;
81 
82  for (int row = 0; row < count; ++row)
83  delete childItems.takeAt(position);
84 
85  return true;
86 }

References childItems.

Referenced by JsonTreeModel::removeRows().

Here is the caller graph for this function:

◆ removeColumns()

bool JsonTreeItem::removeColumns ( int  position,
int  columns 
)

Definition at line 88 of file jsontreeitem.cpp.

89 {
90  if (position < 0 || position + columns > itemData.size())
91  return false;
92 
93  for (int column = 0; column < columns; ++column)
94  itemData.remove(position);
95 
96  foreach (JsonTreeItem *child, childItems)
97  child->removeColumns(position, columns);
98 
99  return true;
100 }

References child(), childItems, itemData, and removeColumns().

Referenced by removeColumns(), and JsonTreeModel::removeColumns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setData()

bool JsonTreeItem::setData ( int  column,
const QVariant &  value 
)

Definition at line 102 of file jsontreeitem.cpp.

103 {
104  if (column < 0 || column >= itemData.size())
105  return false;
106 
107  itemData[column] = value;
108  return true;
109 }

References itemData.

Referenced by JsonTreeModel::setData(), JsonTreeModel::setHeaderData(), and JsonTreeModel::setupModelData().

Here is the caller graph for this function:

Member Data Documentation

◆ childItems

QList<JsonTreeItem*> JsonTreeItem::childItems
private

◆ itemData

QVector<QVariant> JsonTreeItem::itemData
private

Definition at line 28 of file jsontreeitem.h.

Referenced by columnCount(), data(), insertColumns(), JsonTreeItem(), removeColumns(), and setData().

◆ parentItem

JsonTreeItem* JsonTreeItem::parentItem
private

Definition at line 29 of file jsontreeitem.h.

Referenced by childNumber(), JsonTreeItem(), and parent().


The documentation for this class was generated from the following files:
JsonTreeItem::insertColumns
bool insertColumns(int position, int columns)
Definition: jsontreeitem.cpp:58
JsonTreeItem::removeColumns
bool removeColumns(int position, int columns)
Definition: jsontreeitem.cpp:88
JsonTreeItem::childItems
QList< JsonTreeItem * > childItems
Definition: jsontreeitem.h:27
JsonTreeItem::JsonTreeItem
JsonTreeItem(const QVector< QVariant > &data, JsonTreeItem *parent=0)
Definition: jsontreeitem.cpp:5
JsonTreeItem::parent
JsonTreeItem * parent()
Definition: jsontreeitem.cpp:72
JsonTreeItem::child
JsonTreeItem * child(int number)
Definition: jsontreeitem.cpp:16
JsonTreeItem::itemData
QVector< QVariant > itemData
Definition: jsontreeitem.h:28
JsonTreeItem::data
QVariant data(int column) const
Definition: jsontreeitem.cpp:39
JsonTreeItem::parentItem
JsonTreeItem * parentItem
Definition: jsontreeitem.h:29
JsonTreeItem
Definition: jsontreeitem.h:8