CommandHierarchyItemCreate.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <QUndoCommand>
  10. class CommandHierarchyItemCreate
  11. : public QUndoCommand
  12. {
  13. public:
  14. using PostCreationCallback = std::function<void(AZ::Entity* element)>;
  15. void undo() override;
  16. void redo() override;
  17. static void Push(UndoStack* stack,
  18. HierarchyWidget* hierarchy,
  19. const QTreeWidgetItemRawPtrQList& selectedItems,
  20. int childIndex = -1,
  21. PostCreationCallback postCreationCB = []([[maybe_unused]] AZ::Entity* element){});
  22. private:
  23. CommandHierarchyItemCreate(UndoStack* stack,
  24. HierarchyWidget* hierarchy,
  25. const EntityHelpers::EntityIdList& parents,
  26. int childIndex,
  27. PostCreationCallback postCreationCB);
  28. UndoStack* m_stack;
  29. HierarchyWidget* m_hierarchy;
  30. EntityHelpers::EntityIdList m_parents;
  31. int m_childIndex;
  32. SerializeHelpers::SerializedEntryList m_entries;
  33. PostCreationCallback m_postCreationCB;
  34. };