OGS
|
TreeModelIterator provides a way to iterate over TreeItems in a TreeModel. Usage:
Definition at line 34 of file TreeModelIterator.h.
#include <TreeModelIterator.h>
Public Member Functions | |
TreeModelIterator (TreeModel *model) | |
Constructor. Provide a tree model to iterate over. | |
TreeItem * | operator* () const |
Dereferencing the iterator to retrieve the current TreeItem. Returns nullptr if the iterator is at the end. | |
TreeModelIterator & | operator++ () |
Advance the iterator to the next TreeItem. | |
Private Member Functions | |
TreeItem * | next (const TreeItem *current) |
The traversal implementation. | |
Private Attributes | |
TreeItem * | _current |
The current TreeItem. | |
int | _currentIndex |
The current child index. | |
QStack< int > | _parentIndex |
Stack to save the child indices of the parent TreeItems. | |
TreeModel * | _model |
The model to iterate over. | |
|
explicit |
Constructor. Provide a tree model to iterate over.
Definition at line 21 of file TreeModelIterator.cpp.
References _model, TreeItem::childCount(), and TreeModel::rootItem().
The traversal implementation.
Definition at line 45 of file TreeModelIterator.cpp.
References _currentIndex, _model, _parentIndex, TreeItem::child(), TreeItem::childCount(), next(), TreeItem::parentItem(), and TreeModel::rootItem().
Referenced by next(), and operator++().
TreeItem * TreeModelIterator::operator* | ( | ) | const |
Dereferencing the iterator to retrieve the current TreeItem. Returns nullptr if the iterator is at the end.
Definition at line 30 of file TreeModelIterator.cpp.
References _current.
TreeModelIterator & TreeModelIterator::operator++ | ( | ) |
|
private |
The current TreeItem.
Definition at line 49 of file TreeModelIterator.h.
Referenced by operator*(), and operator++().
|
private |
|
private |
The model to iterate over.
Definition at line 58 of file TreeModelIterator.h.
Referenced by TreeModelIterator(), and next().
|
private |
Stack to save the child indices of the parent TreeItems.
Definition at line 55 of file TreeModelIterator.h.
Referenced by next().