Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/asset/intern/asset_catalog.cc')
-rw-r--r--source/blender/editors/asset/intern/asset_catalog.cc35
1 files changed, 31 insertions, 4 deletions
diff --git a/source/blender/editors/asset/intern/asset_catalog.cc b/source/blender/editors/asset/intern/asset_catalog.cc
index dae960cbb0a..8e1e5be2e47 100644
--- a/source/blender/editors/asset/intern/asset_catalog.cc
+++ b/source/blender/editors/asset/intern/asset_catalog.cc
@@ -107,17 +107,44 @@ void ED_asset_catalog_rename(::AssetLibrary *library,
AssetCatalog *catalog = catalog_service->find_catalog(catalog_id);
- AssetCatalogPath new_path = catalog->path.parent();
- new_path = new_path / StringRef(new_name);
+ const AssetCatalogPath new_path = catalog->path.parent() / StringRef(new_name);
+ const AssetCatalogPath clean_new_path = new_path.cleanup();
- if (new_path == catalog->path) {
+ if (new_path == catalog->path || clean_new_path == catalog->path) {
/* Nothing changed, so don't bother renaming for nothing. */
return;
}
catalog_service->undo_push();
catalog_service->tag_has_unsaved_changes(catalog);
- catalog_service->update_catalog_path(catalog_id, new_path);
+ catalog_service->update_catalog_path(catalog_id, clean_new_path);
+ WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
+}
+
+void ED_asset_catalog_move(::AssetLibrary *library,
+ const CatalogID src_catalog_id,
+ const CatalogID dst_parent_catalog_id)
+{
+ bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(library);
+ if (!catalog_service) {
+ BLI_assert_unreachable();
+ return;
+ }
+
+ AssetCatalog *src_catalog = catalog_service->find_catalog(src_catalog_id);
+ AssetCatalog *dst_catalog = catalog_service->find_catalog(dst_parent_catalog_id);
+
+ const AssetCatalogPath new_path = dst_catalog->path / StringRef(src_catalog->path.name());
+ const AssetCatalogPath clean_new_path = new_path.cleanup();
+
+ if (new_path == src_catalog->path || clean_new_path == src_catalog->path) {
+ /* Nothing changed, so don't bother renaming for nothing. */
+ return;
+ }
+
+ catalog_service->undo_push();
+ catalog_service->tag_has_unsaved_changes(src_catalog);
+ catalog_service->update_catalog_path(src_catalog_id, clean_new_path);
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
}