summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql/models/qsqltablemodel
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-03-13 01:28:35 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-15 15:35:32 +0100
commit108748404beb607538ea965a21fa932d275eecdd (patch)
treee2d8f5b11ea3b2897d0dd2f61fcfdcbff10d4bdc /tests/auto/sql/models/qsqltablemodel
parent3d7cec6577fa32fb6036b346db57c53e38ea2ffd (diff)
QSqlTableModel::setData(): no longer autosubmit for OnRowChange
The model can never do a good job of knowing when user moves to a new row in the view. Faking it by detecting when another row is changed was not a good solution because it cannot detect when the last edited row is left. Either the view should automatically submit when the user leaves a row or the application should provide a way to submit. This change made it possible to reuse the logic of flags() in setData(). Change-Id: I2550e5b113bceba1a852fc21203babeca07c5748 Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
Diffstat (limited to 'tests/auto/sql/models/qsqltablemodel')
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index 0bdcb3bce6..8bc71257e3 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -1067,6 +1067,26 @@ void tst_QSqlTableModel::isDirty()
QFAIL_SQL(model, isDirty(model.index(0, 1)));
}
+ if (submitpolicy == QSqlTableModel::OnRowChange) {
+ // dirty row must block change on other rows
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
+ QVERIFY(model.rowCount() > 1);
+ QVERIFY_SQL(model, setData(model.index(0, 1), QString("sam i am")));
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("sam i am"));
+ QVERIFY_SQL(model, isDirty());
+ QVERIFY_SQL(model, isDirty(model.index(0, 1)));
+ QVERIFY(!(model.flags(model.index(1, 1)) & Qt::ItemIsEditable));
+ QFAIL_SQL(model, setData(model.index(1, 1), QString("sam i am")));
+ QFAIL_SQL(model, setRecord(1, model.record(1)));
+ QFAIL_SQL(model, insertRow(1));
+ QFAIL_SQL(model, isDirty(model.index(1, 1)));
+
+ model.revertAll();
+ QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
+ QFAIL_SQL(model, isDirty());
+ QFAIL_SQL(model, isDirty(model.index(0, 1)));
+ }
+
// setData() followed by submitAll()
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
QVERIFY_SQL(model, setData(model.index(0, 1), QString("sam i am")));