mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 23:27:22 +00:00
Change Model::row_data to return an Option<T> (#873)
Change Model::row_data to return an Option<T> (rust) or std::optional<T> (c++) Co-authored-by: Olivier Goffart <olivier@woboq.com> Co-authored-by: Simon Hausmann <hausmann@gmail.com>
This commit is contained in:
parent
e2ec76f9ef
commit
e3c4209b1f
24 changed files with 229 additions and 102 deletions
|
@ -15,8 +15,8 @@ int main()
|
|||
std::vector<TileData> new_tiles;
|
||||
new_tiles.reserve(old_tiles->row_count() * 2);
|
||||
for (int i = 0; i < old_tiles->row_count(); ++i) {
|
||||
new_tiles.push_back(old_tiles->row_data(i));
|
||||
new_tiles.push_back(old_tiles->row_data(i));
|
||||
new_tiles.push_back(*old_tiles->row_data(i));
|
||||
new_tiles.push_back(*old_tiles->row_data(i));
|
||||
}
|
||||
std::default_random_engine rng {};
|
||||
std::shuffle(new_tiles.begin(), new_tiles.end(), rng);
|
||||
|
@ -33,7 +33,7 @@ int main()
|
|||
int first_visible_index = -1;
|
||||
TileData first_visible_tile;
|
||||
for (int i = 0; i < tiles_model->row_count(); ++i) {
|
||||
auto tile = tiles_model->row_data(i);
|
||||
auto tile = *tiles_model->row_data(i);
|
||||
if (!tile.image_visible || tile.solved)
|
||||
continue;
|
||||
if (first_visible_index == -1) {
|
||||
|
|
|
@ -16,8 +16,8 @@ int main()
|
|||
std::vector<TileData> new_tiles;
|
||||
new_tiles.reserve(old_tiles->row_count() * 2);
|
||||
for (int i = 0; i < old_tiles->row_count(); ++i) {
|
||||
new_tiles.push_back(old_tiles->row_data(i));
|
||||
new_tiles.push_back(old_tiles->row_data(i));
|
||||
new_tiles.push_back(*old_tiles->row_data(i));
|
||||
new_tiles.push_back(*old_tiles->row_data(i));
|
||||
}
|
||||
std::default_random_engine rng {};
|
||||
std::shuffle(new_tiles.begin(), new_tiles.end(), rng);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue