Keep gem repos pages in sync

Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
Alex Peterson
2021-11-04 09:37:26 -07:00
parent 861b29ffc7
commit 2f8de3e797
7 changed files with 56 additions and 8 deletions
@@ -51,13 +51,11 @@ namespace O3DE::ProjectManager
m_gemRepoScreen = new GemRepoScreen(this);
m_stack->addWidget(m_gemRepoScreen);
vLayout->addWidget(m_stack);
connect(m_gemCatalogScreen, &ScreenWidget::ChangeScreenRequest, this, &CreateProjectCtrl::OnChangeScreenRequest);
connect(
m_gemRepoScreen, &GemRepoScreen::OnRefresh,
[this]()
connect(m_gemRepoScreen, &GemRepoScreen::OnRefresh, [this]()
{
const QString projectTemplatePath = m_newProjectSettingsScreen->GetProjectTemplatePath();
m_gemCatalogScreen->Refresh(projectTemplatePath + "/Template");
@@ -135,6 +133,9 @@ namespace O3DE::ProjectManager
// Gather the enabled gems from the default project template when starting the create new project workflow.
ReinitGemCatalogForSelectedTemplate();
// make sure the gem repo has the latest details
m_gemRepoScreen->Reinit();
}
void CreateProjectCtrl::HandleBackButton()
@@ -39,6 +39,10 @@ namespace O3DE::ProjectManager
m_tabWidget->addTab(m_engineSettingsScreen, tr("General"));
m_tabWidget->addTab(m_gemRepoScreen, tr("Gem Repositories"));
// when tab changes, notify the current screen so it can refresh
connect(m_tabWidget, &QTabWidget::currentChanged, this, &EngineScreenCtrl::TabChanged);
topBarHLayout->addWidget(m_tabWidget);
vLayout->addWidget(topBarFrameWidget);
@@ -46,6 +50,11 @@ namespace O3DE::ProjectManager
setLayout(vLayout);
}
void EngineScreenCtrl::TabChanged([[maybe_unused]] int index)
{
NotifyCurrentScreen();
}
ProjectManagerScreen EngineScreenCtrl::GetScreenEnum()
{
return ProjectManagerScreen::UpdateProject;
@@ -71,6 +80,15 @@ namespace O3DE::ProjectManager
return false;
}
void EngineScreenCtrl::NotifyCurrentScreen()
{
ScreenWidget* screen = reinterpret_cast<ScreenWidget*>(m_tabWidget->currentWidget());
if (screen)
{
screen->NotifyCurrentScreen();
}
}
void EngineScreenCtrl::GoToScreen(ProjectManagerScreen screen)
{
if (screen == m_engineSettingsScreen->GetScreenEnum())
@@ -30,6 +30,10 @@ namespace O3DE::ProjectManager
bool IsTab() override;
bool ContainsScreen(ProjectManagerScreen screen) override;
void GoToScreen(ProjectManagerScreen screen) override;
void NotifyCurrentScreen() override;
public slots:
void TabChanged(int index);
QTabWidget* m_tabWidget = nullptr;
EngineSettingsScreen* m_engineSettingsScreen = nullptr;
@@ -23,7 +23,6 @@
#include <QStandardPaths>
#include <QFileDialog>
#include <QMessageBox>
#include <QSet>
#include <QHash>
namespace O3DE::ProjectManager
@@ -160,6 +159,7 @@ namespace O3DE::ProjectManager
{
QHash<QString, GemInfo> gemInfoHash;
// create a hash with the gem name as key
AZ::Outcome<QVector<GemInfo>, AZStd::string> allGemInfosResult = PythonBindingsInterface::Get()->GetAllGemInfos(projectPath);
if (allGemInfosResult.IsSuccess())
{
@@ -170,6 +170,7 @@ namespace O3DE::ProjectManager
}
}
// add all the gem repos into the hash
AZ::Outcome<QVector<GemInfo>, AZStd::string> allRepoGemInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoGemsInfos();
if (allRepoGemInfosResult.IsSuccess())
{
@@ -183,24 +184,32 @@ namespace O3DE::ProjectManager
}
}
// remove rows for gems that were removed and not project dependencies
// remove gems from the model that no longer exist in the hash and are not project dependencies
int i = 0;
while (i < m_gemModel->rowCount())
{
QModelIndex index = m_gemModel->index(i,0);
QString gemName = m_gemModel->GetName(index);
if (!gemInfoHash.contains(gemName) && !m_gemModel->IsAdded(index) && !m_gemModel->IsAddedDependency(index))
const bool gemFound = gemInfoHash.contains(gemName);
if (!gemFound && !m_gemModel->IsAdded(index) && !m_gemModel->IsAddedDependency(index))
{
m_gemModel->removeRow(i);
}
else
{
if (!gemFound && (m_gemModel->IsAdded(index) || !m_gemModel->IsAddedDependency(index)))
{
const QString error = tr("Gem %1 was removed or unregistered, but is still used by the project.").arg(gemName);
AZ_Warning("Project Manager", false, error.toUtf8().constData());
QMessageBox::warning(this, tr("Gem not found"), error.toUtf8().constData());
}
gemInfoHash.remove(gemName);
i++;
}
}
// add new rows
// add all gems remaining in the hash that were not removed
for(auto iter = gemInfoHash.begin(); iter != gemInfoHash.end(); ++iter)
{
m_gemModel->AddGem(iter.value());
@@ -208,6 +217,10 @@ namespace O3DE::ProjectManager
m_gemModel->UpdateGemDependencies();
m_proxyModel->sort(/*column=*/0);
// temporary, until we can refresh filter counts
m_proxyModel->ResetFilters();
m_filterWidget->ResetAllFilters();
}
void GemCatalogScreen::OnGemStatusChanged(const QString& gemName, uint32_t numChangedDependencies)
@@ -52,6 +52,11 @@ namespace O3DE::ProjectManager
Reinit();
}
void GemRepoScreen::NotifyCurrentScreen()
{
Reinit();
}
void GemRepoScreen::Reinit()
{
m_gemRepoModel->clear();
@@ -38,6 +38,8 @@ namespace O3DE::ProjectManager
GemRepoModel* GetGemRepoModel() const { return m_gemRepoModel; }
void NotifyCurrentScreen() override;
signals:
void OnRefresh();
@@ -47,6 +49,7 @@ namespace O3DE::ProjectManager
void HandleRefreshAllButton();
void HandleRefreshRepoButton(const QModelIndex& modelIndex);
private:
void FillModel();
QFrame* CreateNoReposContent();
@@ -43,6 +43,7 @@ namespace O3DE::ProjectManager
m_gemRepoScreen = new GemRepoScreen(this);
connect(m_gemCatalogScreen, &ScreenWidget::ChangeScreenRequest, this, &UpdateProjectCtrl::OnChangeScreenRequest);
connect(m_gemRepoScreen, &GemRepoScreen::OnRefresh, [this](){ m_gemCatalogScreen->Refresh(m_projectInfo.m_path); });
m_stack = new QStackedWidget(this);
m_stack->setObjectName("body");
@@ -101,6 +102,9 @@ namespace O3DE::ProjectManager
// Gather the available gems that will be shown in the gem catalog.
m_gemCatalogScreen->ReinitForProject(m_projectInfo.m_path);
// make sure the gem repo has the latest repo details
m_gemRepoScreen->Reinit();
}
void UpdateProjectCtrl::OnChangeScreenRequest(ProjectManagerScreen screen)