e4e22879b8
* Fixed crash in tableView when the filter goes empty and there is a selected entry. * fixed consts * Code Review Changes * more minor fixes
62 lines
2.4 KiB
C++
62 lines
2.4 KiB
C++
/*
|
|
* 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.
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#if !defined(Q_MOC_RUN)
|
|
#include <AzCore/Asset/AssetCommon.h>
|
|
#include <QSortFilterProxyModel>
|
|
#include <QPointer>
|
|
#endif
|
|
|
|
namespace AzToolsFramework
|
|
{
|
|
namespace AssetBrowser
|
|
{
|
|
class AssetBrowserFilterModel;
|
|
class AssetBrowserEntry;
|
|
|
|
class AssetBrowserTableModel
|
|
: public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0);
|
|
explicit AssetBrowserTableModel(QObject* parent = nullptr);
|
|
|
|
void UpdateTableModelMaps();
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// QSortFilterProxyModel
|
|
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
|
QModelIndex mapToSource(const QModelIndex& proxyIndex) 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;
|
|
|
|
protected:
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override;
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
private:
|
|
AssetBrowserEntry* GetAssetEntry(QModelIndex index) const;
|
|
int BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0);
|
|
|
|
private:
|
|
QPointer<AssetBrowserFilterModel> m_filterModel;
|
|
QMap<int, QModelIndex> m_indexMap;
|
|
};
|
|
} // namespace AssetBrowser
|
|
} // namespace AzToolsFramework
|