From ec784b005ffdd39288097ed17f44612cf00b32a4 Mon Sep 17 00:00:00 2001 From: igarri Date: Tue, 18 May 2021 15:49:35 +0100 Subject: [PATCH] More Corrections --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 2 +- .../AssetBrowser/AssetBrowserTableModel.cpp | 44 ++++++++++--------- .../AssetBrowser/AssetBrowserTableModel.h | 13 +++++- .../Views/AssetBrowserTableView.cpp | 28 +++++++----- .../Views/AssetBrowserTableView.h | 11 +++++ 5 files changed, 64 insertions(+), 34 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 77e5523ee3..12b0256c5d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -174,7 +174,7 @@ namespace AzToolsFramework if (compStringFilterIter != subFilters.end()) { auto compStringFilter = qobject_cast>(*compStringFilterIter); - if (compStringFilter->GetSubFilters().size() > 0 && compStringFilter->GetSubFilters()[0]) + if (!compStringFilter->GetSubFilters().isEmpty() && compStringFilter->GetSubFilters()[0]) { m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index bebdf44c9a..b9bfe1bea6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -1,3 +1,14 @@ +/* + * 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. + * + */ #include #include #include @@ -32,24 +43,27 @@ namespace AzToolsFramework { if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { - switch (section) + auto columnRole = aznumeric_cast(role); + switch (columnRole) { - case static_cast(AssetBrowserEntry::Column::Name): + case AssetBrowserEntry::Column::Name: return QString("Name"); - case static_cast(AssetBrowserEntry::Column::Path): + case AssetBrowserEntry::Column::Path: return QString("Path"); default: return QString::number(section); } } - return QSortFilterProxyModel::headerData(section, orientation, role); // QVariant(); + return QSortFilterProxyModel::headerData(section, orientation, role); } QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const { auto sourceIndex = mapToSource(index); if (!sourceIndex.isValid()) + { return QVariant(); + } AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); if (entry == nullptr) @@ -66,22 +80,10 @@ namespace AzToolsFramework return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer()); } - QModelIndex AssetBrowserTableModel::parent(const QModelIndex& child) const + QModelIndex AssetBrowserTableModel::parent([[maybe_unused]] const QModelIndex& child) const { - AZ_UNUSED(child); return QModelIndex(); } - bool AssetBrowserTableModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const - { - AZ_UNUSED(source_row); - AZ_UNUSED(source_parent); - // no filter present, every entry is not visible - if (!m_filterModel->GetFilter()) - { - return true; - } - return true; - } int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const { @@ -94,14 +96,14 @@ namespace AzToolsFramework for (int i = 0; i < rows; ++i) { QModelIndex index = model->index(i, 0, parent); - if (model->hasChildren(index) == false) + if (!model->hasChildren(index)) { beginInsertRows(parent, row, row); m_indexMap[row] = index; endInsertRows(); Q_EMIT dataChanged(index, index); - row = row + 1; + ++row; } if (model->hasChildren(index)) @@ -124,9 +126,9 @@ namespace AzToolsFramework } } void AssetBrowserTableModel::UpdateTableModelMaps() -{ + { emit layoutAboutToBeChanged(); - if (m_indexMap.size() > 0) + if (!m_indexMap.isEmpty()) { beginRemoveRows(m_indexMap.first(), m_indexMap.first().row(), m_indexMap.last().row()); m_indexMap.clear(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 432300194b..b0497213a0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -1,4 +1,16 @@ +/* + * 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 #include @@ -30,7 +42,6 @@ namespace AzToolsFramework public Q_SLOTS: void UpdateTableModelMaps(); protected: - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override; //////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index cb4a989043..df3b0b8644 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -1,3 +1,15 @@ +/* + * 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. + * + */ + #include #include @@ -109,21 +121,16 @@ namespace AzToolsFramework } QTableView::rowsAboutToBeRemoved(parent, start, end); } - void AssetBrowserTableView::layoutChangedSlot(const QList& parents, QAbstractItemModel::LayoutChangeHint hint) + void AssetBrowserTableView::layoutChangedSlot([[maybe_unused]] const QList& parents,[[maybe_unused]] QAbstractItemModel::LayoutChangeHint hint) { - AZ_UNUSED(parents); - AZ_UNUSED(hint); - scrollToTop(); } - void AssetBrowserTableView::SelectProduct(AZ::Data::AssetId assetID) + void AssetBrowserTableView::SelectProduct([[maybe_unused]] AZ::Data::AssetId assetID) { - AZ_UNUSED(assetID); } - void AssetBrowserTableView::SelectFileAtPath(const AZStd::string& assetPath) + void AssetBrowserTableView::SelectFileAtPath([[maybe_unused]] const AZStd::string& assetPath) { - AZ_UNUSED(assetPath); } void AssetBrowserTableView::ClearFilter() @@ -142,11 +149,10 @@ namespace AzToolsFramework { } - void AssetBrowserTableView::OnContextMenu(const QPoint& point) + void AssetBrowserTableView::OnContextMenu([[maybe_unused]] const QPoint& point) { - AZ_UNUSED(point); - auto selectedAssets = GetSelectedAssets(); + const auto& selectedAssets = GetSelectedAssets(); if (selectedAssets.size() != 1) { return; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index b39d48c391..482a072373 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -1,3 +1,14 @@ +/* + * 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