qt5base-lts/tests/auto
Mark Brand f6ca63f896 QSqlTableModel::setData()/setRecord(): fix incorrect row
For OnFieldChange and OnRowChange, before submitting new changes,
setData() and setRecord() attempt to submit pending changes and
revert them upon failure. However, they fail to consider that
reverting pending insertions removes rows from the model. As a
result, the new change can be applied to a row higher than intended.

One possible solution would be to adjust the targetted index for the
removed rows, so that the intended row is affected by the new change.
But this still causes the strange editing experience as rows jump
up just as they are being edited.

It does not seem right in the first place for the model to initiate
reverting changes. It should be up to the application to decide what
to do when data cannot be committed. In particular, setData() and
setRecord() should not have the side effect of reverting already
pending changes.

The chosen solution is simply to refuse new changes that don't make
sense for the edit strategy. For OnFieldChange, flag() will
indicate read-only when editing is blocked by a pending change.

Since setData() and setRecord() submit data immediately for
OnFieldChange, it no longer makes sense to resubmit changes
automatically before a new change.

For OnRowChange, setData() keeps the behavior of automatically
submitting a pending row before starting on a new row. This is
historical behavior and is probably motivated by the fact that
QTableView does not automatically call submit() when editing leaves a
row. The obvious shortcoming of this is that the last row to be edited
will not be submitted automatically. It also prevents us from flagging
rows other than the pending row as read-only.

For OnRowChange, setRecord(), being row-oriented by nature, should
submit the change immediately rather than waiting for the next call
to setRecord(). This makes setRecord() consistent with insertRecord().

Change-Id: Icb4019d8b7c53a7ee48f8121a7a525e8bc35d523
Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
2012-03-15 15:35:17 +01:00
..
bic Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
compilerwarnings/data Remove "All rights reserved" line from license headers. 2012-01-30 03:54:59 +01:00
concurrent Remove commented code from qtconcurrentmap autotest. 2012-03-14 07:51:45 +01:00
corelib UTF8-Codec test: Fix compilation with g++/C++0X. 2012-03-15 14:51:50 +01:00
dbus Avoid using internal testlib API in QDbusConnection autotest. 2012-03-05 03:44:01 +01:00
gui Move tst_qshortcut.cpp to QtWidgets 2012-03-12 21:38:51 +01:00
guiapplauncher Update the documentation after moving examples. 2011-07-05 21:19:08 +02:00
network Mark unstable windows network tests 2012-03-08 05:31:40 +01:00
opengl Remove "All rights reserved" line from license headers. 2012-01-30 03:54:59 +01:00
other Remove unmaintained and broken VNC platform plugin 2012-03-15 02:45:31 +01:00
printsupport Move tst_qprinter.cpp to QtPrintSupport 2012-03-12 13:14:05 +01:00
shared Refactor input context tests 2012-02-22 13:54:13 +01:00
sql QSqlTableModel::setData()/setRecord(): fix incorrect row 2012-03-15 15:35:17 +01:00
testlib testlib: Improve formatting of QCOMPARE failure messages. 2012-03-12 01:50:20 +01:00
tools remove strange .qmake.cache hacks 2012-03-08 18:54:46 +01:00
widgets QTableView: call model->submit() on row change 2012-03-15 00:50:47 +01:00
xml clean up qmake-generated projects 2012-02-24 05:18:30 +01:00
auto.pro Move tst_qprinter.cpp to QtPrintSupport 2012-03-12 13:14:05 +01:00
network-settings.h Remove "All rights reserved" line from license headers. 2012-01-30 03:54:59 +01:00
platformquirks.h Remove "All rights reserved" line from license headers. 2012-01-30 03:54:59 +01:00
test.pl Remove "All rights reserved" line from license headers. 2012-01-30 03:54:59 +01:00