From 5e170ae3320e9bc987d75bb240269c52a1097ec4 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 18 Feb 2021 21:02:48 -0600 Subject: [PATCH] [GUI] Modify behavior of VectorListEditor VectorListEditor allows row-by-row creation of a list of three-component vector values. Values are manipulated using spinboxes. The previous behavior was that the spinboxes only affected the existing rows: when creating a row the contents of the spinboxes were ignored. This commit modifies that behavior so that a new row gets the contents of the spinboxes. In addition, in the original code the "Accept" button was enabled even when there was no row to edit, making it unclear whether a user needed to click the add row button or the accept button. Clicking the accept button did nothing if there was no existing row, and if compiled in debug mode, an assertion was raised. --- src/Gui/VectorListEditor.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Gui/VectorListEditor.cpp b/src/Gui/VectorListEditor.cpp index d857a16b73..506259d475 100644 --- a/src/Gui/VectorListEditor.cpp +++ b/src/Gui/VectorListEditor.cpp @@ -255,6 +255,7 @@ void VectorListEditor::setValues(const QList& v) ui->spinBox->setRange(1, 1); ui->spinBox->setEnabled(false); ui->toolButtonRemove->setEnabled(false); + ui->toolButtonAccept->setEnabled(false); } else { ui->spinBox->setRange(1, v.size()); @@ -310,10 +311,16 @@ void VectorListEditor::acceptCurrent() void VectorListEditor::addRow() { - model->insertRow(ui->tableWidget->currentIndex().row() + 1); + auto newRow = ui->tableWidget->currentIndex().row() + 1; + model->insertRow(newRow); + ui->tableWidget->setCurrentIndex(model->index(newRow, 0)); + QSignalBlocker blocker(ui->spinBox); ui->spinBox->setMaximum(model->rowCount()); + ui->spinBox->setValue(newRow + 1); ui->spinBox->setEnabled(true); ui->toolButtonRemove->setEnabled(true); + ui->toolButtonAccept->setEnabled(true); + acceptCurrent(); // The new row gets the values from the spinboxes } void VectorListEditor::removeRow()