diff options
author | Michael Goddard <michael.goddard@nokia.com> | 2011-02-18 02:16:04 (GMT) |
---|---|---|
committer | Michael Goddard <michael.goddard@nokia.com> | 2011-02-18 04:05:38 (GMT) |
commit | 346af37b7bc8d97ae4cc24b0a1cfe9cf4802057b (patch) | |
tree | dd32ff5a347ebbe1206ca59d1a953fe55b98290e /tests/auto/qsqltablemodel | |
parent | b0822a83a3719ed32f6bf7f78c2ff1ba46837355 (diff) | |
download | Qt-346af37b7bc8d97ae4cc24b0a1cfe9cf4802057b.zip Qt-346af37b7bc8d97ae4cc24b0a1cfe9cf4802057b.tar.gz Qt-346af37b7bc8d97ae4cc24b0a1cfe9cf4802057b.tar.bz2 |
Fix an issue with removing rows in a table model.
Tables with nulls in a row were not being deleted properly in some
cases. Made sure the responsible function no longer has default
parameters so this doesn't happen again.
Change-Id: I479121172d5ac172ca49da78638b9353d7a67548
Task-number: QTBUG-16007, QTBUG-15979
Reviewed-by: Charles Yin
Diffstat (limited to 'tests/auto/qsqltablemodel')
-rw-r--r-- | tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index f7d2180..bf68375 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -773,6 +773,27 @@ void tst_QSqlTableModel::removeInsertedRow() QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond")); QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi")); + + // Now insert a row with a null, and check that removing it also works (QTBUG-15979 etc) + model.insertRow(1); + model.setData(model.index(1,0), 55); + model.setData(model.index(1,1), QString("null columns")); + model.setData(model.index(1,2), QVariant()); + + model.submitAll(); + + QCOMPARE(model.rowCount(), 4); + QCOMPARE(model.data(model.index(3, 0)).toInt(), 55); + QCOMPARE(model.data(model.index(3, 1)).toString(), QString("null columns")); + QCOMPARE(model.data(model.index(3, 2)).isNull(), true); + + QVERIFY(model.removeRow(3)); + model.submitAll(); + QCOMPARE(model.rowCount(), 3); + + QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond")); + QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi")); } void tst_QSqlTableModel::removeInsertedRows() |