Skip to content

Commit 50b48bc

Browse files
committed
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.
1 parent 8ffe641 commit 50b48bc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ExtendedTableWidget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,10 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event)
951951
} else {
952952
// When pressing Delete only set the value to empty string
953953
for(const QModelIndex& index : selectedIndexes())
954-
model()->setData(index, "");
954+
{
955+
if(!model()->setData(index, ""))
956+
return;
957+
}
955958
}
956959
}
957960
} else if(event->modifiers().testFlag(Qt::ControlModifier) && (event->key() == Qt::Key_PageUp || event->key() == Qt::Key_PageDown)) {

0 commit comments

Comments
 (0)