mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
FileManager: Add a columns view
This new view, backed by a GColumnsView, joins the existing table and icon views :^) Even though it displays a file tree, its data is provided by the very same GFileSystemModel that the other two views use. This commit also includes my attempt at making an icon for the new mode.
This commit is contained in:
parent
edb61d8bfd
commit
7bc8fa884a
4 changed files with 42 additions and 0 deletions
|
@ -89,12 +89,16 @@ DirectoryView::DirectoryView(GWidget* parent)
|
|||
m_item_view = GItemView::construct(this);
|
||||
m_item_view->set_model(model());
|
||||
|
||||
m_columns_view = GColumnsView::construct(this);
|
||||
m_columns_view->set_model(model());
|
||||
|
||||
m_table_view = GTableView::construct(this);
|
||||
m_table_view->set_model(GSortingProxyModel::create(m_model));
|
||||
|
||||
m_table_view->model()->set_key_column_and_sort_order(GFileSystemModel::Column::Name, GSortOrder::Ascending);
|
||||
|
||||
m_item_view->set_model_column(GFileSystemModel::Column::Name);
|
||||
m_columns_view->set_model_column(GFileSystemModel::Column::Name);
|
||||
|
||||
m_model->on_root_path_change = [this] {
|
||||
m_table_view->selection().clear();
|
||||
|
@ -122,6 +126,9 @@ DirectoryView::DirectoryView(GWidget* parent)
|
|||
m_item_view->on_activation = [&](const GModelIndex& index) {
|
||||
handle_activation(index);
|
||||
};
|
||||
m_columns_view->on_activation = [&](const GModelIndex& index) {
|
||||
handle_activation(index);
|
||||
};
|
||||
m_table_view->on_activation = [&](auto& index) {
|
||||
auto& filter_model = (GSortingProxyModel&)*m_table_view->model();
|
||||
handle_activation(filter_model.map_to_target(index));
|
||||
|
@ -137,6 +144,11 @@ DirectoryView::DirectoryView(GWidget* parent)
|
|||
if (on_selection_change)
|
||||
on_selection_change(*m_item_view);
|
||||
};
|
||||
m_columns_view->on_selection_change = [this] {
|
||||
update_statusbar();
|
||||
if (on_selection_change)
|
||||
on_selection_change(*m_columns_view);
|
||||
};
|
||||
|
||||
m_table_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||
if (on_context_menu_request)
|
||||
|
@ -146,6 +158,10 @@ DirectoryView::DirectoryView(GWidget* parent)
|
|||
if (on_context_menu_request)
|
||||
on_context_menu_request(*m_item_view, index, event);
|
||||
};
|
||||
m_columns_view->on_context_menu_request = [this](auto& index, auto& event) {
|
||||
if (on_context_menu_request)
|
||||
on_context_menu_request(*m_columns_view, index, event);
|
||||
};
|
||||
|
||||
set_view_mode(ViewMode::Icon);
|
||||
}
|
||||
|
@ -164,6 +180,10 @@ void DirectoryView::set_view_mode(ViewMode mode)
|
|||
set_active_widget(m_table_view);
|
||||
return;
|
||||
}
|
||||
if (mode == ViewMode::Columns) {
|
||||
set_active_widget(m_columns_view);
|
||||
return;
|
||||
}
|
||||
if (mode == ViewMode::Icon) {
|
||||
set_active_widget(m_item_view);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue