summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2013-01-06 15:17:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-10 14:26:33 +0100
commit771b34fb0c62f8c1e982dbcf256bc90ddaba64b7 (patch)
treec8bc0146ac5b462918af8c798551616fa1b0f1a9 /tests
parent2ec2dbd89072f651be737192337b7f968fa54e42 (diff)
QSqlTableModel: fix dataChanged() index for removed edited row
Last column index is columnCount() - 1 This change is not applicable to Qt 5. Task-number: QTBUG-28961 Change-Id: Ib962ab5f737bf9c216423ee9d0632757d33f3bd2 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
index 19ed8a066c..3a39c375ad 100644
--- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -700,9 +700,21 @@ void tst_QSqlTableModel::removeRow()
QCOMPARE(model.rowCount(), 3);
headerDataChangedSpy.clear();
+ // QTBUG-28961 Model emits dataChanged() for reverted changes before refreshing query
+ // after deleting row. Make sure indices are correct.
+ QVERIFY(model.setData(model.index(1, 1), QString("kurt")));
+ QCOMPARE(model.data(model.index(1, 1)).toString(), QString("kurt"));
+ QSignalSpy dataChangedSpy(&model, SIGNAL(dataChanged(QModelIndex, QModelIndex)));
QVERIFY(model.removeRow(1));
QCOMPARE(headerDataChangedSpy.count(), 0);
QCOMPARE(model.rowCount(), 2);
+ QCOMPARE(dataChangedSpy.count(), 1);
+ QModelIndex idxFirst = qvariant_cast<QModelIndex>(dataChangedSpy.at(0).at(0));
+ QCOMPARE(idxFirst.row(), 1);
+ QCOMPARE(idxFirst.column(), 0);
+ QModelIndex idxLast = qvariant_cast<QModelIndex>(dataChangedSpy.at(0).at(1));
+ QCOMPARE(idxLast.row(), 1);
+ QCOMPARE(idxLast.column(), model.columnCount() - 1);
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("vohi"));