refactor(new_editor/app): reorganize host structure and add smoke test

This commit is contained in:
2026-04-15 08:24:06 +08:00
parent 3617b4840b
commit 9e5954cf0a
235 changed files with 11157 additions and 10028 deletions

View File

@@ -0,0 +1,68 @@
#include "ProjectBrowserModelSupport.h"
namespace XCEngine::UI::Editor::App {
using namespace ProjectBrowserModelSupport;
void ProjectBrowserModel::RefreshFolderTree() {
m_folderEntries.clear();
m_treeItems.clear();
if (m_assetsRootPath.empty() || !std::filesystem::exists(m_assetsRootPath)) {
return;
}
const auto appendFolderRecursive =
[&](auto&& self, const std::filesystem::path& folderPath, std::uint32_t depth) -> void {
const std::string itemId = BuildRelativeItemId(folderPath, m_assetsRootPath);
FolderEntry folderEntry = {};
folderEntry.itemId = itemId;
folderEntry.absolutePath = folderPath;
folderEntry.label = PathToUtf8String(folderPath.filename());
m_folderEntries.push_back(folderEntry);
Widgets::UIEditorTreeViewItem item = {};
item.itemId = itemId;
item.label = folderEntry.label;
item.depth = depth;
item.forceLeaf = !HasChildDirectories(folderPath);
item.leadingIcon = m_folderIcon;
m_treeItems.push_back(std::move(item));
const std::vector<std::filesystem::path> childFolders =
CollectSortedChildDirectories(folderPath);
for (const std::filesystem::path& childPath : childFolders) {
self(self, childPath, depth + 1u);
}
};
appendFolderRecursive(appendFolderRecursive, m_assetsRootPath, 0u);
}
std::vector<std::string> ProjectBrowserModel::CollectCurrentFolderAncestorIds() const {
return BuildAncestorFolderIds(m_currentFolderId);
}
std::vector<std::string> ProjectBrowserModel::BuildAncestorFolderIds(
std::string_view itemId) const {
std::vector<std::string> ancestors = {};
const FolderEntry* folderEntry = FindFolderEntry(itemId);
if (folderEntry == nullptr) {
return ancestors;
}
std::filesystem::path path = folderEntry->absolutePath;
while (true) {
ancestors.push_back(BuildRelativeItemId(path, m_assetsRootPath));
if (path == m_assetsRootPath) {
break;
}
path = path.parent_path();
}
std::reverse(ancestors.begin(), ancestors.end());
return ancestors;
}
} // namespace XCEngine::UI::Editor::App