QATLControlsTreeModel.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <ATLControlsModel.h>
  10. #include <QStandardItemModel>
  11. class QStandardItem;
  12. namespace AudioControls
  13. {
  14. class CATLControl;
  15. //-------------------------------------------------------------------------------------------//
  16. class QATLTreeModel
  17. : public QStandardItemModel
  18. , public IATLControlModelListener
  19. {
  20. public:
  21. QATLTreeModel();
  22. ~QATLTreeModel() override;
  23. void Initialize(CATLControlsModel* pControlsModel);
  24. QStandardItem* GetItemFromControlID(CID nID);
  25. CATLControl* CreateControl(EACEControlType eControlType, const AZStd::string_view sName, CATLControl* pParent = nullptr);
  26. QStandardItem* AddControl(CATLControl* pControl, QStandardItem* pParent, int nRow = 0);
  27. QStandardItem* CreateFolder(QStandardItem* pParent, const AZStd::string_view sName, int nRow = 0);
  28. void RemoveItem(QModelIndex index);
  29. void RemoveItems(QModelIndexList indexList);
  30. void SetItemAsDirty(QStandardItem* pItem);
  31. private:
  32. void DeleteInternalData(QModelIndex root);
  33. CATLControl* GetControlFromIndex(QModelIndex index);
  34. // ------------- QStandardItemModel ----------------------
  35. bool canDropMimeData(const QMimeData* mimeData, Qt::DropAction action, int row, int column, const QModelIndex& parent) const override;
  36. bool dropMimeData(const QMimeData* mimeData, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
  37. // -------------------------------------------------------
  38. // ------------- IATLControlModelListener ----------------
  39. void OnControlAdded([[maybe_unused]] CATLControl* pControl) override {}
  40. void OnControlModified(CATLControl* pControl) override;
  41. void OnControlRemoved([[maybe_unused]] CATLControl* pControl) override {}
  42. // -------------------------------------------------------
  43. CATLControlsModel* m_pControlsModel;
  44. };
  45. } // namespace AudioControls