FindEntityWidget.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef FIND_ENTITY_WIDGET_H
  9. #define FIND_ENTITY_WIDGET_H
  10. #if !defined(Q_MOC_RUN)
  11. #include <AzCore/base.h>
  12. #include <AzCore/Memory/SystemAllocator.h>
  13. #include <AzCore/Component/EntityId.h>
  14. #include <AzCore/std/containers/vector.h>
  15. #include <AzCore/std/containers/unordered_set.h>
  16. #include <AzQtComponents/Components/FilteredSearchWidget.h>
  17. #include <QWidget>
  18. #include <QItemSelection>
  19. #endif
  20. #pragma once
  21. class FindEntityItemModel;
  22. class FindEntitySortFilterProxyModel;
  23. class QPushButton;
  24. class FindEntityWidget
  25. : public QWidget
  26. {
  27. Q_OBJECT;
  28. public:
  29. AZ_CLASS_ALLOCATOR(FindEntityWidget, AZ::SystemAllocator)
  30. FindEntityWidget(AZ::EntityId canvasEntityId, QWidget* pParent = NULL, Qt::WindowFlags flags = Qt::WindowFlags());
  31. virtual ~FindEntityWidget();
  32. Q_SIGNALS:
  33. void OnFinished(AZStd::vector<AZ::EntityId> selectedEntities);
  34. void OnCanceled();
  35. private Q_SLOTS:
  36. void OnSelectionChanged(const QItemSelection&, const QItemSelection&);
  37. void OnItemDblClick(const QModelIndex& index);
  38. void OnSearchTextChanged(const QString& activeTextFilter);
  39. void OnFilterChanged(const AzQtComponents::SearchTypeFilterList& activeTypeFilters);
  40. void OnSelectClicked();
  41. void OnCancelClicked();
  42. private:
  43. AZ::EntityId GetEntityIdFromIndex(const QModelIndex& index) const;
  44. QModelIndex GetIndexFromEntityId(const AZ::EntityId& entityId) const;
  45. void SetupUI();
  46. void GetUsedComponents(AZ::EntityId canvasEntityId, AZStd::unordered_set<AZ::Uuid>& usedComponents);
  47. AzQtComponents::FilteredSearchWidget* m_searchWidget;
  48. QTreeView* m_objectTree;
  49. QPushButton* m_selectButton;
  50. QPushButton* m_cancelButton;
  51. FindEntityItemModel* m_listModel;
  52. FindEntitySortFilterProxyModel* m_proxyModel;
  53. };
  54. #endif