OGS
TreeModelIterator.h
Go to the documentation of this file.
1
15#pragma once
16
17// ** INCLUDES **
18#include <QStack>
19
20class TreeModel;
21class TreeItem;
22
35{
36public:
38 explicit TreeModelIterator(TreeModel* model);
39
42 TreeItem* operator* () const;
43
46
47private:
50
53
55 QStack<int> _parentIndex;
56
59
61 TreeItem* next(const TreeItem* current);
62};
Objects nodes for the TreeModel.
Definition TreeItem.h:28
TreeModelIterator provides a way to iterate over TreeItems in a TreeModel. Usage:
TreeItem * next(const TreeItem *current)
The traversal implementation.
TreeModelIterator(TreeModel *model)
Constructor. Provide a tree model to iterate over.
QStack< int > _parentIndex
Stack to save the child indices of the parent TreeItems.
TreeModel * _model
The model to iterate over.
TreeItem * operator*() const
Dereferencing the iterator to retrieve the current TreeItem. Returns nullptr if the iterator is at th...
int _currentIndex
The current child index.
TreeItem * _current
The current TreeItem.
TreeModelIterator & operator++()
Advance the iterator to the next TreeItem.
A hierarchical model for a tree implemented as a double-linked list.
Definition TreeModel.h:30