Adds Inspector to Gem Repo Screen (#4242)

* Adds the gem repo screen with the UI built but with mocked data and not connected to the o3de scripts

Signed-off-by: nggieber <nggieber@amazon.com>

* Changed name of added to enabled, disabled define, removed unused functions

Signed-off-by: nggieber <nggieber@amazon.com>

* Added Repo Screen Inspector UI

Signed-off-by: nggieber <nggieber@amazon.com>

* Addressed minor PR feedback

Signed-off-by: nggieber <nggieber@amazon.com>

* Add some more minor PR changes

Signed-off-by: nggieber <nggieber@amazon.com>
This commit is contained in:
AMZN-nggieber
2021-09-24 10:50:45 -07:00
committed by GitHub
parent 967d535464
commit 9b14d49f87
20 changed files with 439 additions and 65 deletions
@@ -7,8 +7,10 @@
*/
#include <GemRepo/GemRepoModel.h>
#include <PythonBindings.h>
#include <QItemSelectionModel>
#include <QMessageBox>
namespace O3DE::ProjectManager
{
@@ -16,6 +18,7 @@ namespace O3DE::ProjectManager
: QStandardItemModel(parent)
{
m_selectionModel = new QItemSelectionModel(this, parent);
m_gemModel = new GemModel(this);
}
QItemSelectionModel* GemRepoModel::GetSelectionModel() const
@@ -37,8 +40,17 @@ namespace O3DE::ProjectManager
item->setData(gemRepoInfo.m_repoLink, RoleRepoLink);
item->setData(gemRepoInfo.m_lastUpdated, RoleLastUpdated);
item->setData(gemRepoInfo.m_path, RolePath);
item->setData(gemRepoInfo.m_additionalInfo, RoleAdditionalInfo);
item->setData(gemRepoInfo.m_includedGemPaths, RoleIncludedGems);
appendRow(item);
QVector<GemInfo> includedGemInfos = GetIncludedGemInfos(item->index());
for (const GemInfo& gemInfo : includedGemInfos)
{
m_gemModel->AddGem(gemInfo);
}
}
void GemRepoModel::Clear()
@@ -61,6 +73,11 @@ namespace O3DE::ProjectManager
return modelIndex.data(RoleSummary).toString();
}
QString GemRepoModel::GetAdditionalInfo(const QModelIndex& modelIndex)
{
return modelIndex.data(RoleAdditionalInfo).toString();
}
QString GemRepoModel::GetDirectoryLink(const QModelIndex& modelIndex)
{
return modelIndex.data(RoleDirectoryLink).toString();
@@ -81,6 +98,45 @@ namespace O3DE::ProjectManager
return modelIndex.data(RolePath).toString();
}
QStringList GemRepoModel::GetIncludedGemPaths(const QModelIndex& modelIndex)
{
return modelIndex.data(RoleIncludedGems).toStringList();
}
QStringList GemRepoModel::GetIncludedGemNames(const QModelIndex& modelIndex)
{
QStringList gemNames;
QVector<GemInfo> gemInfos = GetIncludedGemInfos(modelIndex);
for (const GemInfo& gemInfo : gemInfos)
{
gemNames.append(gemInfo.m_displayName);
}
return gemNames;
}
QVector<GemInfo> GemRepoModel::GetIncludedGemInfos(const QModelIndex& modelIndex)
{
QVector<GemInfo> allGemInfos;
QStringList repoGemPaths = GetIncludedGemPaths(modelIndex);
for (const QString& gemPath : repoGemPaths)
{
AZ::Outcome<GemInfo> gemInfoResult = PythonBindingsInterface::Get()->GetGemInfo(gemPath);
if (gemInfoResult.IsSuccess())
{
allGemInfos.append(gemInfoResult.GetValue());
}
else
{
QMessageBox::critical(nullptr, tr("Gem Not Found"), tr("Cannot find info for gem %1.").arg(gemPath));
}
}
return allGemInfos;
}
bool GemRepoModel::IsEnabled(const QModelIndex& modelIndex)
{
return modelIndex.data(RoleIsEnabled).toBool();
@@ -91,4 +147,9 @@ namespace O3DE::ProjectManager
model.setData(modelIndex, isEnabled, RoleIsEnabled);
}
bool GemRepoModel::HasAdditionalInfo(const QModelIndex& modelIndex)
{
return !modelIndex.data(RoleAdditionalInfo).toString().isEmpty();
}
} // namespace O3DE::ProjectManager