mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-27 20:42:25 +00:00
Ability to make change to the model property
This commit is contained in:
parent
2d01b92c84
commit
2050f08f1e
5 changed files with 130 additions and 20 deletions
|
@ -340,7 +340,10 @@ public:
|
|||
}
|
||||
int row_count() const override { return Count; }
|
||||
ModelData row_data(int i) const override { return data[i]; }
|
||||
void set_row_data(int i, const ModelData &value) override { data[i] = value; }
|
||||
void set_row_data(int i, const ModelData &value) override {
|
||||
data[i] = value;
|
||||
this->row_changed(i);
|
||||
}
|
||||
};
|
||||
|
||||
/// Model to be used when we just want to repeat without data.
|
||||
|
@ -472,6 +475,21 @@ public:
|
|||
x.ptr->compute_layout({ &C::component_type, x.ptr.get() });
|
||||
}
|
||||
}
|
||||
|
||||
void model_set_row_data(int row, const ModelData &data) const {
|
||||
if (model.is_dirty()) {
|
||||
std::abort();
|
||||
}
|
||||
if (auto m = model.get()) {
|
||||
m->set_row_data(row, data);
|
||||
if (inner && inner->is_dirty) {
|
||||
auto &c = inner->data[row];
|
||||
if (c.state == RepeaterInner::State::Dirty && c.ptr) {
|
||||
c.ptr->update_data(row, m->row_data(row));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Flickable::Flickable()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue