C++: put a pointer to the parent in the component

This commit is contained in:
Olivier Goffart 2020-06-29 10:11:08 +02:00
parent f35c12aef1
commit 967a2b94eb
2 changed files with 22 additions and 7 deletions

View file

@ -119,12 +119,14 @@ template<typename C>
struct Repeater {
std::vector<std::unique_ptr<C>> data;
void update_model(Model *model)
template<typename Parent>
void update_model(Model *model, Parent *parent)
{
data.clear();
auto count = model->count();
for (auto i = 0; i < count; ++i) {
auto x = std::make_unique<C>();
x->parent = parent;
x->update_data(i, model->get(i));
data.push_back(std::move(x));
}