From b979956ec46093e5668c2b264f9b68da3cbb0326 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Wed, 15 Feb 2012 09:56:23 +0100 Subject: QSqlTableModel: handle changes between submit and select Once an insert has been submitted, the cached record behaves like an update. For row bookkeeping, we still have to remember that it was originally inserted and is not in the query rows. Between submitting a delete and selecting, we remove the values from the deleted record. This causes a blank row to be displayed. Read-only flag is set for cells in deleted row. Reverting between submit and select means going back to the last submitted values. When removing rows, it's better to process from highest row numbers to lowest. This avoids complications with higher rows shifting down when lower rows are removed. Change-Id: I8752fa11f7a1b88f2a71b9e03a020ac37e62487f Reviewed-by: Honglei Zhang --- tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index 270de8292b..43829987d4 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -730,10 +730,10 @@ void tst_QSqlTableModel::removeRows() QSignalSpy headerDataChangedSpy(&model, SIGNAL(headerDataChanged(Qt::Orientation, int, int))); QVERIFY(model.removeRows(0, 2, QModelIndex())); QCOMPARE(headerDataChangedSpy.count(), 2); - QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 0); - QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 0); - QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 1); - QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 1); + QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 1); + QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 1); + QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 0); + QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 0); QCOMPARE(model.rowCount(), 3); QVERIFY(beforeDeleteSpy.count() == 0); QVERIFY(model.submitAll()); -- cgit v1.2.3