summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-02-06 17:02:32 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-07 22:05:51 +0100
commitf5e1da12f0e7bdeee4db74acc52dfabeb12a4e31 (patch)
tree9cd38a186e7d07890f3d2b2a558cf4958d28c0de
parent63f634322b2c0f795bd424be9e51953a10c701de (diff)
QSqlTableModel::removeRows(): don't emit extra beforeDelete
Qt 5 seems like a welcome opportunity to stop emitting this spurious beforeDelete signal. Change-Id: Ib8628343ca9b8fdd85c154a206c7e2bf2c4c9dc1 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
-rw-r--r--dist/changes-5.0.02
-rw-r--r--src/sql/models/qsqltablemodel.cpp8
-rw-r--r--tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp7
3 files changed, 5 insertions, 12 deletions
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0
index 617b2d3d95..6bacccc34a 100644
--- a/dist/changes-5.0.0
+++ b/dist/changes-5.0.0
@@ -329,6 +329,8 @@ QTestLib
and log formats simultaneously.
+* removeRows() no longer emits extra beforeDelete signal for out of range row.
+
****************************************************************************
* Database Drivers *
****************************************************************************
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 46d493b726..4094052f1a 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -990,8 +990,6 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)
if (parent.isValid() || row < 0 || count <= 0)
return false;
- int initialRowCount = rowCount();
-
int i;
for (i = 0; i < count && row + i < rowCount(); ++i) {
int idx = row + i;
@@ -1012,12 +1010,6 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)
if (d->strategy != OnManualSubmit && i > 0)
submit();
- // historical bug: emit beforeDelete for 1st row beyond end
- if (d->strategy != OnManualSubmit) {
- if (row + count > initialRowCount)
- emit beforeDelete(qMax(initialRowCount, row));
- }
-
if (i < count)
return false;
diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
index c8b5513a29..6a827e65c5 100644
--- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
+++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp
@@ -703,10 +703,9 @@ void tst_QSqlTableModel::removeRows()
QVERIFY(!model.removeRows(1, 0, model.index(2, 0))); // can't pass a valid modelindex
QVERIFY_SQL(model, removeRows(0, 2));
- QCOMPARE(beforeDeleteSpy.count(), 3);
- QVERIFY(beforeDeleteSpy.at(0).at(0).toInt() == 5);
- QVERIFY(beforeDeleteSpy.at(1).at(0).toInt() == 0);
- QVERIFY(beforeDeleteSpy.at(2).at(0).toInt() == 1);
+ QCOMPARE(beforeDeleteSpy.count(), 2);
+ QVERIFY(beforeDeleteSpy.at(0).at(0).toInt() == 0);
+ QVERIFY(beforeDeleteSpy.at(1).at(0).toInt() == 1);
QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("vohi"));
model.clear();