1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 20:45:08 +00:00

FileManager: Make the tree view follow the directory view navigations.

This commit is contained in:
Andreas Kling 2019-03-30 03:27:25 +01:00
parent f10e0d0546
commit 2c6a597d77
10 changed files with 72 additions and 3 deletions

View file

@ -270,3 +270,32 @@ void GTreeView::paint_event(GPaintEvent& event)
return IterationDecision::Continue;
});
}
void GTreeView::scroll_into_view(const GModelIndex& a_index, Orientation orientation)
{
if (!a_index.is_valid())
return;
Rect found_rect;
traverse_in_paint_order([&] (const GModelIndex& index, const Rect& rect, int) {
if (index == a_index) {
found_rect = rect;
return IterationDecision::Abort;
}
return IterationDecision::Continue;
});
GScrollableWidget::scroll_into_view(found_rect, orientation);
}
void GTreeView::did_update_selection()
{
ASSERT(model());
auto& model = *this->model();
auto index = model.selected_index();
if (!index.is_valid())
return;
auto parent = index.parent();
while (parent.is_valid()) {
ensure_metadata_for_index(parent).open = true;
parent = parent.parent();
}
}