[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.
This commit is contained in:
Benjamin Jillich
2021-06-01 14:03:11 +02:00
parent 553318ed17
commit 7b6226a8aa
@@ -131,6 +131,22 @@ namespace O3DE::ProjectManager
return false;
}
if (event->type() == QEvent::MouseButtonPress)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(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);
}