29 const auto& childIdx = Model_->index (row, 0, SrcIdx_);
30 Children_ [row] = std::make_shared<ModelItem> (Model_, childIdx, shared_from_this ());
41 if (SrcIdx_.isValid ())
42 SrcIdx_ = Model_->index (
GetRow () - modelStartingRow, 0,
Parent_.lock ()->GetIndex ());
52 index = index.sibling (index.row (), 0);
55 [&index] (
const ModelItem_ptr& item) { return item->GetIndex () == index; });
Base class for model items for tree-like models.
Provides a proxying API on top of an QAbstractItemModel.
ModelItem * EnsureChild(int row)
Ensures there is a child item at the given row.
QAbstractItemModel * GetModel() const
Returns the wrapped model.
ModelItem()=default
Constructs a default (invalid) ModelItem having no model set.
void RefreshIndex(int modelStartingRow)
Updates the wrapped index so that it points at the given row.
const QModelIndex & GetIndex() const
Returns the index this ModelItem instance wraps.
ModelItem_ptr FindChild(QModelIndex index) const
Finds a child item for the given index.
std::shared_ptr< ModelItem > ModelItem_ptr
std::weak_ptr< ModelItem > ModelItem_wtr