mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
FileManager: Teach DirectoryView subviews to create editing delegates
This enables inline editing of filenames for table views, where this is already supported. More work in LibGUI will be required to support the feature in icon and columns views.
This commit is contained in:
parent
701787b906
commit
7d30cf7122
Notes:
sideshowbarker
2024-07-19 02:15:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7d30cf71223
1 changed files with 18 additions and 1 deletions
|
@ -34,6 +34,7 @@
|
|||
#include <LibGUI/InputBox.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/ModelEditingDelegate.h>
|
||||
#include <LibGUI/SortingProxyModel.h>
|
||||
#include <serenity.h>
|
||||
#include <spawn.h>
|
||||
|
@ -202,6 +203,11 @@ void DirectoryView::setup_model()
|
|||
void DirectoryView::setup_icon_view()
|
||||
{
|
||||
m_icon_view = add<GUI::IconView>();
|
||||
m_icon_view->set_editable(true);
|
||||
m_icon_view->set_edit_triggers(GUI::AbstractView::EditTrigger::EditKeyPressed);
|
||||
m_icon_view->aid_create_editing_delegate = [](auto&) {
|
||||
return make<GUI::StringModelEditingDelegate>();
|
||||
};
|
||||
|
||||
if (is_desktop()) {
|
||||
m_icon_view->set_frame_shape(Gfx::FrameShape::NoFrame);
|
||||
|
@ -229,6 +235,12 @@ void DirectoryView::setup_icon_view()
|
|||
void DirectoryView::setup_columns_view()
|
||||
{
|
||||
m_columns_view = add<GUI::ColumnsView>();
|
||||
m_columns_view->set_editable(true);
|
||||
m_columns_view->set_edit_triggers(GUI::AbstractView::EditTrigger::EditKeyPressed);
|
||||
m_columns_view->aid_create_editing_delegate = [](auto&) {
|
||||
return make<GUI::StringModelEditingDelegate>();
|
||||
};
|
||||
|
||||
m_columns_view->set_model(m_sorting_model);
|
||||
m_columns_view->set_model_column(GUI::FileSystemModel::Column::Name);
|
||||
|
||||
|
@ -253,8 +265,13 @@ void DirectoryView::setup_columns_view()
|
|||
void DirectoryView::setup_table_view()
|
||||
{
|
||||
m_table_view = add<GUI::TableView>();
|
||||
m_table_view->set_model(m_sorting_model);
|
||||
m_table_view->set_editable(true);
|
||||
m_table_view->set_edit_triggers(GUI::AbstractView::EditTrigger::EditKeyPressed);
|
||||
m_table_view->aid_create_editing_delegate = [](auto&) {
|
||||
return make<GUI::StringModelEditingDelegate>();
|
||||
};
|
||||
|
||||
m_table_view->set_model(m_sorting_model);
|
||||
m_table_view->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending);
|
||||
|
||||
m_table_view->on_activation = [&](auto& index) {
|
||||
|
|
Loading…
Reference in a new issue