Debugger: Make check box widgets in the symbol tree more responsive

This commit is contained in:
chaoticgd 2024-09-14 21:03:49 +01:00 committed by Ty
parent d9c5f22d1e
commit 93b18412f5
2 changed files with 12 additions and 2 deletions

View File

@ -77,6 +77,7 @@ QWidget* SymbolTreeValueDelegate::createEditor(QWidget* parent, const QStyleOpti
{ {
QCheckBox* editor = new QCheckBox(parent); QCheckBox* editor = new QCheckBox(parent);
editor->setChecked(value.toBool()); editor->setChecked(value.toBool());
connect(editor, &QCheckBox::checkStateChanged, this, &SymbolTreeValueDelegate::onCheckBoxStateChanged);
result = editor; result = editor;
break; break;
@ -276,6 +277,13 @@ void SymbolTreeValueDelegate::setModelData(QWidget* editor, QAbstractItemModel*
model->setData(index, value, SymbolTreeModel::EDIT_ROLE); model->setData(index, value, SymbolTreeModel::EDIT_ROLE);
} }
void SymbolTreeValueDelegate::onCheckBoxStateChanged(Qt::CheckState state)
{
QCheckBox* check_box = qobject_cast<QCheckBox*>(sender());
if (check_box)
commitData(check_box);
}
void SymbolTreeValueDelegate::onComboBoxIndexChanged(int index) void SymbolTreeValueDelegate::onComboBoxIndexChanged(int index)
{ {
QComboBox* combo_box = qobject_cast<QComboBox*>(sender()); QComboBox* combo_box = qobject_cast<QComboBox*>(sender());

View File

@ -21,8 +21,10 @@ public:
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
protected: protected:
// Without this, setModelData would only be called when a combo box was // These make it so the values inputted are written back to memory
// deselected rather than when an option was picked. // immediately when the widgets are interacted with rather than when they
// are deselected.
void onCheckBoxStateChanged(Qt::CheckState state);
void onComboBoxIndexChanged(int index); void onComboBoxIndexChanged(int index);
DebugInterface& m_cpu; DebugInterface& m_cpu;