50 using T_ptr = std::shared_ptr<T>;
51 using T_cptr = std::shared_ptr<const T>;
251 template<
typename...
Args>
254 Children_.append (std::make_shared<T> (std::forward<Args> (
args)...));
272 template<
typename...
Args>
Base class for model items for tree-like models.
iterator EraseChildren(iterator begin, iterator end)
Erases all child items in the given range.
int GetRow(const T_cptr &item) const
Returns the index of the item in the children list.
std::shared_ptr< T > T_ptr
T_ptr GetChild(int row) const
Returns a child at the given row.
int GetRow() const
Returns the index of this item in the parent's children list.
T_ptr GetParent() const
Returns the pointer to the parent item.
ModelItemBase(const T_wptr &parent)
Constructs a ModelItemBase with a given parent item.
iterator end()
Returns a non-const iterator pointing past the last child item.
bool IsEmpty() const
Returns whether there are any children at all.
std::shared_ptr< const T > T_cptr
typename TList_t::iterator iterator
A non-const iterator for the list of children.
ModelItemBase()=default
Constructs a default ModelItemBase with no parent.
TList_t & GetChildren()
Returns a non-constant reference to the list of children.
typename TList_t::const_iterator const_iterator
A const iterator for the list of children.
iterator EraseChild(iterator it)
Erases a child item at the position defined by it.
T_ptr & InsertChild(int pos, Args &&... args)
Creates a new child item, inserts it at the given position and returns it.
int GetRow(const T_ptr &item) const
Returns the index of the item in the children list.
void AppendExisting(const T_ptr &t)
Appends a child item t to the list of child items.
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.
std::weak_ptr< T > T_wptr
int GetRowCount() const
Returns the children count.
T_ptr & AppendChild(Args &&... args)
Creates a new child item, appends it and returns it.
const_iterator end() const
Returns a const iterator pointing past the last child item.
void AppendExisting(const TList_t &items)
Appends a list of items to the list of child items.
const TList_t & GetChildren() const
Returns a constant reference to the list of children.
Container< T > Filter(const Container< T > &c, F f)