![]() |
LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
Provides a proxying API on top of an QAbstractItemModel. More...
#include "modelitem.h"
Public Types | |
typedef ModelItemsList_t::iterator | iterator |
typedef ModelItemsList_t::const_iterator | const_iterator |
![]() | |
using | iterator = typename TList_t::iterator |
A non-const iterator for the list of children. More... | |
using | const_iterator = typename TList_t::const_iterator |
A const iterator for the list of children. More... | |
Public Member Functions | |
ModelItem ()=default | |
Constructs a default (invalid) ModelItem having no model set. More... | |
ModelItem (QAbstractItemModel *model, const QModelIndex &index, const ModelItem_wtr &parent) | |
Constructs a ModelItem associated with a given index in the model. More... | |
ModelItem * | EnsureChild (int row) |
Ensures there is a child item at the given row. More... | |
const QModelIndex & | GetIndex () const |
Returns the index this ModelItem instance wraps. More... | |
QAbstractItemModel * | GetModel () const |
Returns the wrapped model. More... | |
void | RefreshIndex (int modelStartingRow) |
Updates the wrapped index so that it points at the given row. More... | |
ModelItem_ptr | FindChild (QModelIndex index) const |
Finds a child item for the given index. More... | |
![]() | |
iterator | begin () |
Returns a non-const iterator pointing to the beginning of the child items list. More... | |
const_iterator | begin () const |
Returns a const iterator pointing to the beginning of the child items list. More... | |
iterator | end () |
Returns a non-const iterator pointing past the last child item. More... | |
const_iterator | end () const |
Returns a const iterator pointing past the last child item. More... | |
T_ptr | GetChild (int row) const |
Returns a child at the given row. More... | |
const TList_t & | GetChildren () const |
Returns a constant reference to the list of children. More... | |
TList_t & | GetChildren () |
Returns a non-constant reference to the list of children. More... | |
int | GetRowCount () const |
Returns the children count. More... | |
bool | IsEmpty () const |
Returns whether there are any children at all. More... | |
iterator | EraseChild (iterator it) |
Erases a child item at the position defined by it. More... | |
iterator | EraseChildren (iterator begin, iterator end) |
Erases all child items in the given range. More... | |
void | AppendExisting (const T_ptr &t) |
Appends a child item t to the list of child items. More... | |
void | AppendExisting (const TList_t &items) |
Appends a list of items to the list of child items. More... | |
T_ptr & | AppendChild (Args &&... args) |
Creates a new child item, appends it and returns it. More... | |
T_ptr & | InsertChild (int pos, Args &&... args) |
Creates a new child item, inserts it at the given position and returns it. More... | |
T_ptr | GetParent () const |
Returns the pointer to the parent item. More... | |
int | GetRow (const T_ptr &item) const |
Returns the index of the item in the children list. More... | |
int | GetRow (const T_cptr &item) const |
Returns the index of the item in the children list. More... | |
int | GetRow () const |
Returns the index of this item in the parent's children list. More... | |
Additional Inherited Members | |
![]() | |
using | T_wptr = std::weak_ptr< ModelItem > |
using | T_ptr = std::shared_ptr< ModelItem > |
using | T_cptr = std::shared_ptr< const ModelItem > |
using | TList_t = QVector< T_ptr > |
![]() | |
ModelItemBase ()=default | |
Constructs a default ModelItemBase with no parent. More... | |
ModelItemBase (const T_wptr &parent) | |
Constructs a ModelItemBase with a given parent item. More... | |
![]() | |
T_wptr | Parent_ |
TList_t | Children_ |
Provides a proxying API on top of an QAbstractItemModel.
This class simplifies writing wrappers around QAbstractItemModel classes representing the data in different means than Qt's MVC.
Definition at line 37 of file modelitem.h.
typedef ModelItemsList_t::const_iterator LC::Util::ModelItem::const_iterator |
Definition at line 43 of file modelitem.h.
typedef ModelItemsList_t::iterator LC::Util::ModelItem::iterator |
Definition at line 42 of file modelitem.h.
|
default |
Constructs a default (invalid) ModelItem having no model set.
LC::Util::ModelItem::ModelItem | ( | QAbstractItemModel * | model, |
const QModelIndex & | index, | ||
const ModelItem_wtr & | parent | ||
) |
Constructs a ModelItem associated with a given index in the model.
[in] | model | The model which this model item wraps. |
[in] | index | The source index in this model. |
[in] | parent | The parent ModelItem, or an empty pointer if this is the root item. |
Definition at line 20 of file modelitem.cpp.
References LC::Util::ModelItemBase< ModelItem >::Children_.
ModelItem * LC::Util::ModelItem::EnsureChild | ( | int | row | ) |
Ensures there is a child item at the given row.
If necessary, this function expands the list of children until there is a given row.
If no model item has been set for the given row, this function creates a proper ModelItem.
[in] | row | The row for which to obtain a child item. |
Definition at line 27 of file modelitem.cpp.
ModelItem_ptr LC::Util::ModelItem::FindChild | ( | QModelIndex | index | ) | const |
Finds a child item for the given index.
The index is assumed to be the child of the one wrapped by this ModelItem.
[in] | index | The index (a child of the one returned by GetIndex()) for which a child model item should be found. |
Definition at line 56 of file modelitem.cpp.
const QModelIndex & LC::Util::ModelItem::GetIndex | ( | ) | const |
Returns the index this ModelItem instance wraps.
Definition at line 40 of file modelitem.cpp.
References LC::Util::ModelItemBase< ModelItem >::GetRow(), and LC::Util::ModelItemBase< ModelItem >::Parent_.
QAbstractItemModel * LC::Util::ModelItem::GetModel | ( | ) | const |
Returns the wrapped model.
Definition at line 51 of file modelitem.cpp.
References LC::Util::ModelItemBase< ModelItem >::Children_.
void LC::Util::ModelItem::RefreshIndex | ( | int | modelStartingRow | ) |
Updates the wrapped index so that it points at the given row.
Calling this function on a ModelItem wrapping the root of the underlying model (that is, constructed by the parameterless constructor) leads to undefined behavior.
[in] | modelStartingRow | The new row (among the children of this item's wrapped index) in the model this item should represent. |
Definition at line 45 of file modelitem.cpp.