Description
Feature Description
Slicing is well known from other languages, to get a specific range of items of a list. For example in Python:
my_data = ["foo", "bar", "hello", "world"]
first_half = my_data[:2]
second_half = my_data[2:]
middle = my_data[1:3]
It would be awesome if this was possible in Slint too. An example use-case could be a tab bar where only the first N elements are shown as tabs and the rest is moved into a context menu. Or a notification area where only the first N messages are visible and the rest are collapsed or so. For those use-cases it would actually be great if the slices can be made of dynamic properties, not just hardcoded numbers. E.g.:
property <[string]> my-data: ["foo", "bar", "hello", "world"];
property <int> visible-elements: min(my-data.length, root.height / 20px);
MyListView {
model: my-data[:visible-elements];
}
MyCollapsible {
MyListView {
model: my-data[visible-elements:];
}
}
Related to #1328 because basically it is a filter model, but the specialized syntax would be much more convenient than a .filter()
call for this basic use-case.
Product Impact
Not critical at all, just would have been convenient a few times.