From dbdd8e1bf997ca3e6f657b5898888c8827d0e481 2017-09-29 15:55:01 From: Alexandre Leroux Date: 2017-09-29 15:55:01 Subject: [PATCH] Handles state role in variable widget delegate --- diff --git a/gui/src/Variable/VariableInspectorWidget.cpp b/gui/src/Variable/VariableInspectorWidget.cpp index 038bcdb..c157aa1 100644 --- a/gui/src/Variable/VariableInspectorWidget.cpp +++ b/gui/src/Variable/VariableInspectorWidget.cpp @@ -63,6 +63,19 @@ public: } else { QStyledItemDelegate::paint(painter, option, index); + + // Sets color depending on the state + auto stateRoleData = index.data(VariableRoles::StateRole); + if (stateRoleData.canConvert()) { + auto stateData = stateRoleData.value(); + + auto color = QColor{stateData.value("color").toString()}; + if (color.isValid()) { + auto newOption = option; + newOption.palette.setBrush(QPalette::Text, QBrush{color}); + QStyledItemDelegate::paint(painter, newOption, index); + } + } } }