From 93ed02e3b1718a560fb8028c80e63b511d334410 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Mon, 4 Feb 2013 02:01:28 +0100 Subject: fix QSqlTableModel:revert() for OnFieldChange revert() should operate in OnFieldChange edit strategy just as submit() does. The reason in Qt 4 for excluding OnFieldChange was that there was no opportunity to revert. The model was refreshed, causing all changes to be lost. In Qt 5 a failed edit remains in the cache until user action, which could be to revert. Change-Id: Ide021c4f83a53834b7ed81f2abfa3aa49317704d Reviewed-by: Mark Brand --- src/sql/models/qsqltablemodel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/sql/models') diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 2822c8bb73..2e395b0a59 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -839,7 +839,8 @@ bool QSqlTableModel::submit() user canceled editing the current row. Reverts the changes if the model's strategy is set to - OnRowChange. Does nothing for the other edit strategies. + OnRowChange or OnFieldChange. Does nothing for the OnManualSubmit + strategy. Use revertAll() to revert all pending changes for the OnManualSubmit strategy or revertRow() to revert a specific row. @@ -849,7 +850,7 @@ bool QSqlTableModel::submit() void QSqlTableModel::revert() { Q_D(QSqlTableModel); - if (d->strategy == OnRowChange) + if (d->strategy == OnRowChange || d->strategy == OnFieldChange) revertAll(); } -- cgit v1.2.3