mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Add insert to C++ VecModel
This commit is contained in:
parent
480c7c6d30
commit
43830ccd78
2 changed files with 11 additions and 2 deletions
|
@ -25,7 +25,8 @@ All notable changes to this project will be documented in this file.
|
||||||
- Math functions `log`, and `pow`
|
- Math functions `log`, and `pow`
|
||||||
- Property animations now have a `delay` property, which will delay the start
|
- Property animations now have a `delay` property, which will delay the start
|
||||||
of the animation.
|
of the animation.
|
||||||
- `sixtyfps::VecModel` in Rust now has an `insert(index, value)` function.
|
- Rust: Added `sixtyfps::VecModel::insert(&self, index, value)`.
|
||||||
|
- C++: Added `sixtyfps::VecModel::insert(index, value)`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -595,6 +595,13 @@ public:
|
||||||
data.erase(data.begin() + index);
|
data.erase(data.begin() + index);
|
||||||
this->row_removed(index, 1);
|
this->row_removed(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Inserts the given value as a new row at the specified index
|
||||||
|
void insert(size_t index, const ModelData &value)
|
||||||
|
{
|
||||||
|
data.insert(data.begin() + index, value);
|
||||||
|
this->row_added(int(index), 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace private_api {
|
namespace private_api {
|
||||||
|
@ -700,7 +707,8 @@ public:
|
||||||
for (std::size_t i = 0; i < inner->data.size(); ++i) {
|
for (std::size_t i = 0; i < inner->data.size(); ++i) {
|
||||||
int index = order == TraversalOrder::BackToFront ? i : inner->data.size() - 1 - i;
|
int index = order == TraversalOrder::BackToFront ? i : inner->data.size() - 1 - i;
|
||||||
auto ref = item_at(index);
|
auto ref = item_at(index);
|
||||||
if (ref.vtable->visit_children_item(ref, -1, order, visitor) != std::numeric_limits<uint64_t>::max()) {
|
if (ref.vtable->visit_children_item(ref, -1, order, visitor)
|
||||||
|
!= std::numeric_limits<uint64_t>::max()) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue