summaryrefslogtreecommitdiff
path: root/editor/filesystem_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r--editor/filesystem_dock.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 6c8bd1901e..e8cf081320 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -531,7 +531,7 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa
}
String file_name = p_path.get_file();
- if (!file_name.empty()) {
+ if (!file_name.is_empty()) {
for (int i = 0; i < files->get_item_count(); i++) {
if (files->get_item_text(i) == file_name) {
files->select(i, true);
@@ -1528,7 +1528,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove
if (!p_overwrite) {
to_move_path = p_to_path;
Vector<String> conflicting_items = _check_existing();
- if (!conflicting_items.empty()) {
+ if (!conflicting_items.is_empty()) {
// Ask to do something.
overwrite_dialog->set_text(vformat(
TTR("The following files or folders conflict with items in the target location '%s':\n\n%s\n\nDo you wish to overwrite them?"),
@@ -1721,7 +1721,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
paths.push_back(fpath);
}
}
- if (!paths.empty()) {
+ if (!paths.is_empty()) {
emit_signal("instance", paths);
}
} break;
@@ -1753,7 +1753,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_DEPENDENCIES: {
// Checkout the file dependencies.
- if (!p_selected.empty()) {
+ if (!p_selected.is_empty()) {
String fpath = p_selected[0];
deps_editor->edit(fpath);
}
@@ -1761,7 +1761,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_OWNERS: {
// Checkout the file owners.
- if (!p_selected.empty()) {
+ if (!p_selected.is_empty()) {
String fpath = p_selected[0];
owners_editor->show(fpath);
}
@@ -1784,7 +1784,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_RENAME: {
// Rename the active file.
- if (!p_selected.empty()) {
+ if (!p_selected.is_empty()) {
to_rename.path = p_selected[0];
if (to_rename.path != "res://") {
to_rename.is_file = !to_rename.path.ends_with("/");
@@ -1885,7 +1885,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
} break;
case FILE_COPY_PATH: {
- if (!p_selected.empty()) {
+ if (!p_selected.is_empty()) {
String fpath = p_selected[0];
DisplayServer::get_singleton()->clipboard_set(fpath);
}
@@ -1898,7 +1898,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
}
void FileSystemDock::_resource_created() {
- Object *c = new_resource_dialog->instance_selected();
+ Variant c = new_resource_dialog->instance_selected();
ERR_FAIL_COND(!c);
Resource *r = Object::cast_to<Resource>(c);
@@ -1912,17 +1912,14 @@ void FileSystemDock::_resource_created() {
memdelete(node);
}
- REF res(r);
- editor->push_item(c);
-
- RES current_res = RES(r);
+ editor->push_item(r);
String fpath = path;
if (!fpath.ends_with("/")) {
fpath = fpath.get_base_dir();
}
- editor->save_resource_as(current_res, fpath);
+ editor->save_resource_as(RES(r), fpath);
}
void FileSystemDock::_search_changed(const String &p_text, const Control *p_from) {
@@ -2013,7 +2010,7 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
all_not_favorites = true;
}
- if (paths.empty()) {
+ if (paths.is_empty()) {
return Variant();
}
@@ -2061,7 +2058,7 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
String to_dir;
bool favorite;
_get_drag_target_folder(to_dir, favorite, p_point, p_from);
- return !to_dir.empty();
+ return !to_dir.is_empty();
}
if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) {
@@ -2074,7 +2071,7 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da
return true;
}
- if (to_dir.empty()) {
+ if (to_dir.is_empty()) {
return false;
}
@@ -2169,7 +2166,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
String to_dir;
bool favorite;
_get_drag_target_folder(to_dir, favorite, p_point, p_from);
- if (res.is_valid() && !to_dir.empty()) {
+ if (res.is_valid() && !to_dir.is_empty()) {
EditorNode::get_singleton()->push_item(res.ptr());
EditorNode::get_singleton()->save_resource_as(res, to_dir);
}
@@ -2180,7 +2177,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
String to_dir;
bool favorite;
_get_drag_target_folder(to_dir, favorite, p_point, p_from);
- if (!to_dir.empty()) {
+ if (!to_dir.is_empty()) {
Vector<String> fnames = drag_data["files"];
to_move.clear();
for (int i = 0; i < fnames.size(); i++) {
@@ -2188,7 +2185,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
to_move.push_back(FileOrFolder(fnames[i], !fnames[i].ends_with("/")));
}
}
- if (!to_move.empty()) {
+ if (!to_move.is_empty()) {
if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < to_move.size(); i++) {
String new_path;
@@ -2291,7 +2288,7 @@ void FileSystemDock::_get_drag_target_folder(String &target, bool &target_favori
void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options) {
// Add options for files and folders.
- ERR_FAIL_COND_MSG(p_paths.empty(), "Path cannot be empty.");
+ ERR_FAIL_COND_MSG(p_paths.is_empty(), "Path cannot be empty.");
Vector<String> filenames;
Vector<String> foldernames;
@@ -2414,7 +2411,7 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) {
}
// Popup.
- if (!paths.empty()) {
+ if (!paths.is_empty()) {
tree_popup->set_size(Size2(1, 1));
_file_and_folders_fill_popup(tree_popup, paths);
tree_popup->set_position(tree->get_screen_position() + p_pos);
@@ -2447,14 +2444,14 @@ void FileSystemDock::_file_list_rmb_select(int p_item, const Vector2 &p_pos) {
continue;
}
if (files->get_item_text(p_item) == "..") {
- files->unselect(i);
+ files->deselect(i);
continue;
}
paths.push_back(files->get_item_metadata(i));
}
// Popup.
- if (!paths.empty()) {
+ if (!paths.is_empty()) {
file_list_popup->clear();
file_list_popup->set_size(Size2(1, 1));
_file_and_folders_fill_popup(file_list_popup, paths, searched_string.length() == 0);