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