/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #ifndef FIND_ENTITY_ITEM_MODEL_H #define FIND_ENTITY_ITEM_MODEL_H #include #include #include #pragma once //! Model for items in the "Find Entity" tree view. //! Each item represents an Entity. class FindEntityItemModel : public QAbstractItemModel { Q_OBJECT; public: AZ_CLASS_ALLOCATOR(FindEntityItemModel, AZ::SystemAllocator, 0); //! Columns of data to display about each Entity. enum Column { ColumnName, //!< Entity name ColumnCount //!< Total number of columns }; enum Roles { VisibilityRole = Qt::UserRole + 1, RoleCount }; FindEntityItemModel(QObject* parent = nullptr); void Initialize(AZ::EntityId canvasEntityId); // Qt overrides. int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex&) const override; QVariant data(const QModelIndex& index, int role) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex& index) const override; QModelIndex GetIndexFromEntity(const AZ::EntityId& entityId, int column = 0) const; AZ::EntityId GetEntityFromIndex(const QModelIndex& index) const; void SearchStringChanged(const AZStd::string& filter); void SearchFilterChanged(const AZStd::vector& componentFilters); protected: QVariant DataForName(const QModelIndex& index, int role) const; //! Use the current filter setting and re-evaluate the filter. void InvalidateFilter(); bool FilterEntity(const AZ::EntityId& entityId); bool IsFiltered(const AZ::EntityId& entityId) const; bool IsMatch(const AZ::EntityId& entityId) const; AZStd::string m_filterString; AZStd::vector m_componentFilters; AZStd::unordered_map m_entityFilteredState; AZStd::unordered_map m_entityMatchState; AZ::EntityId m_canvasEntityId; }; Q_DECLARE_METATYPE(AZ::ComponentTypeList); // allows type to be stored by QVariable #endif