HAL
hal::BaseTreeItem Class Referenceabstract

(Future) Base class for all tree models related to the details widget. More...

#include <base_tree_item.h>

Inheritance diagram for hal::BaseTreeItem:
Inheritance graph
Collaboration diagram for hal::BaseTreeItem:
Collaboration graph

Public Member Functions

 BaseTreeItem ()
 
 BaseTreeItem (QList< QVariant > columnData)
 
virtual ~BaseTreeItem ()
 
virtual QVariant getData (int column) const =0
 
virtual void setData (QList< QVariant > data)=0
 
virtual void setDataAtIndex (int index, QVariant &data)=0
 
virtual void appendData (QVariant data)=0
 
virtual BaseTreeItemgetParent () const
 
virtual void setParent (BaseTreeItem *parent)
 
virtual BaseTreeItemgetChild (int row) const
 
virtual QList< BaseTreeItem * > getChildren () const
 
virtual void appendChild (BaseTreeItem *child)
 
virtual void insertChild (int index, BaseTreeItem *child)
 
virtual BaseTreeItemremoveChildAtPos (int row)
 
virtual bool removeChild (BaseTreeItem *child)
 
virtual int getChildCount () const
 
virtual int getColumnCount () const =0
 
virtual int getRowForChild (const BaseTreeItem *child) const
 
virtual int getOwnRow ()
 

Protected Attributes

BaseTreeItemmParent
 
QList< BaseTreeItem * > mChildren
 

Detailed Description

(Future) Base class for all tree models related to the details widget.

This class functions as a generic data container for all tree models.

Definition at line 40 of file base_tree_item.h.

Constructor & Destructor Documentation

◆ BaseTreeItem() [1/2]

hal::BaseTreeItem::BaseTreeItem ( )

The constructor.

Definition at line 6 of file base_tree_item.cpp.

◆ BaseTreeItem() [2/2]

hal::BaseTreeItem::BaseTreeItem ( QList< QVariant columnData)

Second constructor to immediately assign column data.

Parameters
columnData- The item's data.

◆ ~BaseTreeItem()

hal::BaseTreeItem::~BaseTreeItem ( )
virtual

The destructor.

Definition at line 12 of file base_tree_item.cpp.

References mChildren.

Member Function Documentation

◆ appendChild()

◆ appendData()

virtual void hal::BaseTreeItem::appendData ( QVariant  data)
pure virtual

Appends a new column to the item.

Parameters
data- The data of the new column.

Implemented in hal::PortTreeItem, hal::PinTreeItem, hal::PinItem, hal::ModuleItem, hal::ContextTreeItem, and hal::RootTreeItem.

◆ getChild()

BaseTreeItem * hal::BaseTreeItem::getChild ( int  row) const
virtual

Get the child of a specific row.

Parameters
row- The requested row.
Returns
The child if within bounds. Nullptr otherwise.

Definition at line 29 of file base_tree_item.cpp.

References mChildren.

Referenced by hal::BaseTreeModel::index().

◆ getChildCount()

◆ getChildren()

◆ getColumnCount()

virtual int hal::BaseTreeItem::getColumnCount ( ) const
pure virtual

Get the number of currently stored column data.

Returns
The column count.

Implemented in hal::PortTreeItem, hal::PinTreeItem, hal::PinItem, hal::ModuleItem, hal::ContextTreeItem, and hal::RootTreeItem.

◆ getData()

virtual QVariant hal::BaseTreeItem::getData ( int  column) const
pure virtual

Get the data of a specific column (most in the form of a string).

Parameters
column- The requested column.
Returns
The data if within the column count. Empty QVariant otherwise.

Implemented in hal::PortTreeItem, hal::PinTreeItem, hal::PinItem, hal::ModuleItem, hal::ContextTreeItem, and hal::RootTreeItem.

Referenced by hal::BaseTreeModel::data().

◆ getOwnRow()

