73 using T_ptr = std::shared_ptr<T>;
74 using T_cptr = std::shared_ptr<const T>;
274 template<
typename... Args>
277 Children_.append (std::make_shared<T> (std::forward<Args> (args)...));
295 template<
typename... Args>
298 Children_.insert (
pos, std::make_shared<T> (std::forward<Args> (args)...));
350 return parent->GetRow (this->shared_from_this ());
ModelItemBase(const T_wptr &parent)
Constructs a ModelItemBase with a given parent item.
detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, boost::mpl::int_< Idx > > pos
TList_t & GetChildren()
Returns a non-constant reference to the list of children.
std::weak_ptr< ModelItem > T_wptr
int GetRow() const
Returns the index of this item in the parent's children list.
iterator EraseChildren(iterator begin, iterator end)
Erases all child items in the given range.
int GetRow(const T_ptr &item) const
Returns the index of the item in the children list.
std::shared_ptr< const ModelItem > T_cptr
iterator end()
Returns a non-const iterator pointing past the last child item.
typename TList_t::iterator iterator
A non-const iterator for the list of children.
std::shared_ptr< ModelItem > T_ptr
int GetRowCount() const
Returns the children count.
int GetRow(const T_cptr &item) const
Returns the index of the item in the children list.
Base class for model items for tree-like models.
bool IsEmpty() const
Returns whether there are any children at all.
T_ptr & AppendChild(Args &&... args)
Creates a new child item, appends it and returns it.
ModelItemBase()=default
Constructs a default ModelItemBase with no parent.
iterator begin()
Returns a non-const iterator pointing to the beginning of the child items list.
const_iterator begin() const
Returns a const iterator pointing to the beginning of the child items list.
T_ptr GetParent() const
Returns the pointer to the parent item.
iterator EraseChild(iterator it)
Erases a child item at the position defined by it.
void AppendExisting(const T_ptr &t)
Appends a child item t to the list of child items.
T_ptr GetChild(int row) const
Returns a child at the given row.
const TList_t & GetChildren() const
Returns a constant reference to the list of children.
void AppendExisting(const TList_t &items)
Appends a list of items to the list of child items.
const_iterator end() const
Returns a const iterator pointing past the last child item.
T_ptr & InsertChild(int pos, Args &&... args)
Creates a new child item, inserts it at the given position and returns it.
typename TList_t::const_iterator const_iterator
A const iterator for the list of children.