diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-05-14 23:09:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 23:09:03 +0200 |
commit | 00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8 (patch) | |
tree | 2b1c31f45add24085b64425ce440f577424c16a1 /editor/rename_dialog.cpp | |
parent | 5046f666a1181675b39f156c38346525dc1c444e (diff) | |
parent | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (diff) |
Merge pull request #38738 from akien-mga/cause-we-never-go-out-of-style
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks
Diffstat (limited to 'editor/rename_dialog.cpp')
-rw-r--r-- | editor/rename_dialog.cpp | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 8ae8d0991d..6a54894f40 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -42,7 +42,6 @@ #include "scene/gui/tab_container.h" RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) { - scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; preview_node = nullptr; @@ -341,12 +340,10 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und } void RenameDialog::_bind_methods() { - ClassDB::bind_method("rename", &RenameDialog::rename); } void RenameDialog::_update_substitute() { - LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner()); bool is_main_field = _is_main_field(focus_owner_line_edit); @@ -367,7 +364,6 @@ void RenameDialog::_update_substitute() { } void RenameDialog::_post_popup() { - EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); preview_node = nullptr; @@ -385,9 +381,9 @@ void RenameDialog::_update_preview_int(int new_value) { } void RenameDialog::_update_preview(String new_text) { - - if (lock_preview_update || preview_node == nullptr) + if (lock_preview_update || preview_node == nullptr) { return; + } has_errors = false; add_error_handler(&eh); @@ -395,7 +391,6 @@ void RenameDialog::_update_preview(String new_text) { String new_name = _apply_rename(preview_node, spn_count_start->get_value()); if (!has_errors) { - lbl_preview_title->set_text(TTR("Preview")); lbl_preview->set_text(new_name); @@ -413,7 +408,6 @@ void RenameDialog::_update_preview(String new_text) { } String RenameDialog::_apply_rename(const Node *node, int count) { - String search = lne_search->get_text(); String replace = lne_replace->get_text(); String prefix = lne_prefix->get_text(); @@ -428,7 +422,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) { } if (cbut_regex->is_pressed()) { - new_name = _regex(search, new_name, replace); } else { new_name = new_name.replace(search, replace); @@ -444,7 +437,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) { } String RenameDialog::_substitute(const String &subject, const Node *node, int count) { - String result = subject.replace("${COUNTER}", vformat("%0" + itos(spn_count_padding->get_value()) + "d", count)); if (node) { @@ -474,13 +466,13 @@ String RenameDialog::_substitute(const String &subject, const Node *node, int co } void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) { - RenameDialog *self = (RenameDialog *)p_self; String source_file(p_file); // Only show first error that is related to "regex" - if (self->has_errors || source_file.find("regex") < 0) + if (self->has_errors || source_file.find("regex") < 0) { return; + } String err_str; if (p_errorexp && p_errorexp[0]) { @@ -496,14 +488,12 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * } String RenameDialog::_regex(const String &pattern, const String &subject, const String &replacement) { - RegEx regex(pattern); return regex.sub(subject, replacement, true); } String RenameDialog::_postprocess(const String &subject) { - int style_id = opt_style->get_selected(); String result = subject; @@ -550,12 +540,11 @@ String RenameDialog::_postprocess(const String &subject) { } void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int *counter) { - - if (!node) + if (!node) { return; + } if (selection.has(node)) { - String new_name = _apply_rename(node, *counter); if (node->get_name() != new_name) { @@ -581,7 +570,6 @@ void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int } void RenameDialog::rename() { - // Editor selection is not ordered via scene tree. Instead iterate // over scene tree until all selected nodes are found in order. @@ -596,12 +584,10 @@ void RenameDialog::rename() { _iterate_scene(root_node, selected_node_list, &global_count); if (undo_redo && !to_rename.empty()) { - undo_redo->create_action(TTR("Batch Rename")); // Make sure to iterate reversed so that child nodes will find parents. for (int i = to_rename.size() - 1; i >= 0; --i) { - Node *n = root_node->get_node(to_rename[i].first); const String &new_name = to_rename[i].second; @@ -620,7 +606,6 @@ void RenameDialog::rename() { } void RenameDialog::reset() { - lock_preview_update = true; lne_prefix->clear(); @@ -651,7 +636,6 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) { } void RenameDialog::_insert_text(String text) { - LineEdit *focus_owner = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner()); if (_is_main_field(focus_owner)) { |