Fixed code Style and minor issues from feedback

This commit is contained in:
igarri
2021-05-19 12:04:40 +01:00
parent ec784b005f
commit 0b50b6cc63
5 changed files with 23 additions and 9 deletions
@@ -184,7 +184,6 @@ namespace AzToolsFramework
invalidateFilter();
Q_EMIT filterChanged();
emit stringFilterPopulated(!m_stringFilter.isNull());
}
void AssetBrowserFilterModel::filterUpdatedSlot()
@@ -22,10 +22,11 @@ namespace AzToolsFramework
{
setDynamicSortFilter(false);
}
void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel)
{
m_filterModel = qobject_cast<AssetBrowserFilterModel*>(sourceModel);
AZ_Assert(m_filterModel, "Expecting AssetBrowserFilterModel");
AZ_Assert(m_filterModel, "Error in AssetBrowserTableModel initialization, class expects source model to be an AssetBrowserFilterModel.");
QSortFilterProxyModel::setSourceModel(sourceModel);
}
@@ -47,9 +48,9 @@ namespace AzToolsFramework
switch (columnRole)
{
case AssetBrowserEntry::Column::Name:
return QString("Name");
return tr("Name");
case AssetBrowserEntry::Column::Path:
return QString("Path");
return tr("Path");
default:
return QString::number(section);
}
@@ -68,8 +69,8 @@ namespace AzToolsFramework
AssetBrowserEntry* entry = GetAssetEntry(sourceIndex);
if (entry == nullptr)
{
AZ_Assert(false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?");
return Qt::PartiallyChecked;
AZ_Assert(false, "AssetBrowserTableModel - QModelIndex does not reference an AssetEntry. Source model is not valid.");
return QVariant();
}
return sourceIndex.data(role);
@@ -113,6 +114,7 @@ namespace AzToolsFramework
}
return row;
}
AssetBrowserEntry* AssetBrowserTableModel::GetAssetEntry(QModelIndex index) const
{
if (index.isValid())
@@ -125,6 +127,7 @@ namespace AzToolsFramework
return nullptr;
}
}
void AssetBrowserTableModel::UpdateTableModelMaps()
{
emit layoutAboutToBeChanged();
@@ -60,11 +60,13 @@ namespace AzToolsFramework
AssetBrowserViewRequestBus::Handler::BusConnect();
AssetBrowserComponentNotificationBus::Handler::BusConnect();
}
AssetBrowserTableView::~AssetBrowserTableView()
{
AssetBrowserViewRequestBus::Handler::BusDisconnect();
AssetBrowserComponentNotificationBus::Handler::BusDisconnect();
}
void AssetBrowserTableView::setModel(QAbstractItemModel* model)
{
m_tableModel = qobject_cast<AssetBrowserTableModel*>(model);
@@ -76,6 +78,7 @@ namespace AzToolsFramework
horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch);
}
void AssetBrowserTableView::SetName(const QString& name)
{
m_name = name;
@@ -86,6 +89,7 @@ namespace AzToolsFramework
OnAssetBrowserComponentReady();
}
}
AZStd::vector<AssetBrowserEntry*> AssetBrowserTableView::GetSelectedAssets() const
{
QModelIndexList sourceIndexes;
@@ -101,11 +105,13 @@ namespace AzToolsFramework
AssetBrowserModel::SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries);
return entries;
}
void AssetBrowserTableView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
{
QTableView::selectionChanged(selected, deselected);
Q_EMIT selectionChangedSignal(selected, deselected);
}
void AssetBrowserTableView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
{
// if selected entry is being removed, clear selection so not to select (and attempt to preview) other entries potentially
@@ -121,10 +127,12 @@ namespace AzToolsFramework
}
QTableView::rowsAboutToBeRemoved(parent, start, end);
}
void AssetBrowserTableView::layoutChangedSlot([[maybe_unused]] const QList<QPersistentModelIndex>& parents,[[maybe_unused]] QAbstractItemModel::LayoutChangeHint hint)
{
scrollToTop();
}
void AssetBrowserTableView::SelectProduct([[maybe_unused]] AZ::Data::AssetId assetID)
{
}
@@ -99,9 +99,9 @@ namespace AzToolsFramework
style->drawItemText(
painter, remainingRect, option.displayAlignment, actualPalette, isEnabled,
index.column() == static_cast<int>(AssetBrowserEntry::Column::Name)
? qvariant_cast<QString>(entry->data(static_cast<int>(AssetBrowserEntry::Column::Name)))
: qvariant_cast<QString>(entry->data(static_cast<int>(AssetBrowserEntry::Column::Path))),
index.column() == aznumeric_cast<int>(AssetBrowserEntry::Column::Name)
? qvariant_cast<QString>(entry->data(aznumeric_cast<int>(AssetBrowserEntry::Column::Name)))
: qvariant_cast<QString>(entry->data(aznumeric_cast<int>(AssetBrowserEntry::Column::Path))),
isSelected ? QPalette::HighlightedText : QPalette::Text);
}
}
@@ -312,9 +312,13 @@ void AzAssetBrowserWindow::LockToDefaultView(bool state)
using namespace AzToolsFramework::AssetBrowser;
SwitchDisplayView(!state);
if (state == true)
{
disconnect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView);
}
else
{
connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView);
}
}
#include <AzAssetBrowser/moc_AzAssetBrowserWindow.cpp>