WIP refresh gem catalog in place
Signed-off-by: Alex Peterson <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
@@ -55,6 +55,13 @@ namespace O3DE::ProjectManager
|
||||
|
||||
|
||||
connect(m_gemCatalogScreen, &ScreenWidget::ChangeScreenRequest, this, &CreateProjectCtrl::OnChangeScreenRequest);
|
||||
connect(
|
||||
m_gemRepoScreen, &GemRepoScreen::OnRefresh,
|
||||
[this]()
|
||||
{
|
||||
const QString projectTemplatePath = m_newProjectSettingsScreen->GetProjectTemplatePath();
|
||||
m_gemCatalogScreen->Refresh(projectTemplatePath + "/Template");
|
||||
});
|
||||
|
||||
// When there are multiple project templates present, we re-gather the gems when changing the selected the project template.
|
||||
connect(m_newProjectSettingsScreen, &NewProjectSettingsScreen::OnTemplateSelectionChanged, this, [=](int oldIndex, [[maybe_unused]] int newIndex)
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QSet>
|
||||
#include <QHash>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
@@ -145,6 +147,59 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
}
|
||||
|
||||
void GemCatalogScreen::Refresh(const QString& projectPath)
|
||||
{
|
||||
QHash<QString, GemInfo> gemInfoHash;
|
||||
|
||||
AZ::Outcome<QVector<GemInfo>, AZStd::string> allGemInfosResult = PythonBindingsInterface::Get()->GetAllGemInfos(projectPath);
|
||||
if (allGemInfosResult.IsSuccess())
|
||||
{
|
||||
QVector<GemInfo> gemInfos = allGemInfosResult.GetValue();
|
||||
for (const GemInfo& gemInfo : gemInfos)
|
||||
{
|
||||
gemInfoHash.insert(gemInfo.m_name, gemInfo);
|
||||
}
|
||||
}
|
||||
|
||||
AZ::Outcome<QVector<GemInfo>, AZStd::string> allRepoGemInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoGemsInfos();
|
||||
if (allRepoGemInfosResult.IsSuccess())
|
||||
{
|
||||
const QVector<GemInfo> allRepoGemInfos = allRepoGemInfosResult.GetValue();
|
||||
for (const GemInfo& gemInfo : allRepoGemInfos)
|
||||
{
|
||||
if (!gemInfoHash.contains(gemInfo.m_name))
|
||||
{
|
||||
gemInfoHash.insert(gemInfo.m_name, gemInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove rows for gems that were removed and 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))
|
||||
{
|
||||
m_gemModel->removeRow(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
gemInfoHash.remove(gemName);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// add new rows
|
||||
for(auto iter = gemInfoHash.begin(); iter != gemInfoHash.end(); ++iter)
|
||||
{
|
||||
m_gemModel->AddGem(iter.value());
|
||||
}
|
||||
|
||||
m_gemModel->UpdateGemDependencies();
|
||||
}
|
||||
|
||||
void GemCatalogScreen::OnGemStatusChanged(const QString& gemName, uint32_t numChangedDependencies)
|
||||
{
|
||||
if (m_notificationsEnabled)
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace O3DE::ProjectManager
|
||||
ProjectManagerScreen GetScreenEnum() override;
|
||||
|
||||
void ReinitForProject(const QString& projectPath);
|
||||
void Refresh(const QString& projectPath);
|
||||
|
||||
enum class EnableDisableGemsResult
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace O3DE::ProjectManager
|
||||
: QStandardItemModel(parent)
|
||||
{
|
||||
m_selectionModel = new QItemSelectionModel(this, parent);
|
||||
connect(this, &QAbstractItemModel::rowsAboutToBeRemoved, this, &GemModel::OnRowsAboutToBeRemoved);
|
||||
}
|
||||
|
||||
QItemSelectionModel* GemModel::GetSelectionModel() const
|
||||
@@ -359,6 +360,16 @@ namespace O3DE::ProjectManager
|
||||
gemModel->emit gemStatusChanged(gemName, numChangedDependencies);
|
||||
}
|
||||
|
||||
void GemModel::OnRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last)
|
||||
{
|
||||
for (int i = first; i <= last; ++i)
|
||||
{
|
||||
QModelIndex modelIndex = index(i, 0, parent);
|
||||
const QString& gemName = GetName(modelIndex);
|
||||
m_nameToIndexMap.remove(gemName);
|
||||
}
|
||||
}
|
||||
|
||||
void GemModel::SetIsAddedDependency(QAbstractItemModel& model, const QModelIndex& modelIndex, bool isAdded)
|
||||
{
|
||||
model.setData(modelIndex, isAdded, RoleIsAddedDependency);
|
||||
|
||||
@@ -80,6 +80,9 @@ namespace O3DE::ProjectManager
|
||||
signals:
|
||||
void gemStatusChanged(const QString& gemName, uint32_t numChangedDependencies);
|
||||
|
||||
protected slots:
|
||||
void OnRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last);
|
||||
|
||||
private:
|
||||
void FindGemDisplayNamesByNameStrings(QStringList& inOutGemNames);
|
||||
void GetAllDependingGems(const QModelIndex& modelIndex, QSet<QModelIndex>& inOutGems);
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace O3DE::ProjectManager
|
||||
if (addGemRepoResult)
|
||||
{
|
||||
Reinit();
|
||||
emit OnRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -116,6 +117,7 @@ namespace O3DE::ProjectManager
|
||||
if (removeGemRepoResult)
|
||||
{
|
||||
Reinit();
|
||||
emit OnRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -130,6 +132,7 @@ namespace O3DE::ProjectManager
|
||||
{
|
||||
bool refreshResult = PythonBindingsInterface::Get()->RefreshAllGemRepos();
|
||||
Reinit();
|
||||
emit OnRefresh();
|
||||
|
||||
if (!refreshResult)
|
||||
{
|
||||
@@ -146,6 +149,7 @@ namespace O3DE::ProjectManager
|
||||
if (refreshResult.IsSuccess())
|
||||
{
|
||||
Reinit();
|
||||
emit OnRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace O3DE::ProjectManager
|
||||
class GemRepoScreen
|
||||
: public ScreenWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GemRepoScreen(QWidget* parent = nullptr);
|
||||
~GemRepoScreen() = default;
|
||||
@@ -37,6 +38,9 @@ namespace O3DE::ProjectManager
|
||||
|
||||
GemRepoModel* GetGemRepoModel() const { return m_gemRepoModel; }
|
||||
|
||||
signals:
|
||||
void OnRefresh();
|
||||
|
||||
public slots:
|
||||
void HandleAddRepoButton();
|
||||
void HandleRemoveRepoButton(const QModelIndex& modelIndex);
|
||||
|
||||
Reference in New Issue
Block a user