summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/FilePicker.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-24 20:50:21 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-24 20:50:21 +0100
commita5d7ea24e906a8a7efd764585152dd8734e66ba5 (patch)
tree11d63a372e16595a4701d31275586a5c5acbf0c2 /Libraries/LibGUI/FilePicker.cpp
parent1b2b35cc409525334b20339485486f7b7e4eda41 (diff)
downloadserenity-a5d7ea24e906a8a7efd764585152dd8734e66ba5.zip
LibGUI: Use MultiView in FilePicker
This allows the user to switch between different view modes. Fixes #1283.
Diffstat (limited to 'Libraries/LibGUI/FilePicker.cpp')
-rw-r--r--Libraries/LibGUI/FilePicker.cpp20
1 files changed, 17 insertions, 3 deletions
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 <LibGUI/InputBox.h>
#include <LibGUI/Label.h>
#include <LibGUI/MessageBox.h>
+#include <LibGUI/MultiView.h>
#include <LibGUI/SortingProxyModel.h>
#include <LibGUI/TextBox.h>
#include <LibGUI/ToolBar.h>
@@ -98,15 +99,16 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
auto toolbar = upper_container->add<ToolBar>();
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<TextBox>();
location_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
location_textbox->set_preferred_size(0, 20);
- m_view = vertical_container->add<TableView>();
+ m_view = vertical_container->add<MultiView>();
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<Widget>();
lower_container->set_layout(make<VerticalBoxLayout>());
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);