Fix opening of edit dialog when pressing the return key

Pressing the return key opens the edit dialog or moves focus to the edit
dock (whichever is used). However, when using the edit *dialog* doing
inline editing and then hitting the return key opens the edit dialog
instead of just saving the changes. This is changed by this commit.

See issue #480.
This commit is contained in:
Martin Kleusberg
2016-01-06 20:29:13 +01:00
parent 6d73633608
commit a7b5c3f182

View File

@@ -210,7 +210,7 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event)
foreach(const QModelIndex& index, selectedIndexes())
model()->setData(index, "");
}
} else if(event->key() == Qt::Key_Return && selectedIndexes().count() == 1) {
} else if(event->key() == Qt::Key_Return && selectedIndexes().count() == 1 && state() != QTableView::EditingState) {
// When hitting the return key simulate a double click. This way you can change the focus to the editor dock when pressing the
// return key for advanced editing, just like a double click would open the edit dialog
emit doubleClicked(selectedIndexes().at(0));