int hal::BaseTreeItem::getOwnRow ( )
virtual

Convenience method to get the row of this item within the parent's list. If the item has no parent, -1 is returned.

Returns
The row of this item if it has a parent, -1 otherwise.

Definition at line 94 of file base_tree_item.cpp.

References getRowForChild(), and mParent.

Referenced by hal::ModulePinsTreeModel::canDropMimeData(), hal::ModuleModel::removeChildItem(), and hal::ModuleModel::updateModuleParent().

◆ getParent()

◆ getRowForChild()

int hal::BaseTreeItem::getRowForChild ( const BaseTreeItem child) const
virtual

Convenience method to get the row for a given item. If the item is not a child of this item, -1 is returned.

Parameters
child- The child for which the row is requested.
Returns
The row if the item is a child, -1 otherwise.

Definition at line 80 of file base_tree_item.cpp.

References mChildren.

Referenced by hal::BaseTreeModel::getIndexFromItem(), getOwnRow(), hal::ContextTreeItem::row(), and hal::PinItem::row().

◆ insertChild()

void hal::BaseTreeItem::insertChild ( int  index,
BaseTreeItem child 
)
virtual

Inserts a child at the given index. If the index exceeds the amount of children, the new child is appended.

Parameters
index- The position at which to insert.
child- The child to insert.

Definition at line 45 of file base_tree_item.cpp.

References mChildren, and setParent().

Referenced by hal::BaseTreeModel::insertChildItem().

◆ removeChild()

bool hal::BaseTreeItem::removeChild ( BaseTreeItem child)
virtual

Removes the given item and returns True if removing was successful or False if the given item was no child.

Parameters
child- The child to remove.
Returns
True on success, False otherwise.

Definition at line 63 of file base_tree_item.cpp.

References mChildren.

Referenced by hal::PinModel::handleDeleteItem(), hal::ContextTreeModel::moveItem(), hal::ModuleModel::removeChildItem(), and hal::ModuleModel::updateModuleParent().

◆ removeChildAtPos()

BaseTreeItem * hal::BaseTreeItem::removeChildAtPos ( int  row)
virtual

Removes the child at the given row and returns it.

Parameters
row- The row from which to remove the child.
Returns
The removed child. Nullptr if row was out of bounds.

Definition at line 51 of file base_tree_item.cpp.

References mChildren.

Referenced by hal::BaseTreeModel::clear().

◆ setData()

virtual void hal::BaseTreeItem::setData ( QList< QVariant data)
pure virtual

Sets the data for all columns.

Parameters
data- Each entry in the list represents one column.

Implemented in hal::PortTreeItem, hal::PinTreeItem, hal::PinItem, hal::ModuleItem, hal::ContextTreeItem, and hal::RootTreeItem.

◆ setDataAtIndex()

virtual void hal::BaseTreeItem::setDataAtIndex ( int  index,
QVariant data 
)
pure virtual

Sets the data for a specified column. The index must be within already existing boundaries (for example, add dummy data beforehand).

Parameters
index- The column to set the new data.
data- The new column data.

Implemented in hal::PortTreeItem, hal::PinTreeItem, hal::PinItem, hal::ModuleItem, hal::ContextTreeItem, and hal::RootTreeItem.

◆ setParent()

void hal::BaseTreeItem::setParent ( BaseTreeItem parent)
virtual

Sets the item's parent.

Parameters
parent- The parent.

Definition at line 24 of file base_tree_item.cpp.

References mParent.

Referenced by appendChild(), hal::ModuleItem::appendExistingChildIfAny(), and insertChild().

Member Data Documentation

◆ mChildren

QList<BaseTreeItem*> hal::BaseTreeItem::mChildren
protected

◆ mParent

BaseTreeItem* hal::BaseTreeItem::mParent
protected

Definition at line 193 of file base_tree_item.h.

Referenced by getOwnRow(), getParent(), hal::ModuleItem::isToplevelItem(), and setParent().


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