[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.
This commit is contained in:
Chris Hennes
2021-02-18 21:02:48 -06:00
committed by wwmayer
parent 55cdfefce1
commit 5e170ae332

View File

@@ -255,6 +255,7 @@ void VectorListEditor::setValues(const QList<Base::Vector3d>& 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()