From a5d7ea24e906a8a7efd764585152dd8734e66ba5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Feb 2020 20:50:21 +0100 Subject: LibGUI: Use MultiView in FilePicker This allows the user to switch between different view modes. Fixes #1283. --- Libraries/LibGUI/FilePicker.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'Libraries/LibGUI/FilePicker.cpp') diff --git a/Libraries/LibGUI/FilePicker.cpp b/Libraries/LibGUI/FilePicker.cpp index 008e8c53b5..6cacd95d73 100644 --- a/Libraries/LibGUI/FilePicker.cpp +++ b/Libraries/LibGUI/FilePicker.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -98,15 +99,16 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView& auto toolbar = upper_container->add(); toolbar->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); - toolbar->set_preferred_size(85, 0); + toolbar->set_preferred_size(165, 0); toolbar->set_has_frame(false); auto location_textbox = upper_container->add(); location_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); location_textbox->set_preferred_size(0, 20); - m_view = vertical_container->add(); + m_view = vertical_container->add(); m_view->set_model(SortingProxyModel::create(*m_model)); + m_view->set_model_column(FileSystemModel::Column::Name); m_view->set_column_hidden(FileSystemModel::Column::Owner, true); m_view->set_column_hidden(FileSystemModel::Column::Group, true); m_view->set_column_hidden(FileSystemModel::Column::Permissions, true); @@ -146,8 +148,19 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView& } } }); + toolbar->add_action(*mkdir_action); + toolbar->add_separator(); + + toolbar->add_action(m_view->view_as_icons_action()); + toolbar->add_action(m_view->view_as_table_action()); + + // FIXME: Enable this once GUI::ColumnsView doesn't crash when used here. +#if 0 + toolbar->add_action(m_view->view_as_columns_action()); +#endif + auto lower_container = vertical_container->add(); lower_container->set_layout(make()); lower_container->layout()->set_spacing(4); @@ -172,7 +185,8 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView& on_file_return(); }; - m_view->on_selection = [this](auto& index) { + m_view->on_selection_change = [this] { + auto index = m_view->selection().first(); auto& filter_model = (SortingProxyModel&)*m_view->model(); auto local_index = filter_model.map_to_target(index); const FileSystemModel::Node& node = m_model->node(local_index); -- cgit v1.2.3