modified code from feedback
This commit is contained in:
+19
-14
@@ -23,9 +23,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option")
|
||||
#include <QCollator>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
AZ_CVAR(
|
||||
bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null,
|
||||
"Use the new AssetBrowser TableView for searching assets.");
|
||||
AZ_CVAR_EXTERNED(bool, ed_useNewAssetBrowserTableView);
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -36,10 +34,10 @@ namespace AzToolsFramework
|
||||
AssetBrowserFilterModel::AssetBrowserFilterModel(QObject* parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
m_showColumn.insert(static_cast<int>(AssetBrowserEntry::Column::DisplayName));
|
||||
m_showColumn.insert(aznumeric_cast<int>(AssetBrowserEntry::Column::DisplayName));
|
||||
if (ed_useNewAssetBrowserTableView)
|
||||
{
|
||||
m_showColumn.insert(static_cast<int>(AssetBrowserEntry::Column::Path));
|
||||
m_showColumn.insert(aznumeric_cast<int>(AssetBrowserEntry::Column::Path));
|
||||
}
|
||||
m_collator.setNumericMode(true);
|
||||
AssetBrowserComponentNotificationBus::Handler::BusConnect();
|
||||
@@ -149,19 +147,23 @@ namespace AzToolsFramework
|
||||
m_assetTypeFilter = qobject_cast<QSharedPointer<const CompositeFilter> >(*it);
|
||||
}
|
||||
|
||||
it = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool
|
||||
auto compStringFilterIter = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool
|
||||
{
|
||||
//The real StringFilter is really a CompositeFilter with just one StringFilter in its subfilter list
|
||||
//To know if it is actually a StringFilter we have to get that subfilter and check if it is a Stringfilter.
|
||||
auto stringCompositeFilter = qobject_cast<QSharedPointer<const CompositeFilter> >(filter);
|
||||
bool isStringFilter = false;
|
||||
if (stringCompositeFilter)
|
||||
{
|
||||
auto& subFilters = stringCompositeFilter->GetSubFilters();
|
||||
auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filt) -> bool
|
||||
{
|
||||
const auto& stringSubfilters = stringCompositeFilter->GetSubFilters();
|
||||
auto canBeCasted = [](FilterConstType filt) -> bool {
|
||||
auto strFilter = qobject_cast<QSharedPointer<const StringFilter>>(filt);
|
||||
return !strFilter.isNull();
|
||||
});
|
||||
if (it != subFilters.end())
|
||||
};
|
||||
auto stringSubfliterConstIter = AZStd::find_if(stringSubfilters.begin(), stringSubfilters.end(), canBeCasted);
|
||||
|
||||
//A Composite StringFilter will only have just one subfilter and nothing more.
|
||||
if (stringSubfliterConstIter != stringSubfilters.end() && stringSubfilters.size() == 1)
|
||||
{
|
||||
isStringFilter = true;
|
||||
}
|
||||
@@ -169,10 +171,13 @@ namespace AzToolsFramework
|
||||
|
||||
return isStringFilter;
|
||||
});
|
||||
if (it != subFilters.end())
|
||||
if (compStringFilterIter != subFilters.end())
|
||||
{
|
||||
auto compStringFilter = qobject_cast<QSharedPointer<const CompositeFilter>>(*it);
|
||||
m_stringFilter = qobject_cast<QSharedPointer<const StringFilter>>(compStringFilter->GetSubFilters()[0]);
|
||||
auto compStringFilter = qobject_cast<QSharedPointer<const CompositeFilter>>(*compStringFilterIter);
|
||||
if (compStringFilter->GetSubFilters().size() > 0 && compStringFilter->GetSubFilters()[0])
|
||||
{
|
||||
m_stringFilter = qobject_cast<QSharedPointer<const StringFilter>>(compStringFilter->GetSubFilters()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace AssetBrowser
|
||||
{
|
||||
const int AssetBrowserModel::m_column = static_cast<int>(AssetBrowserEntry::Column::DisplayName);
|
||||
|
||||
AssetBrowserModel::AssetBrowserModel(QObject* parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_rootEntry(nullptr)
|
||||
@@ -143,9 +141,9 @@ namespace AzToolsFramework
|
||||
|
||||
if (parent.isValid())
|
||||
{
|
||||
if ((parent.column() != static_cast<int>(AssetBrowserEntry::Column::DisplayName)) &&
|
||||
(parent.column() != static_cast<int>(AssetBrowserEntry::Column::Name)) &&
|
||||
(parent.column() != static_cast<int>(AssetBrowserEntry::Column::Path)))
|
||||
if ((parent.column() != aznumeric_cast<int>(AssetBrowserEntry::Column::DisplayName)) &&
|
||||
(parent.column() != aznumeric_cast<int>(AssetBrowserEntry::Column::Name)) &&
|
||||
(parent.column() != aznumeric_cast<int>(AssetBrowserEntry::Column::Path)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -394,7 +392,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
int row = entry->row();
|
||||
index = createIndex(row, m_column, entry);
|
||||
index = createIndex(row, aznumeric_cast<int>(AssetBrowserEntry::Column::DisplayName), entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,8 +91,6 @@ namespace AzToolsFramework
|
||||
static void SourceIndexesToAssetIds(const QModelIndexList& indexes, AZStd::vector<AZ::Data::AssetId>& assetIds);
|
||||
static void SourceIndexesToAssetDatabaseEntries(const QModelIndexList& indexes, AZStd::vector<AssetBrowserEntry*>& entries);
|
||||
|
||||
const static int m_column;
|
||||
|
||||
private:
|
||||
AZStd::shared_ptr<RootAssetBrowserEntry> m_rootEntry;
|
||||
bool m_loaded;
|
||||
|
||||
+1
@@ -102,6 +102,7 @@ namespace AzToolsFramework
|
||||
QModelIndexList sourceIndexes;
|
||||
for (const auto& index : selectedIndexes())
|
||||
{
|
||||
//If we check for more than one column then the model will try to select the same entry several times.
|
||||
if (index.column() == 0)
|
||||
{
|
||||
sourceIndexes.push_back(m_assetBrowserSortFilterProxyModel->mapToSource(index));
|
||||
|
||||
@@ -114,7 +114,6 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent)
|
||||
}
|
||||
|
||||
m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data());
|
||||
//m_ui->m_assetBrowserTreeViewWidget->hideColumn(static_cast<int>(AssetBrowserEntry::Column::Path));
|
||||
|
||||
connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal,
|
||||
m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot);
|
||||
@@ -232,7 +231,7 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex&
|
||||
using namespace AzToolsFramework;
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
// assumption: Double clicking an item selects it before telling us we double clicked it.
|
||||
auto selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets();
|
||||
const auto& selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets();
|
||||
for (const AssetBrowserEntry* entry : selectedAssets)
|
||||
{
|
||||
AZ::Data::AssetId assetIdToOpen;
|
||||
@@ -269,7 +268,7 @@ void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QM
|
||||
using namespace AzToolsFramework;
|
||||
using namespace AzToolsFramework::AssetBrowser;
|
||||
// assumption: Double clicking an item selects it before telling us we double clicked it.
|
||||
auto selectedAssets = m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets();
|
||||
const auto& selectedAssets = m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets();
|
||||
for (const AssetBrowserEntry* entry : selectedAssets)
|
||||
{
|
||||
AZ::Data::AssetId assetIdToOpen;
|
||||
|
||||
Reference in New Issue
Block a user