2
0

NodeListSelectionWidget.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. #if !defined(Q_MOC_RUN)
  10. #include <QComboBox>
  11. #include <AzCore/Math/Uuid.h>
  12. #include <AzCore/std/string/string.h>
  13. #include <AzCore/std/containers/unordered_set.h>
  14. #include <AzCore/Memory/SystemAllocator.h>
  15. #include <SceneAPI/SceneUI/SceneUIConfiguration.h>
  16. #include <SceneAPI/SceneCore/Containers/SceneGraph.h>
  17. #endif
  18. namespace AZ
  19. {
  20. namespace SceneAPI
  21. {
  22. namespace DataTypes
  23. {
  24. class IGraphObject;
  25. }
  26. namespace UI
  27. {
  28. class NodeListSelectionWidget : public QComboBox
  29. {
  30. Q_OBJECT
  31. public:
  32. AZ_CLASS_ALLOCATOR_DECL
  33. explicit NodeListSelectionWidget(QWidget* parent);
  34. void SetCurrentSelection(const AZStd::string& selection);
  35. AZStd::string GetCurrentSelection() const;
  36. void AddDisabledOption(const AZStd::string& option);
  37. void AddDisabledOption(AZStd::string&& option);
  38. const AZStd::string& GetDisabledOption() const;
  39. void UseShortNames(bool use);
  40. // Sets the class type id to filter against.
  41. void SetClassTypeId(const Uuid& classTypeId);
  42. void ClearClassTypeId();
  43. // When the classTypeId is set as this is true, the nodes it the tree
  44. // must have the exact same type id, if set to false all types
  45. // matching the type id and derived classes will be listed.
  46. void UseExactClassTypeMatch(bool exactMatch);
  47. void ExcludeEndPoints(bool exclude);
  48. // If the assigned selection is missing the selection will default to
  49. // the disabled value if present and true, otherwise the alphabetically
  50. // first entry is used.
  51. void DefaultToDisabled(bool value);
  52. signals:
  53. void valueChanged(const AZStd::string& newValue);
  54. protected slots:
  55. void OnTextChange(const QString& text);
  56. protected:
  57. void showEvent(QShowEvent* event) override;
  58. void BuildList(const Containers::SceneGraph& graph);
  59. bool IsCorrectType(const DataTypes::IGraphObject& object) const;
  60. void AddEntry(QStringList& comboListEntries, const Containers::SceneGraph::Name& name);
  61. void SetSelection();
  62. void AddDisabledOption();
  63. AZStd::string m_disabledOption;
  64. AZStd::string m_currentSelection;
  65. Uuid m_classTypeId;
  66. // Set to true if only a specific class type should be in the filter, otherwise
  67. // all classes that derive from the given type will be listed.
  68. bool m_exactClassTypeMatch;
  69. // Attributes come in after widget has been created and this requires the
  70. // list to be rebuild. This flag keeps track of any changes and
  71. // whether or not the list should be repopulated.
  72. bool m_hasDirtyList;
  73. bool m_useShortNames;
  74. bool m_excludeEndPoints;
  75. bool m_defaultToDisabled;
  76. };
  77. } // UI
  78. } // SceneAPI
  79. } // AZ