summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2010-11-17 07:30:40 (GMT)
committerMichael Goddard <michael.goddard@nokia.com>2011-02-04 05:41:03 (GMT)
commitbdd4a9149789f60974603e1f7621d51378f0a108 (patch)
tree4fea7c7337799c5df11e7273a7ee04125bf3fd26 /src/sql
parent594e46bdd36d2964c20cbc5a8de32abd5e343f43 (diff)
downloadQt-bdd4a9149789f60974603e1f7621d51378f0a108.zip
Qt-bdd4a9149789f60974603e1f7621d51378f0a108.tar.gz
Qt-bdd4a9149789f60974603e1f7621d51378f0a108.tar.bz2
Fix some removeRows issues with QSqlTableModel.
Added some better unit testing around the problem areas. Change-Id: Ie4749da298aebbae6aec9558ebe8c8f2196c705f Task-number: QTBUG-14916 Reviewed-by: Charles Yin
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/models/qsqltablemodel.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index c6efbad..4df1d63 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1103,9 +1103,12 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)
int idx = row + i;
if (idx >= rowCount())
return false;
- if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert)
+ if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) {
revertRow(idx);
- else {
+ // Reverting a row means all the other cache entries have been adjusted downwards
+ // so fake this by adjusting row
+ --row;
+ } else {
d->cache[idx].op = QSqlTableModelPrivate::Delete;
d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row());
emit headerDataChanged(Qt::Vertical, idx, idx);