Files
o3de/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h
T
AMZN-Igarri a1d9a2cc58 Asset Browser Tests (#4948)
* Added AssetBrowser Tests

Signed-off-by: igarri <igarri@amazon.com>

* Added Entries to test AssetBrowser

Signed-off-by: igarri <igarri@amazon.com>

* Added Print info.

Signed-off-by: igarri <igarri@amazon.com>

* Added more folders

Signed-off-by: igarri <igarri@amazon.com>

* Added Asset Browser Tests for the Search View

Signed-off-by: igarri <igarri@amazon.com>

* Fixed Entry creation

Signed-off-by: igarri <igarri@amazon.com>

* Removed optimize

Signed-off-by: igarri <igarri@amazon.com>

* Cleanup AssetBrowserModel

Signed-off-by: igarri <igarri@amazon.com>

* RowCount made public

Signed-off-by: igarri <igarri@amazon.com>

* Delegated entry creation to RootAssetBrowserEntry and added Code review feedback

Signed-off-by: igarri <igarri@amazon.com>

* removed unused helper class and fixed demo tests

Signed-off-by: igarri <igarri@amazon.com>

* Fixed bus connections

Signed-off-by: igarri <igarri@amazon.com>

* Refactored test environment and added basic tests

Signed-off-by: igarri <igarri@amazon.com>

* Applied some code review feedback and added basic tests

Signed-off-by: igarri <igarri@amazon.com>

* fixed naming

Signed-off-by: igarri <igarri@amazon.com>

* Refactored Tests

Signed-off-by: igarri <igarri@amazon.com>

* removed pointer reset, now handled by the AssetBrowserComponent

Signed-off-by: igarri <igarri@amazon.com>

* Fixed conversion unsigned-signed

Signed-off-by: igarri <igarri@amazon.com>

* Cleaned includes

Signed-off-by: igarri <igarri@amazon.com>

* fixed test setup

Signed-off-by: igarri <igarri@amazon.com>

* Fixed unused variables

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* Added printer function

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* cleaned up code

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* Added Test to check the correctness of the setup

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* Fixed basic tests

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>

* Fixed Tests

Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>
2021-11-08 09:56:51 +00:00

66 lines
2.6 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <AzCore/Asset/AssetCommon.h>
#include <QSortFilterProxyModel>
#include <QPointer>
#endif
#include <Editor/EditorSettingsAPIBus.h>
namespace AzToolsFramework
{
namespace AssetBrowser
{
class AssetBrowserFilterModel;
class AssetBrowserEntry;
class AssetBrowserTableModel
: public QSortFilterProxyModel
, public AssetBrowserComponentNotificationBus::Handler
{
Q_OBJECT
public:
AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0);
explicit AssetBrowserTableModel(QObject* parent = nullptr);
////////////////////////////////////////////////////////////////////
// QSortFilterProxyModel
void setSourceModel(QAbstractItemModel* sourceModel) override;
QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QModelIndex parent(const QModelIndex& child) const override;
QModelIndex sibling(int row, int column, const QModelIndex& idx) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
protected:
QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override;
////////////////////////////////////////////////////////////////////
AssetBrowserEntry* GetAssetEntry(QModelIndex index) const;
int BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0);
public slots:
void UpdateTableModelMaps();
private slots:
void SourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
private:
AZ::u64 m_numberOfItemsDisplayed = 50;
int m_displayedItemsCounter = 0;
QPointer<AssetBrowserFilterModel> m_filterModel;
QMap<int, QModelIndex> m_indexMap;
QMap<QModelIndex, int> m_rowMap;
};
} // namespace AssetBrowser
} // namespace AzToolsFramework