3
0

QSimpleAudioControlListWidget.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #if !defined(Q_MOC_RUN)
  10. #include <ACETypes.h>
  11. #include <ATLControlsModel.h>
  12. #include <AudioControl.h>
  13. #include <IAudioSystemControl.h>
  14. #include <QTreeWidget>
  15. #endif
  16. namespace AudioControls
  17. {
  18. //-------------------------------------------------------------------------------------------//
  19. class QSimpleAudioControlListWidget
  20. : public QTreeWidget
  21. , public IATLControlModelListener
  22. {
  23. Q_OBJECT
  24. public:
  25. explicit QSimpleAudioControlListWidget(QWidget* parent = nullptr);
  26. ~QSimpleAudioControlListWidget();
  27. void UpdateModel();
  28. void Refresh(bool reload = true);
  29. //
  30. QTreeWidgetItem* GetItem(CID id, bool bLocalized);
  31. TImplControlType GetControlType(QTreeWidgetItem* item);
  32. CID GetItemId(QTreeWidgetItem* item);
  33. bool IsLocalized(QTreeWidgetItem* item);
  34. ControlList GetSelectedIds();
  35. bool IsConnected(QTreeWidgetItem* item);
  36. private:
  37. void LoadControls();
  38. void LoadControl(IAudioSystemControl* pControl, QTreeWidgetItem* pRoot);
  39. QTreeWidgetItem* InsertControl(IAudioSystemControl* pControl, QTreeWidgetItem* pRoot);
  40. void InitItem(QTreeWidgetItem* pItem);
  41. void InitItemData(QTreeWidgetItem* pItem, IAudioSystemControl* pControl = nullptr);
  42. //////////////////////////////////////////////////////////
  43. // IATLControlModelListener implementation
  44. /////////////////////////////////////////////////////////
  45. void OnConnectionAdded(CATLControl* pControl, IAudioSystemControl* pMiddlewareControl) override;
  46. void OnConnectionRemoved(CATLControl* pControl, IAudioSystemControl* pMiddlewareControl) override;
  47. //////////////////////////////////////////////////////////
  48. private slots:
  49. void UpdateControl(IAudioSystemControl* pControl);
  50. private:
  51. // Icons and colours
  52. QColor m_connectedColor;
  53. QColor m_disconnectedColor;
  54. QColor m_localizedColor;
  55. };
  56. } // namespace AudioControls