Extra gem download failure handling

Signed-off-by: AMZN-Phil <pconroy@amazon.com>
monroegm-disable-blank-issue-2
AMZN-Phil 4 years ago
parent 06e5c394e2
commit 7e43b53d16

@ -57,6 +57,7 @@ namespace O3DE::ProjectManager
vLayout->addWidget(m_headerWidget); vLayout->addWidget(m_headerWidget);
connect(m_gemModel, &GemModel::gemStatusChanged, this, &GemCatalogScreen::OnGemStatusChanged); connect(m_gemModel, &GemModel::gemStatusChanged, this, &GemCatalogScreen::OnGemStatusChanged);
connect(m_gemModel, &GemModel::dependencyGemStatusChanged, this, &GemCatalogScreen::OnDependencyGemStatusChanged);
connect(m_gemModel->GetSelectionModel(), &QItemSelectionModel::selectionChanged, this, [this]{ ShowInspector(); }); connect(m_gemModel->GetSelectionModel(), &QItemSelectionModel::selectionChanged, this, [this]{ ShowInspector(); });
connect(m_headerWidget, &GemCatalogHeaderWidget::RefreshGems, this, &GemCatalogScreen::Refresh); connect(m_headerWidget, &GemCatalogHeaderWidget::RefreshGems, this, &GemCatalogScreen::Refresh);
connect(m_headerWidget, &GemCatalogHeaderWidget::OpenGemsRepo, this, &GemCatalogScreen::HandleOpenGemRepo); connect(m_headerWidget, &GemCatalogHeaderWidget::OpenGemsRepo, this, &GemCatalogScreen::HandleOpenGemRepo);
@ -279,7 +280,8 @@ namespace O3DE::ProjectManager
{ {
notification += tr(" and "); notification += tr(" and ");
} }
if (added && GemModel::GetDownloadStatus(modelIndex) == GemInfo::DownloadStatus::NotDownloaded) if (added && (GemModel::GetDownloadStatus(modelIndex) == GemInfo::DownloadStatus::NotDownloaded) ||
(GemModel::GetDownloadStatus(modelIndex) == GemInfo::DownloadStatus::DownloadFailed))
{ {
m_downloadController->AddGemDownload(GemModel::GetName(modelIndex)); m_downloadController->AddGemDownload(GemModel::GetName(modelIndex));
GemModel::SetDownloadStatus(*m_gemModel, modelIndex, GemInfo::DownloadStatus::Downloading); GemModel::SetDownloadStatus(*m_gemModel, modelIndex, GemInfo::DownloadStatus::Downloading);
@ -304,6 +306,18 @@ namespace O3DE::ProjectManager
} }
} }
void GemCatalogScreen::OnDependencyGemStatusChanged(const QString& gemName)
{
QModelIndex modelIndex = m_gemModel->FindIndexByNameString(gemName);
bool added = GemModel::IsAddedDependency(modelIndex);
if (added && (GemModel::GetDownloadStatus(modelIndex) == GemInfo::DownloadStatus::NotDownloaded) ||
(GemModel::GetDownloadStatus(modelIndex) == GemInfo::DownloadStatus::DownloadFailed))
{
m_downloadController->AddGemDownload(GemModel::GetName(modelIndex));
GemModel::SetDownloadStatus(*m_gemModel, modelIndex, GemInfo::DownloadStatus::Downloading);
}
}
void GemCatalogScreen::SelectGem(const QString& gemName) void GemCatalogScreen::SelectGem(const QString& gemName)
{ {
QModelIndex modelIndex = m_gemModel->FindIndexByNameString(gemName); QModelIndex modelIndex = m_gemModel->FindIndexByNameString(gemName);
@ -383,6 +397,7 @@ namespace O3DE::ProjectManager
// Remove gem from gems to be added to update any dependencies // Remove gem from gems to be added to update any dependencies
GemModel::SetIsAdded(*m_gemModel, modelIndex, false); GemModel::SetIsAdded(*m_gemModel, modelIndex, false);
GemModel::DeactivateDependentGems(*m_gemModel, modelIndex);
// Unregister the gem // Unregister the gem
auto unregisterResult = PythonBindingsInterface::Get()->UnregisterGem(selectedGemPath); auto unregisterResult = PythonBindingsInterface::Get()->UnregisterGem(selectedGemPath);
@ -660,6 +675,8 @@ namespace O3DE::ProjectManager
QModelIndex index = m_gemModel->FindIndexByNameString(gemName); QModelIndex index = m_gemModel->FindIndexByNameString(gemName);
if (index.isValid()) if (index.isValid())
{ {
GemModel::SetIsAdded(*m_gemModel, index, false);
GemModel::DeactivateDependentGems(*m_gemModel, index);
GemModel::SetDownloadStatus(*m_gemModel, index, GemInfo::DownloadFailed); GemModel::SetDownloadStatus(*m_gemModel, index, GemInfo::DownloadFailed);
} }
} }

