So far, the method had a weld:::TreeView* out param
and a bool return value, which indicated whether
or not a selected item actually exists (and was
set in the passed TreeIter).
Drop the method param and instead return a
std::unique_ptr<weld::TreeIter>. If it doesn't
own a pointer, there is no selection (i.e. the
case previously indicated by a `false` return
value). If it owns a weld::TreeIter, then
that one points to the (first) selected item.
This simplifies using this as it is no longer
necessary to separately create weld::TreeIter to
pass as an out param first, e.g.
std::unique_ptr<weld::TreeIter> pEntry = rMyIconView.make_iterator());
if (rMyIconView.get_selected(xEntry.get()))
{
// do sth
}
now turns into
if (std::unique_ptr<weld::TreeIter> xEntry = rMyIconView->get_selected())
{
// do sth
}
Adjust all callers accordingly.
It might be worth looking into doing something
similar for other methods (e.g.
weld::ItemView::get_iter_first) as well.
Change-Id: I83146fc8d68a92d50eed9bd635bf91b1450ce495
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196039
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>