From 7b6226a8aa5f7d7f504c1c6a975abfeff00c4d96 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich Date: Tue, 1 Jun 2021 14:03:11 +0200 Subject: [PATCH] [LYN-2514] GemCatalog: Item delegate changes enabled/disabled state in the gem model When clicking the button on the right side of the gem item delegate, it changes the enabled/disabled state of the gem in the model. --- .../Source/GemCatalog/GemItemDelegate.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp index 57200e3b36..0fc0d89fcb 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemItemDelegate.cpp @@ -131,6 +131,22 @@ namespace O3DE::ProjectManager return false; } + if (event->type() == QEvent::MouseButtonPress) + { + QMouseEvent* mouseEvent = static_cast(event); + + QRect fullRect, itemRect, contentRect; + CalcRects(option, fullRect, itemRect, contentRect); + const QRect buttonRect = CalcButtonRect(contentRect); + + if (buttonRect.contains(mouseEvent->pos())) + { + const bool isAdded = GemModel::IsAdded(modelIndex); + GemModel::SetIsAdded(*model, modelIndex, !isAdded); + return true; + } + } + return QStyledItemDelegate::editorEvent(event, model, option, modelIndex); }