Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkDataStorageTreeModelInternalItem Class Reference

Helper class representing a node in a tree structure of DataNodes. More...

#include <QmitkDataStorageTreeModelInternalItem.h>

Collaboration diagram for QmitkDataStorageTreeModelInternalItem:

Public Member Functions

 QmitkDataStorageTreeModelInternalItem (mitk::DataNode *_DataNode, QmitkDataStorageTreeModelInternalItem *_Parent=nullptr)
 Constructs a tree item for the given DataNode. More...
 
virtual ~QmitkDataStorageTreeModelInternalItem ()
 Destructor. Removes this item from its parent's child list. More...
 
int IndexOfChild (const QmitkDataStorageTreeModelInternalItem *item) const
 Returns the index of the given child item. More...
 
QmitkDataStorageTreeModelInternalItem * GetChild (int index) const
 Returns the child item at the given index. More...
 
QmitkDataStorageTreeModelInternalItem * Find (const mitk::DataNode *_DataNode) const
 Recursively searches for the item holding the given DataNode. More...
 
int GetChildCount () const
 Returns the number of child items. More...
 
int GetIndex () const
 Returns the index of this item within its parent's child list. More...
 
QmitkDataStorageTreeModelInternalItem * GetParent () const
 Returns the parent item. More...
 
mitk::DataNode::Pointer GetDataNode () const
 Returns the DataNode associated with this tree item. More...
 
std::vector< QmitkDataStorageTreeModelInternalItem * > GetChildren () const
 Returns all child items as a vector. More...
 
void AddChild (QmitkDataStorageTreeModelInternalItem *item)
 Adds the given item as a child (if not already present). More...
 
void RemoveChild (QmitkDataStorageTreeModelInternalItem *item)
 Removes the given item from this item's child list. More...
 
void InsertChild (QmitkDataStorageTreeModelInternalItem *item, int index=-1)
 Inserts a child item at the given position. More...
 
void SetParent (QmitkDataStorageTreeModelInternalItem *_Parent)
 Sets the parent of this item. More...
 
void Delete ()
 Recursively deletes this item and all its children. More...
 

Protected Attributes

QmitkDataStorageTreeModelInternalItem * m_Parent
 
std::vector< QmitkDataStorageTreeModelInternalItem * > m_Children
 
mitk::WeakPointer< mitk::DataNode > m_DataNode
 

Detailed Description

Helper class representing a node in a tree structure of DataNodes.

This class is used internally by QmitkDataStorageTreeModel and QmitkDataStorageSimpleTreeModel to build an in-memory tree hierarchy that mirrors the parent-child relationships in the DataStorage. Each item holds a weak pointer to a mitk::DataNode and references to its parent and children.

See also
QmitkDataStorageTreeModel
QmitkDataStorageSimpleTreeModel

Definition at line 35 of file QmitkDataStorageTreeModelInternalItem.h.

Constructor & Destructor Documentation

◆ QmitkDataStorageTreeModelInternalItem()

QmitkDataStorageTreeModelInternalItem::QmitkDataStorageTreeModelInternalItem ( mitk::DataNode *  _DataNode,
QmitkDataStorageTreeModelInternalItem *  _Parent = nullptr 
)

Constructs a tree item for the given DataNode.

Parameters
[in]_DataNodeThe data node to associate with this item. Must not be nullptr.
[in]_ParentOptional parent item. Defaults to nullptr (root item).

◆ ~QmitkDataStorageTreeModelInternalItem()

virtual QmitkDataStorageTreeModelInternalItem::~QmitkDataStorageTreeModelInternalItem ( )
virtual

Destructor. Removes this item from its parent's child list.

Note
Does not delete child items. Use Delete() to recursively remove an entire branch.
See also
Delete

Member Function Documentation

◆ AddChild()

void QmitkDataStorageTreeModelInternalItem::AddChild ( QmitkDataStorageTreeModelInternalItem *  item)

Adds the given item as a child (if not already present).

Parameters
[in]itemThe item to add as a child.

◆ Delete()

void QmitkDataStorageTreeModelInternalItem::Delete ( )

Recursively deletes this item and all its children.

◆ Find()

QmitkDataStorageTreeModelInternalItem* QmitkDataStorageTreeModelInternalItem::Find ( const mitk::DataNode *  _DataNode) const

Recursively searches for the item holding the given DataNode.

Parameters
[in]_DataNodeThe data node to search for.
Returns
Pointer to the matching item, or nullptr if not found.

◆ GetChild()

QmitkDataStorageTreeModelInternalItem* QmitkDataStorageTreeModelInternalItem::GetChild ( int  index) const

Returns the child item at the given index.

Parameters
[in]indexThe zero-based child index.
Returns
Pointer to the child item, or nullptr if the index is out of range.

◆ GetChildCount()

int QmitkDataStorageTreeModelInternalItem::GetChildCount ( ) const

Returns the number of child items.

Returns
The child count.

◆ GetChildren()

std::vector<QmitkDataStorageTreeModelInternalItem *> QmitkDataStorageTreeModelInternalItem::GetChildren ( ) const

Returns all child items as a vector.

Returns
A vector of pointers to child items.

◆ GetDataNode()

mitk::DataNode::Pointer QmitkDataStorageTreeModelInternalItem::GetDataNode ( ) const

Returns the DataNode associated with this tree item.

Returns
A smart pointer to the data node.

◆ GetIndex()

int QmitkDataStorageTreeModelInternalItem::GetIndex ( ) const

Returns the index of this item within its parent's child list.

Returns
The zero-based index, or -1 if this item has no parent.

◆ GetParent()

QmitkDataStorageTreeModelInternalItem* QmitkDataStorageTreeModelInternalItem::GetParent ( ) const

Returns the parent item.

Returns
Pointer to the parent item, or nullptr for root items.

◆ IndexOfChild()

int QmitkDataStorageTreeModelInternalItem::IndexOfChild ( const QmitkDataStorageTreeModelInternalItem *  item) const

Returns the index of the given child item.

Parameters
[in]itemThe child item to find.
Returns
The zero-based index, or -1 if the item is not a child.

◆ InsertChild()

void QmitkDataStorageTreeModelInternalItem::InsertChild ( QmitkDataStorageTreeModelInternalItem *  item,
int  index = -1 
)

Inserts a child item at the given position.

If index is out of range (or -1), the item is appended at the end.

Parameters
[in]itemThe item to insert.
[in]indexThe position at which to insert. Defaults to -1 (append).

◆ RemoveChild()

void QmitkDataStorageTreeModelInternalItem::RemoveChild ( QmitkDataStorageTreeModelInternalItem *  item)

Removes the given item from this item's child list.

Parameters
[in]itemThe child item to remove.

◆ SetParent()

void QmitkDataStorageTreeModelInternalItem::SetParent ( QmitkDataStorageTreeModelInternalItem *  _Parent)

Sets the parent of this item.

Parameters
[in]_ParentThe new parent item.

Member Data Documentation

◆ m_Children

std::vector<QmitkDataStorageTreeModelInternalItem *> QmitkDataStorageTreeModelInternalItem::m_Children
protected

Definition at line 138 of file QmitkDataStorageTreeModelInternalItem.h.

◆ m_DataNode

mitk::WeakPointer<mitk::DataNode> QmitkDataStorageTreeModelInternalItem::m_DataNode
protected

Definition at line 139 of file QmitkDataStorageTreeModelInternalItem.h.

◆ m_Parent

QmitkDataStorageTreeModelInternalItem* QmitkDataStorageTreeModelInternalItem::m_Parent
protected

Definition at line 137 of file QmitkDataStorageTreeModelInternalItem.h.


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