#pragma once #include #include #include #include #include #include namespace XCEngine::UI::Editor::App { struct ProductHierarchyNode { std::string nodeId = {}; std::string label = {}; std::vector children = {}; }; class ProductHierarchyModel { public: static ProductHierarchyModel BuildDefault(); bool Empty() const; bool ContainsNode(std::string_view nodeId) const; const ProductHierarchyNode* FindNode(std::string_view nodeId) const; ProductHierarchyNode* FindNode(std::string_view nodeId); std::optional GetParentId(std::string_view nodeId) const; bool RenameNode(std::string_view nodeId, std::string label); std::string CreateChild(std::string_view parentId, std::string_view label); bool DeleteNode(std::string_view nodeId); bool CanReparent(std::string_view sourceNodeId, std::string_view targetParentId) const; bool Reparent(std::string_view sourceNodeId, std::string_view targetParentId); bool MoveToRoot(std::string_view sourceNodeId); std::vector BuildTreeItems( const ::XCEngine::UI::UITextureHandle& icon) const; private: std::string AllocateNodeId(); bool CanAdopt( std::string_view sourceNodeId, const ProductHierarchyNode* targetParent) const; bool ContainsDescendant( const ProductHierarchyNode& node, std::string_view candidateId) const; std::vector m_roots = {}; std::uint64_t m_nextGeneratedNodeId = 1u; }; } // namespace XCEngine::UI::Editor::App