Avoid multiple error messages when deleting cell values

When multiple cells are selected pressing the Delete key tries to set
all of them to an empty string. In case of a unique constraint or
similar constraints this throws an error. This commit copies the
behaviour of the set to NULL menu action in that it aborts at the first
error to avoid multiple error messages.

See issue #2704.
This commit is contained in:
Martin Kleusberg
2021-05-22 09:55:49 +02:00
parent 8ffe641ae1
commit 50b48bc756

View File

@@ -951,7 +951,10 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event)
} else {
// When pressing Delete only set the value to empty string
for(const QModelIndex& index : selectedIndexes())
model()->setData(index, "");
{
if(!model()->setData(index, ""))
return;
}
}
}
} else if(event->modifiers().testFlag(Qt::ControlModifier) && (event->key() == Qt::Key_PageUp || event->key() == Qt::Key_PageDown)) {