mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Browse Data: Add keyboard shortcuts for deleting value
Add keyboard shortcut for setting the values of the selected cells to empty string (Delete key) or to NULL (Alt+Delete). See issue #443.
This commit is contained in:
@@ -75,6 +75,17 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event)
|
||||
selectedIndexes().at(0).row() == model()->rowCount()-1 && selectedIndexes().at(0).column() == model()->columnCount()-1) {
|
||||
// If the Tab key was pressed while the focus was on the last cell of the last row insert a new row automatically
|
||||
model()->insertRow(model()->rowCount());
|
||||
} else if(event->key() == Qt::Key_Delete) {
|
||||
if(event->modifiers().testFlag(Qt::AltModifier))
|
||||
{
|
||||
// When pressing Alt+Delete set the value to NULL
|
||||
foreach(const QModelIndex& index, selectedIndexes())
|
||||
model()->setData(index, QString());
|
||||
} else {
|
||||
// When pressing Delete only set the value to empty string
|
||||
foreach(const QModelIndex& index, selectedIndexes())
|
||||
model()->setData(index, "");
|
||||
}
|
||||
}
|
||||
|
||||
// This prevents the current selection from being changed when pressing tab to move to the next filter. Note that this is in an 'if' condition,
|
||||
|
||||
Reference in New Issue
Block a user