mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 20:31:27 +00:00
C++: add a Model::row_data_tracked function
This commit is contained in:
parent
fd44b2e651
commit
2f67564ea9
1 changed files with 9 additions and 2 deletions
|
|
@ -527,8 +527,7 @@ using ModelPeer = std::weak_ptr<AbstractRepeaterView>;
|
|||
template<typename M>
|
||||
auto access_array_index(const M &model, int index)
|
||||
{
|
||||
model->track_row_data_changes(index);
|
||||
if (const auto v = model->row_data(index)) {
|
||||
if (const auto v = model->row_data_tracked(index)) {
|
||||
return *v;
|
||||
} else {
|
||||
return decltype(*v) {};
|
||||
|
|
@ -589,6 +588,14 @@ public:
|
|||
model_row_data_dirty_property.get();
|
||||
}
|
||||
|
||||
/// \private
|
||||
/// Convenience function that calls `track_row_data_changes` before returning `row_data`
|
||||
std::optional<ModelData> row_data_tracked(int row) const
|
||||
{
|
||||
const_cast<Model *>(this)->track_row_data_changes(row);
|
||||
return row_data(row);
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Notify the views that a specific row was changed
|
||||
void row_changed(int row)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue