AudioControlsEditorUndo.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 <AudioControl.h>
  10. #include <AzCore/std/containers/map.h>
  11. #include <AzCore/std/containers/vector.h>
  12. #include <AzCore/std/smart_ptr/shared_ptr.h>
  13. #include <QATLControlsTreeModel.h>
  14. #include <Undo/IUndoObject.h>
  15. #include <Util/UndoUtil.h>
  16. #include <QAbstractItemModel>
  17. #include <QString>
  18. class QStandardItem;
  19. namespace AudioControls
  20. {
  21. typedef AZStd::vector<int> TPath;
  22. //-------------------------------------------------------------------------------------------//
  23. class IUndoControlOperation
  24. : public IUndoObject
  25. {
  26. protected:
  27. IUndoControlOperation() {}
  28. void AddStoredControl();
  29. void RemoveStoredControl();
  30. TPath m_path;
  31. CID m_id;
  32. AZStd::shared_ptr<CATLControl> m_pStoredControl;
  33. };
  34. //-------------------------------------------------------------------------------------------//
  35. class CUndoControlAdd
  36. : public IUndoControlOperation
  37. {
  38. public:
  39. explicit CUndoControlAdd(CID id);
  40. protected:
  41. int GetSize() override { return sizeof(*this); }
  42. void Undo(bool bUndo) override;
  43. void Redo() override;
  44. };
  45. //-------------------------------------------------------------------------------------------//
  46. class CUndoControlRemove
  47. : public IUndoControlOperation
  48. {
  49. public:
  50. explicit CUndoControlRemove(AZStd::shared_ptr<CATLControl>& pControl);
  51. protected:
  52. int GetSize() override { return sizeof(*this); }
  53. void Undo(bool bUndo) override;
  54. void Redo() override;
  55. };
  56. //-------------------------------------------------------------------------------------------//
  57. class IUndoFolderOperation
  58. : public IUndoObject
  59. {
  60. protected:
  61. explicit IUndoFolderOperation(QStandardItem* pItem);
  62. void AddFolderItem();
  63. void RemoveItem();
  64. TPath m_path;
  65. QString m_sName;
  66. };
  67. //-------------------------------------------------------------------------------------------//
  68. class CUndoFolderRemove
  69. : public IUndoFolderOperation
  70. {
  71. public:
  72. explicit CUndoFolderRemove(QStandardItem* pItem);
  73. protected:
  74. int GetSize() override { return sizeof(*this); }
  75. void Undo(bool bUndo) override;
  76. void Redo() override;
  77. };
  78. //-------------------------------------------------------------------------------------------//
  79. class CUndoFolderAdd
  80. : public IUndoFolderOperation
  81. {
  82. public:
  83. explicit CUndoFolderAdd(QStandardItem* pItem);
  84. protected:
  85. int GetSize() override { return sizeof(*this); }
  86. void Undo(bool bUndo) override;
  87. void Redo() override;
  88. };
  89. //-------------------------------------------------------------------------------------------//
  90. class CUndoFolderRename
  91. : public IUndoFolderOperation
  92. {
  93. public:
  94. explicit CUndoFolderRename(QStandardItem* pItem);
  95. protected:
  96. int GetSize() override { return sizeof(*this); }
  97. void Undo(bool bUndo) override;
  98. void Redo() override;
  99. void SwapNames();
  100. };
  101. //-------------------------------------------------------------------------------------------//
  102. class CUndoControlModified
  103. : public IUndoObject
  104. {
  105. public:
  106. explicit CUndoControlModified(CID id);
  107. protected:
  108. int GetSize() override { return sizeof(*this); }
  109. void SwapData();
  110. void Undo(bool bUndo) override;
  111. void Redo() override;
  112. CID m_id;
  113. AZStd::string m_name;
  114. AZStd::string m_scope;
  115. bool m_isAutoLoad;
  116. AZStd::vector<TConnectionPtr> m_connectedControls;
  117. };
  118. //-------------------------------------------------------------------------------------------//
  119. class CUndoItemMove
  120. : public IUndoObject
  121. {
  122. public:
  123. CUndoItemMove();
  124. protected:
  125. int GetSize() override { return sizeof(*this); }
  126. void Undo(bool bUndo) override;
  127. void Redo() override;
  128. void Copy(QStandardItem* pSource, QStandardItem* pDest);
  129. QATLTreeModel m_original;
  130. QATLTreeModel m_modified;
  131. bool bModifiedInitialised;
  132. };
  133. } //namespace AudioControls