Component: Replace parent_item to parent_node

Remove the `parent_item` function. After the recent changes that did not
return an item anymore and since the item tree is exposed, this function
was only used to find the repeater a component was created by.

So replace the old function with a new one that only returns the parent
node in the parent component.

This saves a few lines of generated code that is not used anymore.

Co-authored-by: Simon Hausmann <hausmann@gmail.com>
This commit is contained in:
Tobias Hunger 2022-04-08 16:46:17 +02:00 committed by Tobias Hunger
parent ca5bfd3426
commit 416aa42d90
6 changed files with 49 additions and 84 deletions

View file

@ -1031,7 +1031,7 @@ fn generate_item_tree(
.upgrade()
.map(|sc| (VRcMapped::origin(&sc), sc.tree_index_of_first_child.get()))
{
*result = slint::re_exports::ItemRc::new(parent_component, parent_index as usize + #sub_component_offset - 1)
*_result = slint::re_exports::ItemRc::new(parent_component, parent_index as usize + #sub_component_offset - 1)
.downgrade();
})
})
@ -1178,14 +1178,8 @@ fn generate_item_tree(
self.index_property()
}
fn parent_item(self: ::core::pin::Pin<&Self>, index: usize, result: &mut slint::re_exports::ItemWeak) {
if index == 0 {
#parent_item_expression
return;
}
let parent_index = self.get_item_tree().as_slice()[index].parent_index();
let self_rc = slint::re_exports::VRcMapped::origin(&self.self_weak.get().unwrap().upgrade().unwrap());
*result = ItemRc::new(self_rc, parent_index).downgrade();
fn parent_node(self: ::core::pin::Pin<&Self>, _result: &mut slint::re_exports::ItemWeak) {
#parent_item_expression
}
fn layout_info(self: ::core::pin::Pin<&Self>, orientation: slint::re_exports::Orientation) -> slint::re_exports::LayoutInfo {