From 716e5b2943965688127d079bbdba91597907e483 Mon Sep 17 00:00:00 2001 From: MillionOstrich <31486600+MillionOstrich@users.noreply.github.com> Date: Sun, 1 Oct 2017 22:59:27 +0100 Subject: Reworked rename & move for files & folders. Move/rename don't depend on the path variable anymore. Fixed dependencies not updating correctly when dragging folders in the folder tree. Dependencies will only update for files which sucessfully moved. Reduced code duplication between move & rename. Added rename & move options to folders tree. --- editor/filesystem_dock.h | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'editor/filesystem_dock.h') diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index b38e3e63f0..1491e1c7a7 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -32,6 +32,7 @@ #include "scene/gui/box_container.h" #include "scene/gui/control.h" +#include "scene/gui/dialogs.h" #include "scene/gui/item_list.h" #include "scene/gui/label.h" #include "scene/gui/menu_button.h" @@ -67,6 +68,7 @@ private: FILE_DEPENDENCIES, FILE_OWNERS, FILE_MOVE, + FILE_RENAME, FILE_REMOVE, FILE_REIMPORT, FILE_INFO, @@ -77,6 +79,8 @@ private: enum FolderMenu { FOLDER_EXPAND_ALL, FOLDER_COLLAPSE_ALL, + FOLDER_MOVE, + FOLDER_RENAME, FOLDER_SHOW_IN_EXPLORER, FOLDER_COPY_PATH }; @@ -111,10 +115,21 @@ private: DependencyRemoveDialog *remove_dialog; EditorDirDialog *move_dialog; - EditorFileDialog *rename_dialog; + ConfirmationDialog *rename_dialog; + LineEdit *rename_dialog_text; - Vector move_dirs; - Vector move_files; + class FileOrFolder { + public: + String path; + bool is_file; + + FileOrFolder() + : path(""), is_file(false) {} + FileOrFolder(const String &p_path, bool p_is_file) + : path(p_path), is_file(p_is_file) {} + }; + FileOrFolder to_rename; + Vector to_move; Vector history; int history_pos; @@ -136,11 +151,14 @@ private: bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir); void _thumbnail_done(const String &p_path, const Ref &p_preview, const Variant &p_udata); - void _find_inside_move_files(EditorFileSystemDirectory *efsd, Vector &files); - void _find_remaps(EditorFileSystemDirectory *efsd, Map &renames, List &to_remaps); - void _rename_operation(const String &p_to_path); - void _move_operation(const String &p_to_path); + void _get_all_files_in_dir(EditorFileSystemDirectory *efsd, Vector &files) const; + void _find_remaps(EditorFileSystemDirectory *efsd, const Map &renames, Vector &to_remaps) const; + void _try_move_item(const FileOrFolder &p_item, const String &p_new_path, Map &p_renames) const; + void _update_dependencies_after_move(const Map &p_renames) const; + + void _rename_operation_confirm(); + void _move_operation_confirm(const String &p_to_path); void _file_option(int p_option); void _folder_option(int p_option); -- cgit v1.2.3