summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-02-06 15:03:25 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-08 14:43:18 +0100
commit5953304bc5f50eca77f78fd0623479de6bebacbe (patch)
treef410b506565b85a03c81c40c0441328b2b73972f /tests/auto
parentf5e58a1f69e5d17369198bbf1e7bb8946e3c7b5d (diff)
QSqlTableModel::setRecord(): do not try to detect value changes
In an apparent attempt to be economical with emitting dataChanged() and submitting SQL to the databse, setRecord() compares each field value of the record with the old value, taking action only when a difference is detected. Several complaints against this code are: -The comparision does not work on float type. -It is really up to the application and database to decide this. The model should make few assumptions. The application has the option to omit fields from the record that should be ignored. -The current behavior seems to assume that the "old" values are the current state of the database, but the database may have changed since the model was last refreshed. -The code compares the value from record(), which probably corresponds to the EditRole, with the DisplayRole value from data(). Change-Id: I11477c185eb411d442144dc682893d0df12d03d5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index 6a827e65c5..518c6b6d25 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -412,10 +412,10 @@ void tst_QSqlTableModel::setRecord()
model.submit();
else {
// dataChanged() is not emitted when submitAll() is called
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.count(), model.columnCount());
QCOMPARE(spy.at(0).count(), 2);
- QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(0)), model.index(i, 1));
- QCOMPARE(qvariant_cast<QModelIndex>(spy.at(0).at(1)), model.index(i, 1));
+ QCOMPARE(qvariant_cast<QModelIndex>(spy.at(1).at(0)), model.index(i, 1));
+ QCOMPARE(qvariant_cast<QModelIndex>(spy.at(1).at(1)), model.index(i, 1));
}
}