summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorZae <zaevi@live.com>2020-07-08 21:32:42 +0800
committerZae <zaevi@live.com>2020-07-10 17:21:43 +0800
commitb0fbde6abd2d2bd6a8ad226597b1582b62d63607 (patch)
treec8e017f037d02ce565d4da1047d3430601005461 /editor
parent18c51d3f0c4ddf0bdf347638ca2d781a42de16d2 (diff)
fix item_edited behavior on Asset Installer.
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_asset_installer.cpp25
-rw-r--r--editor/editor_asset_installer.h1
2 files changed, 25 insertions, 1 deletions
diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp
index edb299bb90..8aeeba52ed 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -54,6 +54,27 @@ void EditorAssetInstaller::_update_subitems(TreeItem *p_item, bool p_check, bool
}
}
+void EditorAssetInstaller::_uncheck_parent(TreeItem *p_item) {
+ if (!p_item) {
+ return;
+ }
+
+ bool any_checked = false;
+ TreeItem *item = p_item->get_children();
+ while (item) {
+ if (item->is_checked(0)) {
+ any_checked = true;
+ break;
+ }
+ item = item->get_next();
+ }
+
+ if (!any_checked) {
+ p_item->set_checked(0, false);
+ _uncheck_parent(p_item->get_parent());
+ }
+}
+
void EditorAssetInstaller::_item_edited() {
if (updating) {
return;
@@ -67,7 +88,7 @@ void EditorAssetInstaller::_item_edited() {
String path = item->get_metadata(0);
updating = true;
- if (path == String()) { //a dir
+ if (path == String() || item == tree->get_root()) { //a dir or root
_update_subitems(item, item->is_checked(0), true);
}
@@ -76,6 +97,8 @@ void EditorAssetInstaller::_item_edited() {
item->set_checked(0, true);
item = item->get_parent();
}
+ } else {
+ _uncheck_parent(item->get_parent());
}
updating = false;
}
diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h
index 7f3d00994f..7be87b2e4f 100644
--- a/editor/editor_asset_installer.h
+++ b/editor/editor_asset_installer.h
@@ -42,6 +42,7 @@ class EditorAssetInstaller : public ConfirmationDialog {
Map<String, TreeItem *> status_map;
bool updating;
void _update_subitems(TreeItem *p_item, bool p_check, bool p_first = false);
+ void _uncheck_parent(TreeItem *p_item);
void _item_edited();
virtual void ok_pressed();