diff options
author | Marco Cutecchia <marco.cutecchia@outlook.it> | 2021-09-24 18:30:12 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-27 01:20:48 +0200 |
commit | 05630d2d5d203c42cfcf1e0e3321c253ad038aef (patch) | |
tree | 8cbe464fffeea885227170acb88262cf41263528 /Userland/Libraries/LibGUI | |
parent | 5565db5aa1e57145c1671fd33faa4b6bd44ad343 (diff) | |
download | serenity-05630d2d5d203c42cfcf1e0e3321c253ad038aef.zip |
LibGUI: Add 'on_rename_successful' callback to FileSystemModel
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/FileSystemModel.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/FileSystemModel.h | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp index eb03b50850..cb4b437030 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.cpp +++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp @@ -746,7 +746,11 @@ void FileSystemModel::set_data(ModelIndex const& index, Variant const& data) if (rc < 0) { if (on_rename_error) on_rename_error(errno, strerror(errno)); + return; } + + if (on_rename_successful) + on_rename_successful(node.full_path(), new_full_path); } Vector<ModelIndex> FileSystemModel::matches(StringView const& searching, unsigned flags, ModelIndex const& index) diff --git a/Userland/Libraries/LibGUI/FileSystemModel.h b/Userland/Libraries/LibGUI/FileSystemModel.h index b523b25236..67973e5625 100644 --- a/Userland/Libraries/LibGUI/FileSystemModel.h +++ b/Userland/Libraries/LibGUI/FileSystemModel.h @@ -118,6 +118,7 @@ public: Function<void()> on_complete; Function<void(int error, char const* error_string)> on_directory_change_error; Function<void(int error, char const* error_string)> on_rename_error; + Function<void(String const& old_name, String const& new_name)> on_rename_successful; virtual int tree_column() const override { return Column::Name; } virtual int row_count(ModelIndex const& = ModelIndex()) const override; |