@ -53,6 +53,7 @@ namespace O3DE::ProjectManager
public slots: public slots:
void OnGemStatusChanged(const QString& gemName, uint32_t numChangedDependencies); void OnGemStatusChanged(const QString& gemName, uint32_t numChangedDependencies);
void OnDependencyGemStatusChanged(const QString& gemName);
void OnAddGemClicked(); void OnAddGemClicked();
void SelectGem(const QString& gemName); void SelectGem(const QString& gemName);
void OnGemDownloadResult(const QString& gemName, bool succeeded = true); void OnGemDownloadResult(const QString& gemName, bool succeeded = true);

@ -357,6 +357,8 @@ namespace O3DE::ProjectManager
if (!IsAdded(dependency)) if (!IsAdded(dependency))
{ {
numChangedDependencies++; numChangedDependencies++;
const QString dependencyName = gemModel->GetName(dependency);
gemModel->emit dependencyGemStatusChanged(dependencyName);
} }
} }
} }
@ -381,6 +383,8 @@ namespace O3DE::ProjectManager
if (!IsAdded(dependency)) if (!IsAdded(dependency))
{ {
numChangedDependencies++; numChangedDependencies++;
const QString dependencyName = gemModel->GetName(dependency);
gemModel->emit dependencyGemStatusChanged(dependencyName);
} }
} }
} }
@ -479,6 +483,28 @@ namespace O3DE::ProjectManager
return previouslyAdded && !added; return previouslyAdded && !added;
} }
void GemModel::DeactivateDependentGems(QAbstractItemModel& model, const QModelIndex& modelIndex)
{
GemModel* gemModel = GetSourceModel(&model);
AZ_Assert(gemModel, "Failed to obtain GemModel");
QVector<QModelIndex> dependentGems = gemModel->GatherDependentGems(modelIndex);
if (!dependentGems.isEmpty())
{
// we need to deactivate all gems that depend on this one
for (auto dependentModelIndex : dependentGems)
{
DeactivateDependentGems(model, dependentModelIndex);
}
}
else
{
// Deactivate this gem
SetIsAdded(model, modelIndex, false);
}
}
void GemModel::SetDownloadStatus(QAbstractItemModel& model, const QModelIndex& modelIndex, GemInfo::DownloadStatus status) void GemModel::SetDownloadStatus(QAbstractItemModel& model, const QModelIndex& modelIndex, GemInfo::DownloadStatus status)
{ {
model.setData(modelIndex, status, RoleDownloadStatus); model.setData(modelIndex, status, RoleDownloadStatus);

@ -99,6 +99,7 @@ namespace O3DE::ProjectManager
static bool NeedsToBeRemoved(const QModelIndex& modelIndex, bool includeDependencies = false); static bool NeedsToBeRemoved(const QModelIndex& modelIndex, bool includeDependencies = false);
static bool HasRequirement(const QModelIndex& modelIndex); static bool HasRequirement(const QModelIndex& modelIndex);
static void UpdateDependencies(QAbstractItemModel& model, const QString& gemName, bool isAdded); static void UpdateDependencies(QAbstractItemModel& model, const QString& gemName, bool isAdded);
static void DeactivateDependentGems(QAbstractItemModel& model, const QModelIndex& modelIndex);
static void SetDownloadStatus(QAbstractItemModel& model, const QModelIndex& modelIndex, GemInfo::DownloadStatus status); static void SetDownloadStatus(QAbstractItemModel& model, const QModelIndex& modelIndex, GemInfo::DownloadStatus status);
bool DoGemsToBeAddedHaveRequirements() const; bool DoGemsToBeAddedHaveRequirements() const;
@ -113,6 +114,7 @@ namespace O3DE::ProjectManager
signals: signals:
void gemStatusChanged(const QString& gemName, uint32_t numChangedDependencies); void gemStatusChanged(const QString& gemName, uint32_t numChangedDependencies);
void dependencyGemStatusChanged(const QString& gemName);
protected slots: protected slots:
void OnRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last); void OnRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last);

Loading…
Cancel
Save