Switching views with filters

This commit is contained in:
igarri
2021-05-14 13:09:14 +01:00
parent 33240c9f90
commit cff9fea535
7 changed files with 23 additions and 5 deletions
@@ -130,6 +130,9 @@ namespace AzToolsFramework
if (compFilter)
{
auto& subFilters = compFilter->GetSubFilters();
//bool bNoFilters = false;
auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool
{
auto assetTypeFilter = qobject_cast<QSharedPointer<const CompositeFilter> >(filter);
@@ -147,8 +150,11 @@ namespace AzToolsFramework
if (it != subFilters.end())
{
m_stringFilter = qobject_cast<QSharedPointer<const StringFilter> >(*it);
emit switchFilterView(m_stringFilter.toStrongRef()->IsEmpty());
}
}
invalidateFilter();
Q_EMIT filterChanged();
}
@@ -52,8 +52,8 @@ namespace AzToolsFramework
void OnAssetBrowserComponentReady() override;
Q_SIGNALS:
void switchFilterView(int);
void filterChanged();
//////////////////////////////////////////////////////////////////////////
//QSortFilterProxyModel
protected:
@@ -233,6 +233,11 @@ namespace AzToolsFramework
Q_EMIT updatedSignal();
}
bool StringFilter::IsEmpty() const
{
return m_filterString.isEmpty();
}
QString StringFilter::GetNameInternal() const
{
return m_filterString;
@@ -110,7 +110,7 @@ namespace AzToolsFramework
~StringFilter() override = default;
void SetFilterString(const QString& filterString);
bool IsEmpty() const;
protected:
QString GetNameInternal() const override;
bool MatchInternal(const AssetBrowserEntry* entry) const override;
@@ -52,6 +52,7 @@ namespace AzToolsFramework
setSortingEnabled(true);
setItemDelegate(m_delegate);
header()->hide();
setContextMenuPolicy(Qt::CustomContextMenu);
setMouseTracking(true);
@@ -174,6 +175,7 @@ namespace AzToolsFramework
void AssetBrowserTreeView::OnAssetBrowserComponentReady()
{
hideColumn(static_cast<int>(AssetBrowserEntry::Column::Path));
if (!m_name.isEmpty())
{
auto crc = AZ::Crc32(m_name.toUtf8().data());