From c62c63295ff4cc889235e13ffe2b372d9b08260b Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:10:39 -0800 Subject: [PATCH] Removes SortFilterProxyModel from AzToolsFramework Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- .../AssetBrowser/SortFilterProxyModel.cpp | 186 ------------------ 1 file changed, 186 deletions(-) delete mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/SortFilterProxyModel.cpp diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/SortFilterProxyModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/SortFilterProxyModel.cpp deleted file mode 100644 index d41bfe6e3b..0000000000 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/SortFilterProxyModel.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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 - * - */ -#include "SortFilterProxyModel.hxx" - -namespace AzToolsFramework -{ - namespace AssetBrowser - { - ////////////////////////////////////////////////////////////////////////// - //SortFilterProxyModel - SortFilterProxyModel::SortFilterProxyModel(QObject* parent) - : QSortFilterProxyModel(parent) - , m_assetMatchFiltersOperator(AzToolsFramework::FilterOperatorType::And) - { - //uncomment any column you want to see in the view - m_showColumn.insert(AssetBrowserEntry::Column::Name); - //m_showColumn.insert( Entry::Column_SourceID ); - //m_showColumn.insert( Entry::Column_FingerprintValue ); - //m_showColumn.insert( Entry::Colbumn_Guid ); - //m_showColumn.insert( Entry::Column_ScanFolderID ); - //m_showColumn.insert( Entry::Column_ProductID ); - //m_showColumn.insert( Entry::Column_JobID ); - //m_showColumn.insert( Entry::Column_JobKey ); - //m_showColumn.insert( Entry::Column_SubID ); - //m_showColumn.insert( Entry::Column_AssetType ); - //m_showColumn.insert( Entry::Column_Platform ); - //m_showColumn.insert( Entry::Column_ClassID ); - } - - void SortFilterProxyModel::OnSearchCriteriaChanged(QStringList& criteriaList, AzToolsFramework::FilterOperatorType filterOperator) - { - removeAllAssetMatchFilters(); - setAssetMatchFilterOperator(filterOperator); - - for (QString criteria : criteriaList) - { - auto parts = criteria.split(": ", QString::SkipEmptyParts); - addAssetMatchFilter(parts.last().toUtf8().constData()); - } - } - - void SortFilterProxyModel::addAssetTypeFilter(AZ::Data::AssetType assetType) - { - m_assetTypeFilters.push_back(assetType); - invalidateFilter(); - } - - void SortFilterProxyModel::addAssetPathFilter(const char* assetPathFilter) - { - m_assetPathFilters.push_back(assetPathFilter); - invalidateFilter(); - } - - void SortFilterProxyModel::removeAllAssetPathFilters() - { - m_assetPathFilters.clear(); - invalidateFilter(); - } - - void SortFilterProxyModel::setAssetMatchSubDirFilter(bool val) - { - m_includeSubdir = val; - invalidateFilter(); - } - - void SortFilterProxyModel::removeAllAssetMatchFilters() - { - m_assetMatchFilters.clear(); - invalidateFilter(); - } - - void SortFilterProxyModel::addAssetMatchFilter(const char* assetMatchFilter) - { - m_assetMatchFilters.push_back(assetMatchFilter); - invalidateFilter(); - } - - void SortFilterProxyModel::setAssetMatchFilterOperator(AzToolsFramework::FilterOperatorType type) - { - m_assetMatchFiltersOperator = type; - invalidateFilter(); - } - - bool SortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const - { - //get the source idx, if invalid early out - QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); - if (!idx.isValid()) - { - return false; - } - - //the entry is the internal pointer of the index - auto entry = static_cast(idx.internalPointer()); - - if (!entry->isValid()) - { - return false; - } - - //////////////////////////////////////////////////////////////////////// - //we only want to see assets that have at least one child product that has a valid assetType - if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source) - { - //we have a asset with at least one valid child product assetType - //we only want to see assets that have at least one child product that matches the assetType filter - if (!m_assetTypeFilters.empty()) - { - for (int i = 0; i < entry->GetChildCount(); ++i) - { - auto product = static_cast(entry->GetChild(i)); - if (product->isValid()) - { - if (AZStd::find(m_assetTypeFilters.begin(), m_assetTypeFilters.end(), product->GetAssetType()) == m_assetTypeFilters.end()) - { - return false; - } - } - } - } - } - - ////////////////////////////////////////////////////////////////////////// - //we only want to see assets that match all the match filters - if (!m_assetMatchFilters.empty()) - { - if (m_assetMatchFiltersOperator == AzToolsFramework::FilterOperatorType::And) - { - for (const auto& item : m_assetMatchFilters) - { - if (!entry->Match(item.c_str())) - { - return false; - } - } - } - else if (m_assetMatchFiltersOperator == AzToolsFramework::FilterOperatorType::Or) - { - for (const auto& item : m_assetMatchFilters) - { - if (entry->Match(item.c_str())) - { - return true; - } - } - return false; - } - } - //////////////////////////////////////////////////////////////////////// - - return true; - } - - bool SortFilterProxyModel::filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const - { - (void)source_parent; - - //if the column is in the set we want to show it - return m_showColumn.find(static_cast(source_column)) != m_showColumn.end(); - } - - bool SortFilterProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const - { - if (source_left.column() == source_right.column()) - { - QVariant leftData = sourceModel()->data(source_left); - QVariant rightData = sourceModel()->data(source_right); - if ((leftData.type() == QVariant::String) && - (rightData.type() == QVariant::String)) - { - QString leftString = leftData.toString(); - QString rightString = rightData.toString(); - return QString::compare(leftString, rightString, Qt::CaseInsensitive) > 0; - } - } - return QSortFilterProxyModel::lessThan(source_left, source_right); - } - } // namespace AssetBrowser -} // namespace AzToolsFramework// namespace AssetBrowser - -#include